Skip to content

Instantly share code, notes, and snippets.

@raine

raine/mapKeys.js Secret

Last active August 29, 2015 14:23
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 raine/803f4b88c5087b737843 to your computer and use it in GitHub Desktop.
Save raine/803f4b88c5087b737843 to your computer and use it in GitHub Desktop.
var R = require('ramda');
var obj = {
fragments: {
'foo.a': 1,
'foo.b': 2,
'foo.c': 3
},
typ: 'foo'
}
var mapObjKeys = R.curry(function(fn, obj) {
return R.fromPairs(R.map(R.adjust(fn, 0), R.toPairs(obj)));
});
require('treis')(mapObjKeys)(R.replace(obj.typ + '.', ''), obj.fragments)
// λ1 a0: [Function: f1]
// a1: { 'foo.a': 1, 'foo.b': 2, 'foo.c': 3 }
// λ1 => { a: 1, b: 2, c: 3 }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment