@zerodep/is-nil
TypeScript icon, indicating that this package has built-in type declarations

2.0.7 • Public • Published

@zerodep/is-nil

version language types license

CodeFactor Known Vulnerabilities

A simple, performant utility to determine if a value is null or undefined.

Full documentation is available at the zerodep.app page.

Examples

All @zerodep packages support both ESM and CJS.

import { isNil } from '@zerodep/is-nil';
// or
const { isNil } = require('@zerodep/is-nil');

Positive Response

isNil(null); // true
isNil(undefined); // true

Negative Response

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

Readme

Keywords

Package Sidebar

Install

npm i @zerodep/is-nil

Homepage

zerodep.app

Weekly Downloads

6

Version

2.0.7

License

MIT

Unpacked Size

4.2 kB

Total Files

7

Last publish

Collaborators

  • cdepage