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