Skip to content

Instantly share code, notes, and snippets.

@zerobias
Last active June 29, 2017 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zerobias/f5dcd4d976a42c9312a15f4f8d528e16 to your computer and use it in GitHub Desktop.
Save zerobias/f5dcd4d976a42c9312a15f4f8d528e16 to your computer and use it in GitHub Desktop.
Rename object keys by template
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