nested-clean

Remove recursively all key-value pairs where value is undefined

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
nested-clean
0.0.14 years ago4 years agoMinified + gzip package size for nested-clean in KB

Readme

Nested Clean
Remove recursively all value / key-value pairs where the value is undefined.

Installation

npm install --save nested-clean

Usage

const clean = require('nested-clean');

const nestedObject = {
    a: undefined,
    b: {
        prop1: null,
        prop2: [1, undefined, "a"],
        prop3: "b1"
    },
    c: {
        d: {
            e: {
                f: undefined
            }
        }
    }
}

const cleanedNestedObject = clean(nestedObject);

console.log(cleanedNestedObject);
// { b: { prop1: null, prop2: [ 1, 'a' ], prop3: 'b1' } }