is-empty-data
v1.1.0
Published
Tiny utility to check if a value is empty
Downloads
8
Maintainers
Readme
is-empty-data
Tiny utility to check if a value is empty (null, undefined, '', [], {}, NaN, empty Map/Set).
Install
npm install is-empty-dataUsage
const isEmptyValue = require('./index');
isEmptyValue(null); // true
isEmptyValue(undefined); // true
isEmptyValue(''); // true
isEmptyValue(' '); // true
isEmptyValue([]); // true
isEmptyValue({}); // true
isEmptyValue(NaN); // true
isEmptyValue(new Map()); // true
isEmptyValue(new Set()); // true
isEmptyValue(42); // false
isEmptyValue('hello'); // false
isEmptyValue([1, 2]); // false
isEmptyValue({ a: 1 }); // false
isEmptyValue(new Map([['a', 1]])); // false
isEmptyValue(new Set([1])); // falseAPI
isEmptyValue(value)
Returns true if the value is considered empty:
nullorundefined- Empty string (after trim)
- Empty array
- Empty object (plain object, no own properties)
NaN- Empty
MaporSet
Returns false otherwise.
License
MIT
