Created
January 22, 2020 00:50
-
-
Save krfong916/c5b603c2c1645147654fc3e2c77eef9b to your computer and use it in GitHub Desktop.
A list of all the custom util functions I've created
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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