source: imaps-frontend/node_modules/unbox-primitive/README.md@ d565449

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

Update repo after prototype presentation

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[d565449]1# unbox-primitive <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
12Unbox a boxed JS primitive value. This module works cross-realm/iframe, does not depend on `instanceof` or mutable properties, and works despite ES6 Symbol.toStringTag.
13
14## Example
15
16```js
17var unboxPrimitive = require('unbox-primitive');
18var assert = require('assert');
19
20assert.equal(unboxPrimitive(new Boolean(false)), false);
21assert.equal(unboxPrimitive(new String('f')), 'f');
22assert.equal(unboxPrimitive(new Number(42)), 42);
23const s = Symbol();
24assert.equal(unboxPrimitive(Object(s)), s);
25assert.equal(unboxPrimitive(new BigInt(42)), 42n);
26
27// any primitive, or non-boxed-primitive object, will throw
28```
29
30## Tests
31Simply clone the repo, `npm install`, and run `npm test`
32
33[package-url]: https://npmjs.org/package/unbox-primitive
34[npm-version-svg]: https://versionbadg.es/ljharb/unbox-primitive.svg
35[deps-svg]: https://david-dm.org/ljharb/unbox-primitive.svg
36[deps-url]: https://david-dm.org/ljharb/unbox-primitive
37[dev-deps-svg]: https://david-dm.org/ljharb/unbox-primitive/dev-status.svg
38[dev-deps-url]: https://david-dm.org/ljharb/unbox-primitive#info=devDependencies
39[npm-badge-png]: https://nodei.co/npm/unbox-primitive.png?downloads=true&stars=true
40[license-image]: https://img.shields.io/npm/l/unbox-primitive.svg
41[license-url]: LICENSE
42[downloads-image]: https://img.shields.io/npm/dm/unbox-primitive.svg
43[downloads-url]: https://npm-stat.com/charts.html?package=unbox-primitive
44[codecov-image]: https://codecov.io/gh/ljharb/unbox-primitive/branch/main/graphs/badge.svg
45[codecov-url]: https://app.codecov.io/gh/ljharb/unbox-primitive/
46[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/unbox-primitive
47[actions-url]: https://github.com/ljharb/unbox-primitive/actions
Note: See TracBrowser for help on using the repository browser.