Socket
Socket
Sign inDemoInstall

unbox-primitive

Package Overview
Dependencies
20
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    unbox-primitive

Unbox a boxed JS primitive value.


Version published
Weekly downloads
24M
decreased by-17.02%
Maintainers
1
Install size
248 kB
Created
Weekly downloads
 

Changelog

Source

v1.0.2 - 2022-04-24

Commits

Readme

Source

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

Keywords

FAQs

Last updated on 25 Apr 2022

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc