
Product
Rust Support Now in Beta
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
unbox-primitive
Advanced tools
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
v1.1.0 - 2024-12-15
npmignore
to autogenerate an npmignore file 348a5ad
a324230
es-value-fixtures
a321ae5
04a0e0d
@ljharb/eslint-config
, auto-changelog
, npmignore
, object-inspect
, object-is
, tape
7fff971
91d6807
call-bind
, has-symbols
, which-boxed-primitive
f8b6597
aud
, object-inspect
, tape
b3362a1
call-bound
directly e29ff5f
engines.node
d3420bc
aud
with npm audit
5e6a6d0
which-boxed-primitive
0ff873d
aud
dd0e373
4f79b24
FAQs
Unbox a boxed JS primitive value.
The npm package unbox-primitive receives a total of 25,954,991 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 because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.