项目作者: writetome51

项目描述 :
2 functions that check if the argument has a 'length' property with a value of 0
高级语言: JavaScript
项目地址: git://github.com/writetome51/is-empty-not-empty.git
创建时间: 2019-04-08T17:45:46Z
项目社区:https://github.com/writetome51/is-empty-not-empty

开源协议:MIT License

下载


isEmpty(arg): boolean

Returns true if arg.length === 0.

notEmpty(arg): boolean

Returns true if arg.length !== 0.

Examples

  1. isEmpty([]);
  2. // --> true
  3. isEmpty('');
  4. // --> true
  5. isEmpty({length: 0});
  6. // --> true
  7. isEmpty({length: -1});
  8. // --> false
  9. isEmpty();
  10. // TypeError: "Cannot read property 'length' of undefined"
  11. isEmpty(0);
  12. // Error: "Input must have a 'length' property"
  13. notEmpty([0]);
  14. // --> true
  15. notEmpty(' ');
  16. // --> true
  17. notEmpty({length: -1})
  18. // --> true
  19. notEmpty();
  20. // TypeError: "Cannot read property 'length' of undefined"
  21. notEmpty(1);
  22. // Error: "Input must have a 'length' property"

Installation

npm i @writetome51/is-empty-not-empty

Loading

  1. import { isEmpty, notEmpty } from '@writetome51/is-empty-not-empty';