// Auto-generated by scripts/gen_parity_tests.py from docs/runtime-parity.md.
// Module: node:stream/promises
// This file is a byte-for-byte parity test against `node --experimental-strip-types`.

import * as streamP from "node:stream/promises";
import { Readable, Writable } from "node:stream";

try {
  console.log("streamP.pipeline type:", typeof streamP.pipeline);
  console.log("streamP.finished type:", typeof streamP.finished);
} catch (e) {
  console.log("typeof ERROR:", (e as Error).message);
}

try {
  const collected: string[] = [];
  const src = Readable.from(["a", "b", "c"]);
  const dst = new Writable({
    write(chunk, _enc, cb) { collected.push(chunk.toString()); cb(); },
  });
  await streamP.pipeline(src, dst);
  console.log("pipeline collected:", collected.join(","));
} catch (e) {
  console.log("pipeline ERROR:", (e as Error).message);
}

try {
  const r = Readable.from(["x"]);
  r.resume();
  await streamP.finished(r);
  console.log("finished:", "ok");
} catch (e) {
  console.log("finished ERROR:", (e as Error).message);
}
