# unbox-primitive

> Unbox a boxed JS primitive value.

Latest version **1.1.0** (published 2024-12-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install unbox-primitive
pnpm add unbox-primitive
yarn add unbox-primitive
bun add unbox-primitive
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2024-12-16 |
| First published | 2019-08-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >= 0.4 |
| Dependencies | 4 |
| Unpacked size | 18.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Jordan Harband |
| Maintainers | ljharb |
| Keywords | unbox, boxed, primitive, object, javascript, ecmascript |

## Links

- npm: https://www.npmjs.com/package/unbox-primitive
- Repository: https://github.com/ljharb/unbox-primitive
- Homepage: https://github.com/ljharb/unbox-primitive#readme
- Issues: https://github.com/ljharb/unbox-primitive/issues
- Funding: https://github.com/sponsors/ljharb
- npm.io page: https://npm.io/package/unbox-primitive

## Dependencies (4)

- [call-bound](https://npm.io/package/call-bound.md) ^1.0.3
- [has-bigints](https://npm.io/package/has-bigints.md) ^1.0.2
- [has-symbols](https://npm.io/package/has-symbols.md) ^1.1.0
- [which-boxed-primitive](https://npm.io/package/which-boxed-primitive.md) ^1.1.1

## Recent versions

- 1.1.0 (latest) — 2024-12-16
- 1.0.2 — 2022-04-25
- 1.0.1 — 2021-03-25
- 1.0.0 — 2019-08-11

## README

# unbox-primitive <sup>[![Version Badge][npm-version-svg]][package-url]</sup>

[![github actions][actions-image]][actions-url]
[![coverage][codecov-image]][codecov-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![License][license-image]][license-url]
[![Downloads][downloads-image]][downloads-url]

[![npm badge][npm-badge-png]][package-url]

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

```js
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`

[package-url]: https://npmjs.org/package/unbox-primitive
[npm-version-svg]: https://versionbadg.es/ljharb/unbox-primitive.svg
[deps-svg]: https://david-dm.org/ljharb/unbox-primitive.svg
[deps-url]: https://david-dm.org/ljharb/unbox-primitive
[dev-deps-svg]: https://david-dm.org/ljharb/unbox-primitive/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/unbox-primitive#info=devDependencies
[npm-badge-png]: https://nodei.co/npm/unbox-primitive.png?downloads=true&stars=true
[license-image]: https://img.shields.io/npm/l/unbox-primitive.svg
[license-url]: LICENSE
[downloads-image]: https://img.shields.io/npm/dm/unbox-primitive.svg
[downloads-url]: https://npm-stat.com/charts.html?package=unbox-primitive
[codecov-image]: https://codecov.io/gh/ljharb/unbox-primitive/branch/main/graphs/badge.svg
[codecov-url]: https://app.codecov.io/gh/ljharb/unbox-primitive/
[actions-image]: https://img.shields.io/endpoint?url=https://github-actions-badge-u3jn4tfpocch.runkit.sh/ljharb/unbox-primitive
[actions-url]: https://github.com/ljharb/unbox-primitive/actions

---
_Source: https://npm.io/package/unbox-primitive · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
