unbox-primitive
Advanced tools
Unbox a boxed JS primitive value.
Weekly downloads
Changelog
v1.0.2 - 2022-04-24
e6420b9
b90aff2
bcc39b9
eslint
, @ljharb/eslint-config
, object-inspect
, safe-publish-latest
, tape
a704a32
call-bind
instead of function-bind
0a609f1
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, object-inspect
, safe-publish-latest
, tape
6a45317
eslint
, @ljharb/eslint-config
, aud
, auto-changelog
, object-inspect
, tape
795c76f
has-bigints
, has-symbols
257a065
Readme
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.
var unboxPrimitive = require('unbox-primitive');
var assert = require('assert');
assert.equal(unboxPrimitive(new Boolean(false)), false);
assert.equal(unboxPrimitive(new String('f')), 'f');
assert.equal(unboxPrimitive(new Number(42)), 42);
const s = Symbol();
assert.equal(unboxPrimitive(Object(s)), s);
assert.equal(unboxPrimitive(new BigInt(42)), 42n);
// any primitive, or non-boxed-primitive object, will throw
Simply clone the repo, npm install
, and run npm test
Unbox a boxed JS primitive value.
The npm package unbox-primitive receives a total of 23,258,661 weekly downloads. As such, unbox-primitive popularity was classified as popular.
We found that unbox-primitive demonstrated a healthy version release cadence and project activity. It has 1 open source maintainer collaborating on the project.