Tiny utility to check if a value is empty (null, undefined, '', [], {}, NaN, empty Map/Set).
npm install is-empty-dataconst 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])); // falseReturns 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.
MIT