6 lines
173 B
TypeScript
6 lines
173 B
TypeScript
export function* associateBy<T, K>(value: Iterable<T>, transform: (it: T) => K): Iterable<[K, T]> {
|
|
for (const it of value) {
|
|
yield [transform(it), it];
|
|
}
|
|
}
|