UNPKG

@waku/utils

Version:
21 lines (20 loc) 1.09 kB
import type { IAsyncIterator, IDecodedMessage, IDecoder, IReceiver } from "@waku/interfaces"; /** * Options for configuring the behavior of an iterator. * * @property timeoutMs - Optional timeout in milliseconds. If specified, the iterator will terminate after this time period. * @property iteratorDelay - Optional delay in milliseconds between each iteration. Can be used to control the rate of iteration. */ export type IteratorOptions = { timeoutMs?: number; iteratorDelay?: number; }; /** * Function that transforms IReceiver subscription to iterable stream of data. * @param receiver - object that allows to be subscribed to; * @param decoder - parameter to be passed to receiver for subscription; * @param options - options for receiver for subscription; * @param iteratorOptions - optional configuration for iterator; * @returns iterator and stop function to terminate it. */ export declare function toAsyncIterator<T extends IDecodedMessage>(receiver: IReceiver, decoder: IDecoder<T> | IDecoder<T>[], iteratorOptions?: IteratorOptions): Promise<IAsyncIterator<T>>;