Open In App

Node.js isWebAssemblyCompiledModule() Method

Last Updated : 15 Sep, 2020
Improve
Improve
Like Article
Like
Save
Share
Report

It is a function that returns a true or false by checking a module is built-in WebAssembly.Module instance.

It checks whether the given module is an instance of WebAssembly.Module 

Syntax:

util.types.isWebAssemblyCompiledModule(module);

Parameters

  • value: This value parameter is of any type. It is the value for which the function is to be checked for.

Return Value:

  • True, if the value is a built-in WebAssembly.Module instance.
  • False,  if the value is not a built-in WebAssembly.Module instance.

Example 1: Filename index.js




const util = require('util')
const morgan = require('morgan');
const mongoose = require('mongoose')
  
console.log(util.types
  .isWebAssemblyCompiledModule(morgan));
console.log(util.types
  .isWebAssemblyCompiledModule(mongoose));


Output: 

false
false

Example 2: Filename index.js




const util = require('util')
const a = require('./a.js'); 
  
if(util.types.isWebAssemblyCompiledModule(a)) {
    console.log("It is an web assembly module instance")
} else {
    console.log("It is not an web assembly module instance")
}


To run the file, use the following command:

node index.js

Output:

It is not an web assembly module instance

Reference: https://nodejs.org/api/util.html#util_util_types_iswebassemblycompiledmodule_value


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads