js-utils-deep
v1.1.4
Published
Javascript Deep Utility functions
Downloads
13,172
Maintainers
Readme
JavaScript Deep Utility Functions
recursiveOmit (deepObject)
Recursively omits the null, '', undefined values from the object. Checks all levels deep to remove the keys associated.
let deepObject = {
x: {
y: {
z: ''
}
a: {
b: null,
c: undefined
}
d: null
}
};
recursiveOmit(deepObject) // returns {}
deepExtend (object1, object2)
Deeply extend object1 with object2 where object1 will be target and object2 will be source.
let object1 = {
x: {
y: {
z: ''
}
a: {
b: null,
c: undefined
}
}
};
let object 2 = {
x: {
y: {
z: 'z',
}
a: {
b: 'b',
c: 'c'
}
d: 'd'
}
};
deepExtend(object1, object2)
/* returns {
x: {
y: {
z: 'z',
}
a: {
b: 'b',
c: 'c'
}
d: 'd'
}
}; */
diffObject(object1, object2)
Compares object1 with object2 and returns the different key value pairs.
eg: let object1 = {
x: 'a',
y: 'b'
};
let object 2 = {
x: 'a',
z: 'c',
};
diffObject(object1, object2)
/* returns {
y: 'b',
z: 'c'
}; */