defined-keys-only
Return a copy of an object with any undefined properties removed
Install
$ npm install --save defined-keys-only
Usage
const definedKeysOnly = var someInput = someDefinedValue: 42 someUndefinedValue: undefined var output = ;// {someDefinedValue: 42}
It can also delete deeply nested undefined values recursively.
var someInput = foo: 42 bing: undefined bar: baz: 42 biz: undefined var output = ;/*{ foo: 42, bar: { baz: 42 }} */
API
definedKeysOnly(input: object, [deep: boolean])
Returns a new object with the same properties as the input
object, with
the exception of any properties with a value of undefined
.
License
MIT © Brandon Dail