Last active
August 29, 2015 14:21
-
-
Save panuhorsmalahti/fc8a58b56133eb2aec3b to your computer and use it in GitHub Desktop.
updated() and removed()
This file contains 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
const updated = (source, property, value) => { | |
const out = {}; | |
Object.keys(source).forEach(key => { | |
out[key] = source[key]; | |
}); | |
out[property] = value; | |
return out; | |
}; | |
const removed = (source, property) => { | |
const out = {}; | |
Object.keys(source).filter(key => key !== property).forEach(key => { | |
out[key] = source[key]; | |
}); | |
return out; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment