项目作者: almeidx

项目描述 :
高级语言: TypeScript
项目地址: git://github.com/almeidx/is-empty.git
创建时间: 2020-10-04T23:31:49Z
项目社区:https://github.com/almeidx/is-empty

开源协议:MIT License

下载


@almeidx/is-empty

Checks if value is an empty object, collection, map, or set.

Objects are considered empty if they have no own enumerable string keyed properties.

Array-like values such as arguments objects, arrays, buffers, strings, or jQuery-like collections are considered empty if they have a length of 0. Similarly, maps and sets are considered empty if they have a size of 0.

Install

  1. yarn add @almeidx/is-empty

or

  1. npm i @almeidx/is-empty

Usage

  1. isEmpty(value?: any): boolean

Examples

  1. import isEmpty from '@almeidx/is-empty';
  2. // or
  3. const { isEmpty } = require('@almeidx/is-empty');
  4. isEmpty(null);
  5. // => true
  6. isEmpty(true);
  7. // => true
  8. isEmpty(1);
  9. // => false
  10. isEmpty([1, 2, 3]);
  11. // => false
  12. isEmpty({ a: 1 });
  13. // => false