@thi.ng/transducers-async
Version:
Async versions of various highly composable transducers, reducers and iterators
38 lines • 1.53 kB
TypeScript
import type { NumOrString } from "@thi.ng/api";
export type SyncSources<T extends Record<NumOrString, any>> = {
[id in keyof T]: AsyncIterable<T[id]>;
};
export interface SyncOpts {
/**
* If true, {@link sync} waits for new values from *all* remaining inputs
* before a new tuple is produced. If false, that synchronization only
* happens for the very first tuple and afterwards any changed input will
* trigger a tuple update.
*
* @defaultValue false
*/
reset: boolean;
/**
* Only used if {@link SyncOpts.reset} is disabled. If true (default: false)
* *no* input synchronization (waiting for values) is applied and
* {@link sync} will emit potentially partially populated tuple objects for
* each received input value. However, as with the default behavior, tuples
* will retain the most recent consumed value from other inputs.
*/
mergeOnly: boolean;
}
/**
* Async iterator version of [thi.ng/rstream's sync()
* construct](https://docs.thi.ng/umbrella/rstream/functions/sync.html).
*
* @remarks
* Also see {@link merge} for an alternative way of merging.
*
* @param src
* @param opts
*/
export declare function sync<T extends Record<NumOrString, any>>(src: SyncSources<T>, opts?: Partial<SyncOpts> & {
mergeOnly: true;
}): AsyncIterableIterator<Partial<T>>;
export declare function sync<T extends Record<NumOrString, any>>(src: SyncSources<T>, opts?: Partial<SyncOpts>): AsyncIterableIterator<T>;
//# sourceMappingURL=sync.d.ts.map