https://github.com/cloudacy/keyby
A typescript implementation of keyby method, inspired by lodash.keyby
https://github.com/cloudacy/keyby
Last synced: 4 months ago
JSON representation
A typescript implementation of keyby method, inspired by lodash.keyby
- Host: GitHub
- URL: https://github.com/cloudacy/keyby
- Owner: cloudacy
- License: mit
- Created: 2022-02-19T08:37:55.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-08-03T07:42:42.000Z (almost 4 years ago)
- Last Synced: 2023-12-27T15:03:24.743Z (over 2 years ago)
- Language: TypeScript
- Size: 34.2 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# keyby
A typescript implementation of keyby method, inspired by lodash.keyby
## Usage
```ts
const arr = [
{ id: 3, name: "Hello" },
{ id: 5, name: "World" },
{ id: 1, name: "keyby" },
];
const keyedArray = keyBy(array, "id");
console.log(keyedArray);
// => {3: {id: 3, name: "Hello"}, 5: {id: 5, name: "World"}, 1: {id: 1, name: "keyby"}}
```