defined-keys-only

0.0.1 • Public • Published

defined-keys-only

Return a copy of an object with any undefined properties removed

Install

$ npm install --save defined-keys-only

Usage

const definedKeysOnly = require('defined-keys-only')
 
var someInput = {
  someDefinedValue: 42,
  someUndefinedValue: undefined
}
 
var output = definedKeysOnly(someInput);
// {someDefinedValue: 42}
 

It can also delete deeply nested undefined values recursively.

 
var someInput = {
  foo: 42,
  bing: undefined,
  bar: {
    baz: 42,
    biz: undefined
  }
}
 
var output = definedKeysOnly(someInput, true);
/*
{
  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

Readme

Keywords

Package Sidebar

Install

npm i defined-keys-only

Weekly Downloads

1

Version

0.0.1

License

MIT

Last publish

Collaborators

  • aweary