0.0.1 • Published 9 years ago
@joegesualdo/strip-keys-with-empty-values v0.0.1
@joegesualdo/strip-keys-with-empty-values 
Strip an object's keys with empty values. Supports nested objects.
Install
$ npm install --save @joegesualdo/strip-keys-with-empty-valuesUsage
import stripKeysWithEmptyValues from "@joegesualdo/strip-keys-with-empty-values"
let obj = {
name: 'joe',
age: '',
job: {
title: 'cool',
hours: ''
}
}
stripKeysWithEmptyValues(obj, true)
//=> {
// name: 'joe',
// job: {
// title: 'cool'
// }
// }API
stripKeysWithEmptyValues(obj, nested)
Strips the keys with empty values. Support nested objects.
| Name | Type | Description |
|---|---|---|
| obj | Object | The object you want to strip |
| nested | Boolean | Should the keys of nested objects be stripped? |
Returns: Object, that represents the obj provided but with the empty keys stripped.
import stripKeysWithEmptyValues from "@joegesualdo/strip-keys-with-empty-values"
let obj = {
name: 'joe',
age: '',
job: {
title: 'cool',
hours: ''
}
}
stripKeysWithEmptyValues(obj, true)
//=> {
// name: 'joe',
// job: {
// title: 'cool'
// }
// }Test
$ npm testBuild
$ npm run buildLicense
MIT © Joe Gesualdo
0.0.1
9 years ago