web 3d图形渲染器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.5 KiB

  1. # unbox-primitive <sup>[![Version Badge][2]][1]</sup>
  2. [![dependency status][5]][6]
  3. [![dev dependency status][7]][8]
  4. [![License][license-image]][license-url]
  5. [![Downloads][downloads-image]][downloads-url]
  6. [![npm badge][11]][1]
  7. Unbox 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.
  8. ## Example
  9. ```js
  10. var unboxPrimitive = require('unbox-primitive');
  11. var assert = require('assert');
  12. assert.equal(unboxPrimitive(new Boolean(false)), false);
  13. assert.equal(unboxPrimitive(new String('f')), 'f');
  14. assert.equal(unboxPrimitive(new Number(42)), 42);
  15. const s = Symbol();
  16. assert.equal(unboxPrimitive(Object(s)), s);
  17. assert.equal(unboxPrimitive(new BigInt(42)), 42n);
  18. // any primitive, or non-boxed-primitive object, will throw
  19. ```
  20. ## Tests
  21. Simply clone the repo, `npm install`, and run `npm test`
  22. [1]: https://npmjs.org/package/unbox-primitive
  23. [2]: https://versionbadg.es/ljharb/unbox-primitive.svg
  24. [5]: https://david-dm.org/ljharb/unbox-primitive.svg
  25. [6]: https://david-dm.org/ljharb/unbox-primitive
  26. [7]: https://david-dm.org/ljharb/unbox-primitive/dev-status.svg
  27. [8]: https://david-dm.org/ljharb/unbox-primitive#info=devDependencies
  28. [11]: https://nodei.co/npm/unbox-primitive.png?downloads=true&stars=true
  29. [license-image]: https://img.shields.io/npm/l/unbox-primitive.svg
  30. [license-url]: LICENSE
  31. [downloads-image]: https://img.shields.io/npm/dm/unbox-primitive.svg
  32. [downloads-url]: https://npm-stat.com/charts.html?package=unbox-primitive