Javascript Deep Utility functions
npm install js-utils-deepjavascript
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.`javascript
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.`javascript
eg: let object1 = {
x: 'a',
y: 'b'
};let object 2 = {
x: 'a',
z: 'c',
};
diffObject(object1, object2)
/* returns {
y: 'b',
z: 'c'
}; */
``