Skip to content

Instantly share code, notes, and snippets.

@whitehorse0
Created February 12, 2020 11:27
Show Gist options
  • Save whitehorse0/275baae4294849d0a89204f5f5d02e38 to your computer and use it in GitHub Desktop.
Save whitehorse0/275baae4294849d0a89204f5f5d02e38 to your computer and use it in GitHub Desktop.
helper function common used
{
getNestedObject: (nestedObj, pathArr) => {
return pathArr.reduce((obj, key) => (obj && obj[key] !== 'undefined') ? obj[key] : undefined, nestedObj)
},
extendObject: (accumulator, currentValue) => {
for (var p in currentValue) {
try {
if (currentValue[p].constructor == Object) {
accumulator[p] = _helper.extendObject(accumulator[p], currentValue[p])
} else {
accumulator[p] = currentValue[p]
}
} catch (e) {
console.error(e)
accumulator[p] = currentValue[p]
}
}
return accumulator
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment