7 lines
219 B
TypeScript
7 lines
219 B
TypeScript
export function* flatMapIndexed<T, R>(value: Iterable<T>, transform: (index: number, it: T) => Iterable<R>): Iterable<R> {
|
|
let index = 0;
|
|
for (const it of value) {
|
|
yield* transform(index++, it);
|
|
}
|
|
}
|