Universal drop-in replacement for module.isBuiltin
This package is a universal drop-in replacement for module.isBuiltin.
This package exports a single function that can be used to determine if a module is a builtin module. Builtin
modules are core modules maintained by Node.js. They can be imported by name or using a node: URL.
This package is ESM only.
yarn add @flex-development/is-builtinFrom Git:
yarn add @flex-development/is-builtin@flex-development/is-builtinSee Git - Protocols | Yarn for details on requesting a specific branch, commit, or tag.
import { isBuiltin } from '@flex-development/is-builtin'
import { URL, pathToFileURL } from 'node:url'
console.debug(isBuiltin('@flex-development/is-builtin')) // false
console.debug(isBuiltin('fs/promises')) // true
console.debug(isBuiltin('node:module')) // true
console.debug(isBuiltin(new URL('node:os'))) // true
console.debug(isBuiltin(pathToFileURL('node_modules/@flex-development/mlly'))) // falseThis package exports the following identifiers:
There is no default export.
Checks if the given module id is a builtin module.
Supports bare specifiers and node: URLs. If the given module id is an instance of URL,
id.href will be checked instead.
id(URL | string) — Module id to evaluate
Returns true if id is a builtin module, false otherwise.
This package is fully typed with TypeScript.
builtin-modules— Universal drop-in replacement formodule.builtinModules
See CONTRIBUTING.md.