hatch-surf/node_modules/which-boxed-primitive
Riley Zhang df378d33ef
Some checks failed
CI / go (push) Waiting to run
CI / docker (push) Waiting to run
CI / lint-go (push) Waiting to run
CI / lint-docs (push) Waiting to run
CI / check-paperclip (push) Waiting to run
Deploy static site / Deploy to GitHub Pages (push) Has been cancelled
Deploy static site / Deploy via Docker to hatch.surf (push) Has been cancelled
Merge GitHub main into Gitea repo (allow unrelated histories)
Resolved conflicts by taking GitHub versions for:
- .dockerignore, .gitignore, Dockerfile, README.md, docker-compose.yml

Kept deploy.sh updated to:
- Pull from GitHub (primary source)
- Push to Gitea (push-mirror)
- Build from site/ directory (GitHub structure)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-06-25 05:20:46 +02:00
..
.github Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
test Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
.editorconfig Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
.eslintrc Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
.nycrc Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
CHANGELOG.md Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
index.d.ts Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
index.js Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
LICENSE Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
package.json Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
README.md Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00
tsconfig.json Merge GitHub main into Gitea repo (allow unrelated histories) 2026-06-25 05:20:46 +02:00

which-boxed-primitive Version Badge

dependency status dev dependency status License Downloads

npm badge

Which kind of boxed JS primitive is this? This module works cross-realm/iframe, does not depend on instanceof or mutable properties, and works despite ES6 Symbol.toStringTag.

Example

var whichBoxedPrimitive = require('which-boxed-primitive');
var assert = require('assert');

// unboxed primitives return `null`
// boxed primitives return the builtin constructor name

assert.equal(whichBoxedPrimitive(undefined), null);
assert.equal(whichBoxedPrimitive(null), null);

assert.equal(whichBoxedPrimitive(false), null);
assert.equal(whichBoxedPrimitive(true), null);
assert.equal(whichBoxedPrimitive(new Boolean(false)), 'Boolean');
assert.equal(whichBoxedPrimitive(new Boolean(true)), 'Boolean');

assert.equal(whichBoxedPrimitive(42), null);
assert.equal(whichBoxedPrimitive(NaN), null);
assert.equal(whichBoxedPrimitive(Infinity), null);
assert.equal(whichBoxedPrimitive(new Number(42)), 'Number');
assert.equal(whichBoxedPrimitive(new Number(NaN)), 'Number');
assert.equal(whichBoxedPrimitive(new Number(Infinity)), 'Number');

assert.equal(whichBoxedPrimitive(''), null);
assert.equal(whichBoxedPrimitive('foo'), null);
assert.equal(whichBoxedPrimitive(new String('')), 'String');
assert.equal(whichBoxedPrimitive(new String('foo')), 'String');

assert.equal(whichBoxedPrimitive(Symbol()), null);
assert.equal(whichBoxedPrimitive(Object(Symbol()), 'Symbol');

assert.equal(whichBoxedPrimitive(42n), null);
assert.equal(whichBoxedPrimitive(Object(42n), 'BigInt');

// non-boxed-primitive objects return `undefined`
assert.equal(whichBoxedPrimitive([]), undefined);
assert.equal(whichBoxedPrimitive({}), undefined);
assert.equal(whichBoxedPrimitive(/a/g), undefined);
assert.equal(whichBoxedPrimitive(new RegExp('a', 'g')), undefined);
assert.equal(whichBoxedPrimitive(new Date()), undefined);
assert.equal(whichBoxedPrimitive(function () {}), undefined);
assert.equal(whichBoxedPrimitive(function* () {}), undefined);
assert.equal(whichBoxedPrimitive(x => x * x), undefined);
assert.equal(whichBoxedPrimitive([]), undefined);

Tests

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