1.2.4 • Published 3 months ago

get-intrinsic v1.2.4

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

get-intrinsic Version Badge

github actions coverage 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.matchalles-get-iteratorpromise.allsettledarchetype-librarycomponennentt@dinert/utilseasy-select-rnvuedragdropuploadimagesairscanairscan-examplereact-native-esc-pos-sahaab@borisovart/atol-kkt-module@frxf/frxf@phil8795/pecuniarius-apideneme323112@texttree/demo-bsa-reference-rcl@fundefund/funde_ck@ntt_app/react-native-custom-notificationreact-native-custom-text-hwjamesreact-native-covid-sdkgql_din_modafryxiconsmutasi-bca@jttechnic/interpreter@saeon/ol-react@saeon/quick-form@olivervorasai/sliderreact-native-printer-brothersrn-pdf-reader-offlinecbmis-ai-toolboxreact-native-shekhar-bridge-testasterjscogoportutilsuncoded-connectlevibestliblevibestlib2levilibtest19levilibtest24levilibtest25levilibtest26levilibtest27levilibtest28levilibtest29wilscanner@khalitovadel/abstract-repository@oiti/documentoscopy-react-native@mink-opn/build-tokensquoc-testreact-native-slider-kfhexa-node-common@infinitebrahmanuniverse/nolb-get-i@prodam/prodam-typescclibyarntest@saaspe/componentshyperpass-sdkexpand-react-bridgeexpress-api-pack-tropea-bootstraapluminos-ui-coresklif-ui-kitsklif-api@everything-registry/sub-chunk-1751iqra-calculatorjawwy-sdkjawwy_gamification_release@314oner_npm/universal-components-library@deepakorg/test@deepak757/testreact-native-sphereuisphereuijawwy_libraryreact-native-credit-card-pkgondp149-tablesklif-uimachinebeemrcapsreact-native-jawwy_samplecode-msi-simple_calculator123zs89cli-number-guessingkny63-atm-machinekshahmeer10_atmatm_process@uf3sindh/simple_cli_calculatorhmmmmd12-cli-number-guessinghmd12-cli-number-guessingmenyalatea021easy_currency_convertordumy-currency-convertereasyplayer-mydynamic-ui-practicedynamics-contracts-xemily-webpackef-h5editorjs-text-alignment-tool
1.2.4

3 months ago

1.2.3

3 months ago

1.2.2

6 months ago

1.2.1

12 months ago

1.2.0

1 year ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago