unbox-primitive (1.1.0)

Published 2026-02-24 14:07:52 +00:00 by atheaadmin

Installation

registry=
npm install unbox-primitive@1.1.0
"unbox-primitive": "1.1.0"

About this package

unbox-primitive Version Badge

github actions coverage dependency status dev dependency status License Downloads

npm badge

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.

Example

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

Tests

Simply clone the repo, npm install, and run npm test

Dependencies

Dependencies

ID Version
call-bound ^1.0.3
has-bigints ^1.0.2
has-symbols ^1.1.0
which-boxed-primitive ^1.1.1

Development Dependencies

ID Version
@arethetypeswrong/cli ^0.17.1
@ljharb/eslint-config ^21.1.1
@ljharb/tsconfig ^0.2.2
@types/for-each ^0.3.3
@types/object-inspect ^1.13.0
@types/object-is ^1.1.0
@types/tape ^5.7.0
auto-changelog ^2.5.0
encoding ^0.1.13
es-value-fixtures ^1.5.0
eslint =8.8.0
for-each ^0.3.3
in-publish ^2.0.1
npmignore ^0.3.1
nyc ^10.3.2
object-inspect ^1.13.3
object-is ^1.1.6
safe-publish-latest ^2.0.0
tape ^5.9.0
typescript next

Keywords

unbox boxed primitive object javascript ecmascript
Details
npm
2026-02-24 14:07:52 +00:00
1
Jordan Harband
MIT
latest
6.8 KiB
Assets (1)
Versions (1) View all
1.1.0 2026-02-24