UNPKG

shelving

Version:

Toolkit for using data in JavaScript.

20 lines (19 loc) 1.41 kB
import type { AsyncValueCallback, ErrorCallback, ValueCallback } from "./callback.js"; import { STOP } from "./constants.js"; import type { StopCallback } from "./start.js"; /** * Is a value an async iterable object? * - Any object with a `Symbol.iterator` property is iterable. * - Note: Array and Map instances etc will return true because they implement `Symbol.iterator` */ export declare function isSequence(value: unknown): value is AsyncIterable<unknown>; /** Infinite sequence that yields until a `SIGNAL` is received. */ export declare function repeatUntil<T>(source: AsyncIterable<T>, ...signals: [Promise<typeof STOP>, ...Promise<typeof STOP>[]]): AsyncIterable<T>; /** Infinite sequence that yields every X milliseconds (yields a count of the number of iterations). */ export declare function repeatDelay(ms: number): AsyncIterable<number>; /** Dispatch items in a sequence to a (possibly async) callback. */ export declare function callSequence<T>(sequence: AsyncIterable<T>, callback: AsyncValueCallback<T>): AsyncIterable<T>; /** Pull values from a sequence until the returned function is called. */ export declare function runSequence<T>(sequence: AsyncIterable<T>, onNext?: ValueCallback<T>, onError?: ErrorCallback): StopCallback; /** Merge several sequences (calls the sequences in series). */ export declare function mergeSequences<T>(...sequences: AsyncIterable<T>[]): AsyncIterable<T>;