From 6317b8432eb86ceca1ef4b4993214f2ea92091e7 Mon Sep 17 00:00:00 2001 From: "hemanth.hm" Date: Fri, 8 Jul 2022 01:12:32 -0700 Subject: module: add isBuiltIn method MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR-URL: https://github.com/nodejs/node/pull/43396 Fixes: https://github.com/nodejs/node/issues/42785 Reviewed-By: James M Snell Reviewed-By: Ruben Bridgewater Reviewed-By: Michaël Zasso Reviewed-By: Anto Aravinth Reviewed-By: Juan José Arboleda --- doc/api/module.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'doc') diff --git a/doc/api/module.md b/doc/api/module.md index 85ba9a79e2..04b5263155 100644 --- a/doc/api/module.md +++ b/doc/api/module.md @@ -62,6 +62,22 @@ const require = createRequire(import.meta.url); const siblingModule = require('./sibling-module'); ``` +### `module.isBuiltin(moduleName)` + + + +* `moduleName` {string} name of the module +* Returns: {boolean} returns true if the module is builtin else returns false + +```mjs +import { isBuiltin } from 'node:module'; +isBuiltin('node:fs'); // true +isBuiltin('fs'); // true +isBuiltin('wss'); // false +``` + ### `module.syncBuiltinESMExports()`