source: trip-planner-front/node_modules/get-intrinsic/README.md@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 2.3 KB
Line 
1# get-intrinsic <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
3[![dependency status][deps-svg]][deps-url]
4[![dev dependency status][dev-deps-svg]][dev-deps-url]
5[![License][license-image]][license-url]
6[![Downloads][downloads-image]][downloads-url]
7
8[![npm badge][npm-badge-png]][package-url]
9
10Get and robustly cache all JS language-level intrinsics at first require time.
11
12See the syntax described [in the JS spec](https://tc39.es/ecma262/#sec-well-known-intrinsic-objects) for reference.
13
14## Example
15
16```js
17var GetIntrinsic = require('get-intrinsic');
18var assert = require('assert');
19
20// static methods
21assert.equal(GetIntrinsic('%Math.pow%'), Math.pow);
22assert.equal(Math.pow(2, 3), 8);
23assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8);
24delete Math.pow;
25assert.equal(GetIntrinsic('%Math.pow%')(2, 3), 8);
26
27// instance methods
28var arr = [1];
29assert.equal(GetIntrinsic('%Array.prototype.push%'), Array.prototype.push);
30assert.deepEqual(arr, [1]);
31
32arr.push(2);
33assert.deepEqual(arr, [1, 2]);
34
35GetIntrinsic('%Array.prototype.push%').call(arr, 3);
36assert.deepEqual(arr, [1, 2, 3]);
37
38delete Array.prototype.push;
39GetIntrinsic('%Array.prototype.push%').call(arr, 4);
40assert.deepEqual(arr, [1, 2, 3, 4]);
41
42// missing features
43delete JSON.parse; // to simulate a real intrinsic that is missing in the environment
44assert.throws(() => GetIntrinsic('%JSON.parse%'));
45assert.equal(undefined, GetIntrinsic('%JSON.parse%', true));
46```
47
48## Tests
49Simply clone the repo, `npm install`, and run `npm test`
50
51## Security
52
53Please email [@ljharb](https://github.com/ljharb) or see https://tidelift.com/security if you have a potential security vulnerability to report.
54
55[package-url]: https://npmjs.org/package/get-intrinsic
56[npm-version-svg]: http://versionbadg.es/ljharb/get-intrinsic.svg
57[deps-svg]: https://david-dm.org/ljharb/get-intrinsic.svg
58[deps-url]: https://david-dm.org/ljharb/get-intrinsic
59[dev-deps-svg]: https://david-dm.org/ljharb/get-intrinsic/dev-status.svg
60[dev-deps-url]: https://david-dm.org/ljharb/get-intrinsic#info=devDependencies
61[npm-badge-png]: https://nodei.co/npm/get-intrinsic.png?downloads=true&stars=true
62[license-image]: https://img.shields.io/npm/l/get-intrinsic.svg
63[license-url]: LICENSE
64[downloads-image]: https://img.shields.io/npm/dm/get-intrinsic.svg
65[downloads-url]: https://npm-stat.com/charts.html?package=get-intrinsic
Note: See TracBrowser for help on using the repository browser.