Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
is-boolean-object
Advanced tools
Is this value a JS Boolean? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
The is-boolean-object npm package is a utility that allows you to determine if a given value is a boolean object. This can be particularly useful in scenarios where you need to validate or enforce data types in your JavaScript code.
Check if a value is a boolean object
This feature allows you to check if a given value is a boolean object. The code sample demonstrates how to use the is-boolean-object package to differentiate between primitive boolean values and boolean objects.
const isBooleanObject = require('is-boolean-object');
console.log(isBooleanObject(true)); // false
console.log(isBooleanObject(false)); // false
console.log(isBooleanObject(new Boolean(true))); // true
console.log(isBooleanObject(new Boolean(false))); // true
The is-boolean package is a utility that checks if a value is a boolean primitive. Unlike is-boolean-object, it does not check for boolean objects created with the Boolean constructor.
The lodash.isboolean package is part of the Lodash library and checks if a value is a boolean primitive. It is similar to is-boolean but is part of a larger utility library, offering more functionality beyond just type checking.
The is-primitive package checks if a value is a primitive type, including boolean primitives. It does not specifically check for boolean objects, making it broader in scope compared to is-boolean-object.
Is this value a JS Boolean? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
var isBoolean = require('is-boolean-object');
var assert = require('assert');
assert.notOk(isBoolean(undefined));
assert.notOk(isBoolean(null));
assert.notOk(isBoolean('foo'));
assert.notOk(isBoolean(function () {}));
assert.notOk(isBoolean([]));
assert.notOk(isBoolean({}));
assert.notOk(isBoolean(/a/g));
assert.notOk(isBoolean(new RegExp('a', 'g')));
assert.notOk(isBoolean(new Date()));
assert.notOk(isBoolean(42));
assert.notOk(isBoolean(NaN));
assert.notOk(isBoolean(Infinity));
assert.ok(isBoolean(new Boolean(42)));
assert.ok(isBoolean(false));
assert.ok(isBoolean(Object(false)));
assert.ok(isBoolean(true));
assert.ok(isBoolean(Object(true)));
Simply clone the repo, npm install
, and run npm test
FAQs
Is this value a JS Boolean? This module works cross-realm/iframe, and despite ES6 @@toStringTag.
The npm package is-boolean-object receives a total of 25,304,254 weekly downloads. As such, is-boolean-object popularity was classified as popular.
We found that is-boolean-object demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.