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

2.0.7 • Public • Published

@zerodep/is-empty

version language types license

CodeFactor Known Vulnerabilities

A simple, performant utility to determine if a value is null, undefined or an empty array, string, object, Map, Set, WeakMap or WeakSet.

Full documentation is available at the zerodep.app page.

Examples

All @zerodep packages support both ESM and CJS.

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

Positive Response

isEmpty([]); // true
isEmpty(''); // true
isEmpty(null); // true
isEmpty({}); // true
isEmpty(new Map()); // true
isEmpty(new Set()); // true
isEmpty(new WeakMap()); // true
isEmpty(new WeakSet()); // true
isEmpty(undefined); // true

Negative Response

isEmpty(['a', 'b', 'c']); // false
isEmpty(1000n); // false
isEmpty(true); // false
isEmpty(new Date()); // false
isEmpty(new Error('message')); // false
isEmpty(3.14); // false
isEmpty(() => 'function'); // false
isEmpty(42); // false
isEmpty(
  new Map([
    ['a', 1],
    ['b', 2],
  ])
); // false
isEmpty({ an: 'object' }); // false
isEmpty(new Promise(() => {})); // false
isEmpty(/[regex]+/gi); // false
isEmpty(new Set([1, 2, 3])); // false
isEmpty('a string'); // false
isEmpty(Symbol()); // false
isEmpty(new Int32Array(2)); // false

Readme

Keywords

Package Sidebar

Install

npm i @zerodep/is-empty

Homepage

zerodep.app

Weekly Downloads

2

Version

2.0.7

License

MIT

Unpacked Size

7.74 kB

Total Files

7

Last publish

Collaborators

  • cdepage