Last active
August 29, 2015 14:17
-
-
Save gr0uch/773c3f648f0f3bf9da87 to your computer and use it in GitHub Desktop.
Immutable mapping on an object.
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
/** | |
* 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