Skip to main content
Module

x/proc/mod3.ts>Enumerable

A high-level way to run child processes that is easy, flexible, powerful, and prevents resource leaks.
Go to Latest
class Enumerable
implements AsyncIterable<T>
Re-export
import { Enumerable } from "https://deno.land/x/proc@0.20.14/mod3.ts";

Enumerable wrapper for AsyncIterable.

Use the factory function enumerate to create new instances to get better performance.

Constructors

new
Enumerable(iter: AsyncIterable<T>)

Properties

readonly
first: Promise<T>

Take the head of the enumeration.

This operation is equivalent to take(1) and consumes the enumeration.

Methods

protected
identity(): AsyncIterableIterator<T>
collect(): Promise<T[]>

Collect the items in this iterator to an array.

concat(other: AsyncIterable<T>): Enumerable<T>

Drop the first n items, return the rest.

concurrentMap<U>(mapFn: (item: T) => Promise<U>, concurrency?: number): Enumerable<U>

Map the sequence from one type to another, concurrently.

Results are returned in order.

concurrentUnorderedMap<U>(mapFn: (item: T) => Promise<U>, concurrency?: number): Enumerable<U>

Map the sequence from one type to another, concurrently.

Items are iterated out of order. This allows maximum concurrency at all times, but the output order cannot be assumed to be the same as the input order.

drop<N extends number = 1>(n?: N): Enumerable<T>

Drop the first n items, return the rest.

filter(filterFn: (item: T) => boolean | Promise<boolean>): Enumerable<T>

Filter the sequence to contain just the items that pass a test.

flatten(): Enumerable<ElementType<T>>

Flatten the iterable.

forEach(forEachFn: (item: T) => void | Promise<void>): Promise<void>

Perform an operation for each item in the sequence.

map<U>(mapFn: (item: T) => U | Promise<U>): Enumerable<U>

Map the iterator from one type to another.

reduce<U>(zero: U, reduceFn: (acc: U, item: T) => U | Promise<U>): Promise<U>

Reduce a sequence to a single value.

run<S>(options: ProcessOptions<S>, ...cmd: Cmd): Uint8Enumerable

Run a process.

Run a process.

take<N extends number = 1>(n?: N): Enumerable<T>

Take the first n items.

tee<N extends number = 2>(n?: N): Tuple<Enumerable<T>, N>
transform<U>(fn: (it: AsyncIterable<T>) => AsyncIterable<U>): Enumerable<U>

Transform the iterable from one type to another with an opportunity to catch and handle errors.

Write all data to the writer.

Note that this call returns immediately, although it continues to run until the source iterable data is exhausted.

[Symbol.asyncIterator](): AsyncGenerator<T, void, unknown>