Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ianstormtaylor/is-empty
Check whether a value is empty.
https://github.com/ianstormtaylor/is-empty
browser javascript node utility
Last synced: 3 months ago
JSON representation
Check whether a value is empty.
- Host: GitHub
- URL: https://github.com/ianstormtaylor/is-empty
- Owner: ianstormtaylor
- Archived: true
- Created: 2013-08-29T00:36:11.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2019-03-07T23:13:12.000Z (over 5 years ago)
- Last Synced: 2024-07-22T00:04:44.345Z (3 months ago)
- Topics: browser, javascript, node, utility
- Language: JavaScript
- Size: 10.7 KB
- Stars: 46
- Watchers: 4
- Forks: 18
- Open Issues: 6
-
Metadata Files:
- Readme: Readme.md
- Changelog: History.md
Awesome Lists containing this project
- awesome-github-star - is-empty
README
> **Archived:** I wrote this package quite a while ago, and I'd consider it an anti-pattern. The main use case for it is checking if an object is empty, which can be done with [`lodash.isEmpty`](https://lodash.com/docs/4.17.11#isEmpty) instead. In many other cases, it's easier and more clear for people reading your code to just check `val.length === 0` or `val.size === 0` instead of using a separate package for it. And people continue to ask for more things to be considered "empty" over time, which are breaking changes, and just make it harder to understand what the API this package really offers is. For that reason, I've archived this package and I don't recommend using it anymore.
# is-empty
Check whether a value is empty.
## Installation
```
$ npm install is-empty
$ npm test
```## Example
```js
var empty = require('is-empty');empty([]); // true
empty({}); // true
empty(''); // true
empty(0); // true
empty(function(){}); // true
empty(null); // true
empty(undefined); // true
empty(new Map()); // true
empty(new Set()); // true
empty(new Error()); // trueempty(true); // false
empty(false); // false
empty(['a', 'b']); // false
empty({ a: 'b' }); // false
empty('string'); // false
empty(42); // false
empty(function(a,b){}); // false
empty(new Map([['key', 'value']])); // false
empty(new Set([1])); // false
empty(new Error('fail'))// false
```## API
### isEmpty(value)
Check whether `value` is empty.
## License
MIT