Created
September 14, 2018 16:40
-
-
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
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
// 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