Skip to content

Instantly share code, notes, and snippets.

@gr0uch
Last active August 29, 2015 14:17
Show Gist options
  • Save gr0uch/773c3f648f0f3bf9da87 to your computer and use it in GitHub Desktop.
Save gr0uch/773c3f648f0f3bf9da87 to your computer and use it in GitHub Desktop.
Immutable mapping on an object.
/**
* Immutable mapping on an object.
*
* @param {Object} object
* @param {Function} mapFunction
* @return {Object}
*/
export default (object, mapFunction) =>
Object.keys(object).reduce((clone, key) => {
clone[key] = mapFunction(object[key], key);
return clone;
}, {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment