// Generated by bynkc — do not edit by hand.
// commons streaming

import { Ok, Err, Some, None, type Result, type Option, type ValidationError } from "./runtime.js";

export function doubled(xs: readonly number[]): AsyncIterable<number> {
  return (async function* (__s) { for await (const __e of __s) { yield ((x) => x * 2)(__e); } })((async function* () { for (const __e of xs) { yield __e; } })());
}

export async function firstTwoDoubled(xs: readonly number[]): Promise<readonly number[]> {
  return (async (__s) => { const __r = []; for await (const __e of __s) { __r.push(__e); } return __r; })((async function* (__s) { const __n = 2; if (__n <= 0) { return; } let __i = 0; for await (const __e of __s) { yield __e; if (++__i >= __n) { return; } } })((async function* (__s) { for await (const __e of __s) { yield ((x) => x * 2)(__e); } })((async function* () { for (const __e of xs) { yield __e; } })())));
}

export function passthrough(rs: readonly Result<number, string>[]): AsyncIterable<Result<number, string>> {
  return (async function* () { for (const __e of rs) { yield __e; } })();
}

export async function run(): Promise<number> {
  const got = await firstTwoDoubled([1, 2, 3, 4]);
  return ((__xs: readonly number[], __d: number) => __xs.length > 0 ? __xs[0] : __d)(got, 0);
}

