Last active
June 29, 2017 12:42
-
-
Save zerobias/f5dcd4d976a42c9312a15f4f8d528e16 to your computer and use it in GitHub Desktop.
Rename object keys by template
This file contains hidden or 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
import { propOr, pipe, adjust, __, map, useWith, into, toPairs } from 'ramda' | |
const reducePairs = useWith(into({})) | |
const getNameField = | |
keyMap => key => propOr(key, key, keyMap) | |
const reducer = pipe( | |
getNameField, | |
adjust(__, 0), | |
map | |
) | |
const renameKeys = reducePairs([reducer, toPairs]) | |
export default renameKeys |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment