mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
8 lines
No EOL
223 B
TypeScript
8 lines
No EOL
223 B
TypeScript
import {Index} from "gems/indexType";
|
|
|
|
export function createIndex<T>(arr: T[], indexProp: (item) => string): Index<T> {
|
|
return arr.reduce((index, item) => {
|
|
index[indexProp(item)] = item;
|
|
return index;
|
|
}, {})
|
|
} |