New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

emptying

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

emptying

Checking or pruning the empty value.

latest
Source
npmnpm
Version
0.1.3
Version published
Maintainers
1
Created
Source

emptying

🈳 Checking or pruning the empty value.

Getting started

npm i emptying

isEmptyValue

Check if a value is empty. Includes undefined, null, empty string, NaN, empty array, empty object, empty Set, empty Map, or array/set/map/object with empty values.

import { isEmptyValue } from 'emptying';

isEmptyValue(undefined); // true
isEmptyValue(null); // true
isEmptyValue(NaN); // true
isEmptyValue(''); // true
isEmptyValue(['']); // true
isEmptyValue([{ a: '' }]); // true
isEmptyValue([{ a: { b: { c: undefined } } }]); // true
isEmptyValue(new Set()); // true
isEmptyValue(new Set([''])); // true
isEmptyValue(new Map()); // true
isEmptyValue(new Map([['a', null]])); // true
isEmptyValue({}); // true
isEmptyValue({ a: null }); // true
isEmptyValue({ a: { b: { c: undefined } } }); // true

isEmptyValue(0); // false
isEmptyValue(true); // false
isEmptyValue(false); // false
isEmptyValue('a'); // false
isEmptyValue(['a']); // false
isEmptyValue([{ a: 'a' }]); // false
isEmptyValue(new Set([1])); // false
isEmptyValue(new Map([['a', 1]])); // false
isEmptyValue({ a: 1 }); // false
isEmptyValue({ a: 1, b: null }); // false

FAQ

What does empty value mean?

An empty value is data that does not need to be saved. For example, data that the API does not want to receive, or meaningless data that wastes storage space.

  • undefined
  • null
  • ''
  • NaN
  • []
  • new Set
  • new Map
  • {}

What kind of data is not empty?

  • number includes 0
  • boolean
  • string with length ' '
  • unknown value. e.g. buffer/error/function/promise/regexp/symbol and so on...

Why divide data this way?

I often need to filter the data before saving it. Data needs to be discarded or nulled when it doesn't make sense, regardless of how deep it is in the hierarchy.

FAQs

Package last updated on 30 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts