Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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