Created
June 13, 2017 19:10
-
-
Save Emilios1995/b566cdde792a345014387154000432d1 to your computer and use it in GitHub Desktop.
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
// updateKeys :: (String -> String) -> Object -> Object | |
const updateKeys = f => | |
R.compose(R.fromPairs, R.map(R.over(R.lensIndex(0), f)), R.toPairs); | |
// updateKeysWithMap :: Object -> Object -> Object | |
const updateKeysWithMap = map => updateKeys(k => map[k] || k); | |
// example: | |
updateKeysWithMap({ oldKey: "newKey" })({ oldKey: 2 }); // -> { newKey: 2 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment