shelving
Version:
Toolkit for using data in JavaScript.
19 lines (18 loc) • 1.27 kB
TypeScript
import type { AsyncValueCallback, ValueCallback } from "./callback.js";
import type { ErrorCallback } from "./callback.js";
import { STOP } from "./constants.js";
import type { Stop } 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): Stop;