Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

unbox-primitive

ljharb147mMIT1.1.0TypeScript support: included

Unbox a boxed JS primitive value.

unbox, boxed, primitive, object, javascript, ecmascript

readme

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

changelog

Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog and this project adheres to Semantic Versioning.

v1.1.0 - 2024-12-15

Commits

  • [meta] use npmignore to autogenerate an npmignore file 348a5ad
  • [New] add types a324230
  • [Tests] use es-value-fixtures a321ae5
  • [actions] split out node 10-20, and 20+ 04a0e0d
  • [Dev Deps] update @ljharb/eslint-config, auto-changelog, npmignore, object-inspect, object-is, tape 7fff971
  • [actions] update rebase action 91d6807
  • [Deps] update call-bind, has-symbols, which-boxed-primitive f8b6597
  • [Dev Deps] update aud, object-inspect, tape b3362a1
  • [Refactor] use call-bound directly e29ff5f
  • [meta] add missing engines.node d3420bc
  • [Tests] replace aud with npm audit 5e6a6d0
  • [Deps] update which-boxed-primitive 0ff873d
  • [Dev Deps] update aud dd0e373
  • [Dev Deps] add missing peer dep 4f79b24

v1.0.2 - 2022-04-24

Commits

  • [actions] reuse common workflows e6420b9
  • [actions] update codecov uploader b90aff2
  • [readme] add github actions/codecov badges; update URLs bcc39b9
  • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, safe-publish-latest, tape a704a32
  • [Refactor] use call-bind instead of function-bind 0a609f1
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, object-inspect, safe-publish-latest, tape 6a45317
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, auto-changelog, object-inspect, tape 795c76f
  • [Deps] update has-bigints, has-symbols 257a065

v1.0.1 - 2021-03-25

Commits

  • [Tests] use shared travis-ci configs f977e5f
  • [Tests] migrate tests to Github Actions b89def6
  • [meta] do not publish github action workflow files 325d1f1
  • readme 810cd70
  • [Tests] run nyc on all tests; use tape runner 2f5fb08
  • [meta] add auto-changelog 03ed375
  • [actions] add automatic rebasing / merge commit blocking 6dec48d
  • [Dev Deps] update eslint, @ljharb/eslint-config, aud, object-inspect, object-is, tape 528ed88
  • [actions] check out the entire repo 5095b29
  • [actions] add "Allow Edits" workflow 5aa26d7
  • [Dev Deps] update eslint, @ljharb/eslint-config, object-inspect, object-is, safe-publish-latest, tape afc18c6
  • [readme] remove travis badge a025899
  • [Dev Deps] update auto-changelog 9219a32
  • [readme] Fix missing paren in example 73f5a33
  • [Dev Deps] update @ljharb/eslint-config, tape e450acc
  • [Deps] update has-bigints, has-symbols, which-boxed-primitive a4279b5
  • [Dev Deps] update auto-changelog, in-publish, tape b351548
  • [actions] switch Automatic Rebase workflow to pull_request_target event f600382
  • [readme] fix travis links 4d02fa9
  • [Dev Deps] update auto-changelog; add aud 07e74a3
  • [meta] add funding field 7ca4bd7
  • [Tests] only audit prod deps 47d8d5f
  • [Deps] update has-symbols c70c15e

v1.0.0 - 2019-08-10

Commits