source: imaps-frontend/node_modules/reflect.getprototypeof/README.md

main
Last change on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 3.7 KB
Line 
1# reflect.getprototypeof <sup>[![Version Badge][npm-version-svg]][package-url]</sup>
2
3[![github actions][actions-image]][actions-url]
4[![coverage][codecov-image]][codecov-url]
5[![dependency status][deps-svg]][deps-url]
6[![dev dependency status][dev-deps-svg]][dev-deps-url]
7[![License][license-image]][license-url]
8[![Downloads][downloads-image]][downloads-url]
9
10[![npm badge][npm-badge-png]][package-url]
11
12An ES2015 mostly-spec-compliant `Reflect.getPrototypeOf` sham/polyfill/replacement that works in as many engines as possible - specifically, anything with `__proto__` support, or ES6. Built-in types will also work correctly in older engines.
13
14This package implements the [es-shim API](https://github.com/es-shims/api) interface. It works in an ES3-supported environment and complies with the [spec](https://www.ecma-international.org/ecma-262/5.1/).
15
16## Example
17
18```js
19var getPrototypeOf = require('reflect.getprototypeof');
20var assert = require('assert');
21
22assert.throws(() => getPrototypeOf(true));
23assert.throws(() => getPrototypeOf(42));
24assert.throws(() => getPrototypeOf(''));
25assert.equal(getPrototypeOf(/a/g), RegExp.prototype);
26assert.equal(getPrototypeOf(new Date()), Date.prototype);
27assert.equal(getPrototypeOf(function () {}), Function.prototype);
28assert.equal(getPrototypeOf([]), Array.prototype);
29assert.equal(getPrototypeOf({}), Object.prototype);
30```
31
32```js
33var getPrototypeOf = require('reflect.getprototypeof');
34var assert = require('assert');
35/* when Reflect or Reflect.getPrototypeOf is not present */
36if (typeof Reflect === 'object') { delete Reflect.getPrototypeOf; }
37delete globalThis.Reflect;
38var shimmed = getPrototypeOf.shim();
39assert.equal(shimmed, getPrototypeOf.getPolyfill());
40
41assert.throws(() => Reflect.getPrototypeOf(true));
42assert.throws(() => Reflect.getPrototypeOf(42));
43assert.throws(() => Reflect.getPrototypeOf(''));
44assert.equal(Reflect.getPrototypeOf(/a/g), RegExp.prototype);
45assert.equal(Reflect.getPrototypeOf(new Date()), Date.prototype);
46assert.equal(Reflect.getPrototypeOf(function () {}), Function.prototype);
47assert.equal(Reflect.getPrototypeOf([]), Array.prototype);
48assert.equal(Reflect.getPrototypeOf({}), Object.prototype);
49```
50
51```js
52var getPrototypeOf = require('reflect.getprototypeof');
53var assert = require('assert');
54/* when Reflect.getPrototypeOf is present */
55var shimmedGetPrototypeOf = getPrototypeOf.shim();
56assert.equal(shimmedGetPrototypeOf, Reflect.getPrototypeOf);
57assert.equal(Reflect.getPrototypeOf([]), Array.prototype);
58```
59
60## Tests
61Simply clone the repo, `npm install`, and run `npm test`
62
63[package-url]: https://npmjs.org/package/reflect.getprototypeof
64[npm-version-svg]: https://versionbadg.es/es-shims/Reflect.getPrototypeOf.svg
65[deps-svg]: https://david-dm.org/es-shims/Reflect.getPrototypeOf.svg
66[deps-url]: https://david-dm.org/es-shims/Reflect.getPrototypeOf
67[dev-deps-svg]: https://david-dm.org/es-shims/Reflect.getPrototypeOf/dev-status.svg
68[dev-deps-url]: https://david-dm.org/es-shims/Reflect.getPrototypeOf#info=devDependencies
69[npm-badge-png]: https://nodei.co/npm/reflect.getprototypeof.png?downloads=true&stars=true
70[license-image]: https://img.shields.io/npm/l/reflect.getprototypeof.svg
71[license-url]: LICENSE
72[downloads-image]: https://img.shields.io/npm/dm/reflect.getprototypeof.svg
73[downloads-url]: https://npm-stat.com/charts.html?package=reflect.getprototypeof
74[codecov-image]: https://codecov.io/gh/es-shims/Reflect.getPrototypeOf/branch/main/graphs/badge.svg
75[codecov-url]: https://app.codecov.io/gh/es-shims/Reflect.getPrototypeOf/
76[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/es-shims/Reflect.getPrototypeOf
77[actions-url]: https://github.com/es-shims/Reflect.getPrototypeOf/actions
Note: See TracBrowser for help on using the repository browser.