Skip to content

Instantly share code, notes, and snippets.

@elzup
Created October 7, 2018 10: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 elzup/5fd97dc8115decc4021dee35b517458f to your computer and use it in GitHub Desktop.
Save elzup/5fd97dc8115decc4021dee35b517458f to your computer and use it in GitHub Desktop.
lodash key map
// @flow
import _ from 'lodash'
test('works', () => {
const a = [{ id: 'foo', v: 100 }, { id: 'bar', v: 200 }]
expect(_.mapKeys(a, 'id')).toMatchInlineSnapshot(`
Object {
"bar": Object {
"id": "bar",
"v": 200,
},
"foo": Object {
"id": "foo",
"v": 100,
},
}
`)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment