Skip to content

Instantly share code, notes, and snippets.

@panuhorsmalahti
Last active August 29, 2015 14:21
Show Gist options
  • Save panuhorsmalahti/fc8a58b56133eb2aec3b to your computer and use it in GitHub Desktop.
Save panuhorsmalahti/fc8a58b56133eb2aec3b to your computer and use it in GitHub Desktop.
updated() and removed()
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