UNPKG

node-apparatus

Version:

A mix of common components needed for awesome node experience

16 lines (15 loc) 1.02 kB
/** * Merges multiple sorted iterators into a single sorted iterator using a custom frame processing function. * * @template T - The type of elements in the iterators. * @param {AsyncIterableIterator<T>[]} iterators - An array of sorted iterators to be merged. * @param {(elements: (T | null)[]) => { yieldIndex: number | null, purgeIndexes: number[] }} frameProcessFunction - * A function that processes the current frame of elements from each iterator and determines which element to yield next * and which iterators to purge. * @returns {AsyncIterableIterator<T>} - An iterator that yields elements in sorted order from the merged iterators. * @throws {Error} - Throws an error if the frame processing function is indecisive, which could lead to an infinite loop. */ export declare function kWayMergeAsync<T>(iterators: AsyncIterableIterator<T>[], frameProcessFunction: (elements: (T | null)[]) => { yieldIndex: number | null; purgeIndexes: number[]; }): AsyncIterableIterator<T>;