Skip to content

Remove undefined properties and empty arrays from an object

License

Notifications You must be signed in to change notification settings

JoshuaKGoldberg/remove-undefined-objects

 
 

Repository files navigation

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

About

Remove undefined properties and empty arrays from an object

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 100.0%