8 lines
208 B
TypeScript
8 lines
208 B
TypeScript
export function flatMap<T, R>(value: T[], transform: (it: T) => Iterable<R>): R[] {
|
|
const result: R[] = [];
|
|
for (const it of value) {
|
|
result.push(...transform(it));
|
|
}
|
|
return result;
|
|
}
|