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.23/mod3.ts";

Enumerable wrapper for AsyncIterable.

Use the factory function enumerate to create new instances.

Constructors

new
Enumerable(iter: AsyncIterable<T>)

Construct a new enumerable wrapper.

Properties

readonly
first: Promise<T>

Take the head of the enumeration.

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

Methods

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>, options?: ConcurrentOptions): Enumerable<U>

Map the sequence from one type to another, concurrently.

Results are returned in order.

concurrentUnorderedMap<U>(mapFn: (item: T) => Promise<U>, options?: ConcurrentOptions): 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.

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

Filter the sequence to exclude the items that pass a test. This returns the inverse of filter.

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

Equivalent to calling map followed by flatten.

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): ProcessEnumerable<S>

Run a process.

run(...cmd: Cmd): ProcessEnumerable<unknown>

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>

Split into 2 or more identical iterators.

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.

writeTo(writer: Writable<T>): Promise<void>

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>

Implement AsyncIterable<T>.