Skip to content

Instantly share code, notes, and snippets.

@DarrenN
Created September 14, 2018 16:40
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 DarrenN/8211c2a281a2bcfda8e98cc029c7f222 to your computer and use it in GitHub Desktop.
Save DarrenN/8211c2a281a2bcfda8e98cc029c7f222 to your computer and use it in GitHub Desktop.
Pull a field from an object and set the object to the value of that field in a new object
// needs ramda.js
const enclose = curry((a, obj) => objOf(prop(a, obj))(obj))
var example = {'id': '123', 'foo': 'bar'};
enclose('id', example)
// {"123": {"foo": "bar", "id": "123"}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment