Skip to content

Instantly share code, notes, and snippets.

@krfong916
Created January 22, 2020 00:50
Show Gist options
  • Save krfong916/c5b603c2c1645147654fc3e2c77eef9b to your computer and use it in GitHub Desktop.
Save krfong916/c5b603c2c1645147654fc3e2c77eef9b to your computer and use it in GitHub Desktop.
A list of all the custom util functions I've created
function callAll(...functions) {
return function(...args) {
functions.forEach(function(fn) {
fn(...args)
})
}
}
function pluck(property, obj) {
return Object.keys(obj).reduce((temp, key) => {
if (key != property) temp[key] = obj[key]
return temp
}, {})
}
function shallowCompare(obj1, obj2) {
return (
Object.keys(obj1).length == Object.keys(obj2).length &&
Object.keys(obj1).every(key => obj1[key] == obj2[key])
)
}
// sources:
// shallow comparison:
// https://stackoverflow.com/questions/22266826/how-can-i-do-a-shallow-comparison-of-the-properties-of-two-objects-with-javascri
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment