export function mapDefined(arr: ReadonlyArray, f: (t: T) => U | undefined): ReadonlyArray { const out: U[] = []; for (const t of arr) { const u = f(t); if (u !== undefined) { out.push(u); } } return out; } export async function someAsync(arr: ReadonlyArray, f: (t: T) => Promise): Promise { for (const x of arr) { if (await f(x)) { return true; } } return false; }