export function* mapIterable(it: Iterable, cb: (v: T) => R) { for (const v of it) { yield cb(v); } } export function* filterIterable(it: Iterable, cb: (v: T) => boolean) { for (const v of it) { if (cb(v)) { yield v; } } } export function toList(it: Iterable) { const res: T[] = []; for (const v of it) { res.push(v); } return res; }