Skip to main content
Module

x/proc/mod2.ts>PushIterable

A high-level way to run child processes that is easy, flexible, powerful, and prevents resource leaks.
Go to Latest
class PushIterable
implements [Deno.Closer]
import { PushIterable } from "https://deno.land/x/proc@0.20.6/mod2.ts";

Invert the normal data flow of an AsyncIterable, allowing you to push writes on one side and iterate on the other.

The write() side must call close() when all write operations are done.

Constructors

new
PushIterable(options?: { onclose?: () => void | Promise<void>; })

Create a new PushIterable.

Properties

private
closed: boolean
private
queue: QueueEntry<Some<T> | None>[]

Methods

private
addEmptyPromiseToQueue(): void

Add an unresolved promise to the end of the queue.

close(): Promise<void>

Close the iterable.

Once closed, subsequent calls to write(...) will throw an error.

It is safe to call close() multiple times.

write(item: T): Promise<void>

Write an item.

[Symbol.asyncIterator](): AsyncIterableIterator<T>