Skip to content

vkmalik/is-empty-data

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

is-empty-data

Tiny utility to check if a value is empty (null, undefined, '', [], {}, NaN, empty Map/Set).

Install

npm install is-empty-data

Usage

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])); // false

API

isEmptyValue(value)

Returns true if the value is considered empty:

  • null or undefined
  • Empty string (after trim)
  • Empty array
  • Empty object (plain object, no own properties)
  • NaN
  • Empty Map or Set

Returns false otherwise.

License

MIT

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published