Created
October 7, 2018 10:40
-
-
Save elzup/5fd97dc8115decc4021dee35b517458f to your computer and use it in GitHub Desktop.
lodash key map
This file contains 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
// @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