Registry / testing / get-intrinsic

get-intrinsic

JSON →
library1.3.0jsnpmunverified

get-intrinsic (v1.3.0) provides a robust way to access JavaScript language-level intrinsics (e.g., %Array.prototype.push%) at runtime, caching them at first require. Maintained by ljharb and updated regularly, it is used internally by es-abstract and other ECMAScript polyfill libraries. Key differentiator: guarantees access even when intrinsics are deleted or overridden, with optional allowance for missing features. Published weekly, supports Node >=0.4.

npm install get-intrinsic
INSTALL
IMPORT
SIG · GET-INTRINSIC
G
get-intrinsic
testingjavascriptv1.3.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

GetIntrinsic
const GetIntrinsic = require('get-intrinsic')
import GetIntrinsic from 'get-intrinsic'
CommonJS-only; not an ES module. ESM import fails because package has no 'exports' field or 'type': 'module'.
GetIntrinsic
const GetIntrinsic = require('get-intrinsic'); GetIntrinsic('%Math.pow%')
GetIntrinsic('%Math.pow%')
Always require the module before calling; do not destructure.
GetIntrinsic
const GetIntrinsic = require('get-intrinsic'); GetIntrinsic('%Array.prototype.push%', true)
const { '%Array.prototype.push%' } = require('get-intrinsic')
Second boolean argument allows return of undefined instead of throwing when intrinsic is missing. Not a named export.

Demonstrates requiring the module, accessing cached intrinsics, and using the allowMissing flag.

const GetIntrinsic = require('get-intrinsic'); // Static method console.log(GetIntrinsic('%Math.pow%')(2, 3)); // 8 // Instance method with monkey-patching protection const originalPush = GetIntrinsic('%Array.prototype.push%'); const arr = [1]; originalPush.call(arr, 2); console.log(arr); // [1, 2] // Simulate deletion - cached version still works delete Array.prototype.push; originalPush.call(arr, 3); console.log(arr); // [1, 2, 3] // Allow missing intrinsic console.log(GetIntrinsic('%Missing%', true)); // undefined
Debug
Known issues
gotchaESM import (import GetIntrinsic from 'get-intrinsic') does not work. Package exports CommonJS only.
fix
Use require('get-intrinsic') or configure bundler for CommonJS interop.
affects: >=1.0.0
gotchaIntrinsic names are case-sensitive and must match the spec exactly (e.g., %Math.pow% not %math.pow%).
fix
Refer to the ECMAScript specification for correct intrinsic names.
affects: >=1.0.0
gotchaThe second argument (allowMissing) only works for intrinsics that are allowed to be missing per spec. Some intrinsics always throw if not available.
fix
Check the implementation or spec for which intrinsics are optional.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'get-intrinsic'
Package not installed or required path incorrect.
fix
Run 'npm install get-intrinsic' and ensure require('get-intrinsic') without relative path.
TypeError: GetIntrinsic is not a function
Imported incorrectly via ES import or destructured wrong.
fix
Use const GetIntrinsic = require('get-intrinsic'); do not use import or destructure.
TypeError: %Array.prototype.push% is not a valid intrinsic
Intrinsic name misspelled or not recognized.
fix
Double-check spelling against ECMAScript spec; e.g., '%Array.prototype.push%' (case-sensitive).
get-intrinsic@1.2.0: The engine 'node' is incompatible with this module.
Node version too old (<0.4).
fix
Update Node to >=0.4.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
get-intrinsic — npm install get-intrinsic · libregistry