is-boxed-primitive

Is this value a boxed primitive? Shim for node's util.isBoxedPrimitive.

Usage no npm install needed!

<script type="module">
  import isBoxedPrimitive from 'https://cdn.skypack.dev/is-boxed-primitive';
</script>

README

is-boxed-primitive Version Badge

dependency status dev dependency status License Downloads

npm badge

Polyfill/shim for node's util.isBoxedPrimitive()

Example

var isBoxedPrimitive = require('is-boxed-primitive');
var assert = require('assert');

[
    undefined,
    null,
    true,
    false,
    0,
    NaN,
    Infinity,
    0n,
    '',
    'foo',
    Symbol(),
    Symbol.iterator,
].forEach((v) => {
    assert(!isBoxedPrimitive(v)); // primitive form is not boxed
    if (v != null) {
        assert(isBoxedPrimitive(Object(v))); // object form is boxed
    }
});

Tests

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