···22export type { Arg } from './mo.ts';
33export { Task } from './task.ts';
44export { StreamTask } from './stream-task.ts';
55+export { stream } from './stream.ts';
66+export type { StreamOptions } from './stream.ts';
57export { workers } from './worker-pool.ts';
68export { transfer } from './transfer.ts';
79export type { Runner } from './runner.ts';
+24
src/stream.ts
···11+const STREAM = Symbol.for('moroutine.stream');
22+33+export interface StreamOptions {
44+ highWaterMark?: number;
55+}
66+77+export interface StreamMarker<T> {
88+ readonly [STREAM]: {
99+ iterable: AsyncIterable<T>;
1010+ options?: StreamOptions;
1111+ };
1212+}
1313+1414+/**
1515+ * Wraps an AsyncIterable for streaming to a worker.
1616+ * @param iterable - The async iterable to pipe to the worker.
1717+ * @param opts - Optional. highWaterMark controls backpressure buffering (default: 16).
1818+ * @returns The iterable, typed as AsyncIterable<T> for transparent moroutine arg use.
1919+ */
2020+export function stream<T>(iterable: AsyncIterable<T>, opts?: StreamOptions): AsyncIterable<T> {
2121+ return { [STREAM]: { iterable, options: opts } } as unknown as AsyncIterable<T>;
2222+}
2323+2424+export { STREAM };