https://github.com/writetome51/is-empty-not-empty
2 javascript functions that check if the argument has a 'length' property with a value of 0
https://github.com/writetome51/is-empty-not-empty
array empty javascript object string
Last synced: about 1 year ago
JSON representation
2 javascript functions that check if the argument has a 'length' property with a value of 0
- Host: GitHub
- URL: https://github.com/writetome51/is-empty-not-empty
- Owner: writetome51
- License: mit
- Created: 2019-04-08T17:45:46.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-11-15T21:28:42.000Z (over 4 years ago)
- Last Synced: 2024-10-16T10:32:02.336Z (over 1 year ago)
- Topics: array, empty, javascript, object, string
- Language: JavaScript
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# isEmpty(arg): boolean
Returns true if `arg.length === 0`.
# notEmpty(arg): boolean
Returns true if `arg.length !== 0`.
## Examples
```js
isEmpty([]);
// --> true
isEmpty('');
// --> true
isEmpty({length: 0});
// --> true
isEmpty({length: -1});
// --> false
isEmpty();
// TypeError: "Cannot read property 'length' of undefined"
isEmpty(0);
// Error: "Input must have a 'length' property"
notEmpty([0]);
// --> true
notEmpty(' ');
// --> true
notEmpty({length: -1})
// --> true
notEmpty();
// TypeError: "Cannot read property 'length' of undefined"
notEmpty(1);
// Error: "Input must have a 'length' property"
```
## Installation
`npm i @writetome51/is-empty-not-empty`
## Loading
```js
import { isEmpty, notEmpty } from '@writetome51/is-empty-not-empty';
```