A simple, performant utility to determine if a value is a boolean.
Full documentation is available at the zerodep.app page.
All @zerodep packages support both ESM and CJS.
import { isBoolean } from '@zerodep/is-boolean';
// or
const { isBoolean } = require('@zerodep/is-boolean');
isBoolean(true); // true
isBoolean(false); // true
isBoolean(new Boolean(true)); // true
isBoolean(['a', 'b', 'c']); // false
isBoolean(1000n); // false
isBoolean(new Date()); // false
isBoolean(''); // false
isBoolean(new Error('message')); // false
isBoolean(3.14); // false
isBoolean(() => 'function'); // false
isBoolean(42); // false
isBoolean(
new Map([
['a', 1],
['b', 2],
])
); // false
isBoolean(null); // false
isBoolean({ an: 'object' }); // false
isBoolean(new Promise(() => {})); // false
isBoolean(/[regex]+/gi); // false
isBoolean(new Set([1, 2, 3])); // false
isBoolean('a string'); // false
isBoolean(Symbol()); // false
isBoolean(new Int32Array(2)); // false
isBoolean(undefined); // false