is-core-module
Is this specifier a node.js core module?
Last updated 24 days ago by ljharb .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install is-core-module 
SYNC missed versions from official npm registry.

is-core-module Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

Is this specifier a node.js core module? Optionally provide a node version to check; defaults to the current node version.

Example

var isCore = require('is-core-module');
var assert = require('assert');
assert(isCore('fs'));
assert(!isCore('butts'));

TypeScript

isCore accepts any string. isCore.Module is the union of every specifier in core.json, regardless of node version, so editors can suggest them.

The types import core.json, so resolveJsonModule, esModuleInterop, and allowSyntheticDefaultImports must be enabled; some module and moduleResolution settings enable them by default, but node16 does not enable resolveJsonModule. Without them, TypeScript reports an error in this package's index.d.ts, or, with skipLibCheck, isCore.Module silently widens to string | number | symbol.

import isCore = require('is-core-module');

function isBuiltin(specifier: string): boolean {
	return isCore(specifier); // any string is accepted
}

const name: isCore.Module = 'node:fs'; // only specifiers listed in `core.json`
isCore(name, '16.0.0'); // true

Tests

Clone the repo, npm install, and run npm test

Current Tags

  • 2.18.0                                ...           latest (24 days ago)

28 Versions

  • 2.18.0                                ...           24 days ago
  • 2.17.0                                ...           2 months ago
  • 2.16.2                                ...           7 months ago
  • 2.16.1                                ...           2 years ago
  • 2.16.0                                ...           2 years ago
  • 2.15.1                                ...           2 years ago
  • 2.15.0                                ...           2 years ago
  • 2.14.0                                ...           2 years ago
  • 2.13.1                                ...           3 years ago
  • 2.13.0                                ...           3 years ago
  • 2.12.1                                ...           4 years ago
  • 2.12.0                                ...           4 years ago
  • 2.11.0                                ...           4 years ago
  • 2.10.0                                ...           4 years ago
  • 2.9.0                                ...           5 years ago
  • 2.8.1                                ...           5 years ago
  • 2.8.0                                ...           5 years ago
  • 2.7.0                                ...           5 years ago
  • 2.6.0                                ...           5 years ago
  • 2.5.0                                ...           5 years ago
  • 2.4.0                                ...           6 years ago
  • 2.3.0                                ...           6 years ago
  • 2.2.0                                ...           6 years ago
  • 2.1.0                                ...           6 years ago
  • 2.0.0                                ...           6 years ago
  • 1.0.2                                ...           12 years ago
  • 1.0.1                                ...           12 years ago
  • 1.0.0                                ...           12 years ago
Maintainers (1)
Downloads
Total 116
Today 1
This Week 5
This Month 63
Last Day 0
Last Week 36
Last Month 37
Dependencies (1)
Dev Dependencies (18)

© 2010 - cnpmjs.org x YWFE | Home | YWFE