clean-obj

Clean objects recursively, deleting undefined & null or falsy properties


Keywords
obj, object, clean, sanitize, null, undefined, safe
License
MIT
Install
npm install clean-obj@1.0.1

Documentation

clean-obj

Clean objects recursively, deleting undefined & null or falsy properties.

Installation

  npm i clean-obj --save

Usage

cleanObj(obj [,strict])

The usage of this module is very straightforward, as you can see in the example below.

var cleanObj = require('clean-obj')

var obj = {
  key: 'value',
  undf: undefined,
  nullz: null,
  falsy: 0,
  bool: false
}

cleanObj(obj) // { set: 'value', falsy: 0, bool: false }

cleanObj(obj, true) // { set: 'value' }

License

MIT