remove-undefined-objects
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published

remove-undefined-objects

Build

Installation

npm install --save remove-undefined-objects

Usage

import removeUndefinedObjects from 'remove-undefined-objects';

console.log(removeUndefinedObjects({key: [], key2: 123}));
// { key2: 123 }

Behavior

Any items with the following value will be removed:

  • Empty object, {}
  • Empty array, []
  • Undefined, undefined

The following items will NOT be removed:

  • Empty string, ''
  • Null, null

Options

removeAllFalsy

Optional boolean. If provided, the empty string '' and null will be removed as well.

import removeUndefinedObjects from 'remove-undefined-objects';

console.log(removeUndefinedObjects({key1: null, key2: 123, key3: ''}), {removeAllFalsy: true});
// { key2: 123 }

Readme

Keywords

none

Package Sidebar

Install

npm i remove-undefined-objects

Weekly Downloads

156,981

Version

6.0.0

License

MIT

Unpacked Size

19.3 kB

Total Files

12

Last publish

Collaborators

  • gkoberger
  • domharrington
  • mjcuva
  • kanadgupta
  • jonursenbach
  • rafegoldberg
  • iliast
  • dannobytes
  • gratcliff
  • llimllib
  • darrenyong
  • azinder1
  • kellyjosephprice