1.1.1 • Published 5 months ago

get-intrinsic v1.1.1

Weekly downloads
15,160,283
License
MIT
Repository
github
Last release
5 months ago

get-intrinsic Version Badge

dependency status dev dependency status License Downloads

npm badge

Get and robustly cache all JS language-level intrinsics at first require time.

See the syntax described in the JS spec for reference.

Example

var GetIntrinsic = require('get-intrinsic');
var assert = require('assert');

// static methods
assert.equal(GetIntrinsic('%Math.pow%'), Math.pow);
assert.equal(Math.pow(2, 3), 8);
assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8);
delete Math.pow;
assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8);

// instance methods
var arr = [1];
assert.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push);
assert.deepEqual(arr, [1]);

arr.push(2);
assert.deepEqual(arr, [1, 2]);

GetIntrinsic('%Array.prototype.push%').call(arr, 3);
assert.deepEqual(arr, [1, 2, 3]);

delete Array.prototype.push;
GetIntrinsic('%Array.prototype.push%').call(arr, 4);
assert.deepEqual(arr, [1, 2, 3, 4]);

// missing features
delete JSON.parse; // to simulate a real intrinsic that is missing in the environment
assert.throws(() => GetIntrinsic('%JSON.parse%'));
assert.equal(undefined, GetIntrinsic('%JSON.parse%', true));

Tests

Simply clone the repo, npm install, and run npm test

Security

Please email @ljharb or see https://tidelift.com/security if you have a potential security vulnerability to report.

es-abstractcall-binddeep-equalarray-includesside-channelstring.prototype.matchallinternal-slotes-get-iteratorpromise.allsettledvuedragdropuploadimagesairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxf@phil8795/pecuniarius-apideneme323112@texttree/demo-bsa-reference-rclreact-native-dsphoto-modulemath.log1pmncss@amraneze/react-instagram-login@seculum/vue-dev-clone@saeon/logger@saeon/ol-react@saeon/snap-menus@sung/subsequence@stansaal/ckeditor5-custom-build@openpolitica/matomo-nextstnenopmoc-iusticky-scroll-catch@arielapaula/components@arielapaula/testtmwg-react-ui@kirrosh/pts@blkmarketco/components-library@bebopskull/lotide@thirstcreative/nuxt-module@graines-digitales/nice-handsome-buttonstring.prototype.replaceallstring.prototype.split@headgum/tko-mappingtailwind-vector-effect@eliteswap/token-lists@eliteswap/v2-core@fazal/ckeditor5-custom-build@torswap/tor-token-lists@buganto/clientpony-react-uipromise.anyreact-native-android-advertising-idreact-native-test-module-hhhpixiu-swap-corepixiuswap-libs-sdkrn-pdf-reader-offlinereact-native-responsive-sizereact-native-is7react-native-flyyreact-native-modal-progress-barreflect.getprototypeof@levlevin/react-portal-tooltip@moezx/metingtypescript-promise-anyvue-v3-yandex-metrikavue-writervue-dev-clonebirken-react-native-community-image-editor@xswap/token-lists@xswap/v2-corearray.prototype.copywithin@vitali_shcherbina/styled-libchain_diggerckeditor5-build-custom-strapickeditor5-click-virtualckeditor5-strapi-msgckeditor-5-imi-1cpcs6_logger@dalygbarron/fish-tank@posturize/react-resizable-rotatable-draggable@cryptocode99/token-listses-create-array-iteratores-aggregate-errorgetprototypeofgql_din_mod@corelmax/react-native-my2c2p-sdkeasyplayer-mydrowl-base-theme-iconsetelvyjavascript-clientdemo-component-skyflyer86
1.1.1

5 months ago

1.1.0

5 months ago

1.0.2

6 months ago

1.0.1

8 months ago

1.0.0

8 months ago