@solid/community-server
Version:
Community Solid Server: an open and modular implementation of the Solid specifications
68 lines (67 loc) • 3.65 kB
TypeScript
/**
* Creates a new iterable with the results of calling a provided function on every element in the calling array.
* Similar to the {@link Array.prototype.map} function.
* See the documentation of the above function for more details.
*
* @param iterable - Iterable on which to call the map function.
* @param callbackFn - Function that is called for every element.
* @param thisArg - Value to use as `this` when executing `callbackFn`.
*/
export declare function map<TIn, TOut>(iterable: Iterable<TIn>, callbackFn: (element: TIn, index: number) => TOut, thisArg?: unknown): Iterable<TOut>;
/**
* Creates a new iterable with all elements that pass the test implemented by the provided function.
* Similar to the {@link Array.prototype.filter} function.
* See the documentation of the above function for more details.
*
* @param iterable - Iterable on which to call the map function.
* @param callbackFn - Function that is called to test every element.
* @param thisArg - Value to use as `this` when executing `callbackFn`.
*/
export declare function filter<T>(iterable: Iterable<T>, callbackFn: (element: T, index: number) => boolean, thisArg?: unknown): Iterable<T>;
/**
* Creates a new iterable that is a concatenation of all the iterables in the input.
*
* @param iterables - An iterable of which the contents will be concatenated into a new iterable.
*/
export declare function concat<T>(iterables: Iterable<Iterable<T>>): Iterable<T>;
/**
* Returns the first element in the provided iterable that satisfies the provided testing function.
* If no values satisfy the testing function, `undefined` is returned.
* Similar to the {@link Array.prototype.find} function.
* See the documentation of the above function for more details.
*
* @param iterable - Iterable on which to call the map function.
* @param callbackFn - Function that is called to test every element.
* @param thisArg - Value to use as `this` when executing `callbackFn`.
*/
export declare function find<T>(iterable: Iterable<T>, callbackFn: (element: T, index: number) => boolean, thisArg?: unknown): T | undefined;
/**
* Similar to the {@link Array.prototype.reduce} function, but for an iterable.
* See the documentation of the above function for more details.
* The first element will be used as the initial value.
*
* @param iterable - Iterable of which to reduce the elements.
* @param callbackFn - A reducer function.
*/
export declare function reduce<TIn>(iterable: Iterable<TIn>, callbackFn: (previousValue: TIn, currentValue: TIn, currentIndex: number) => TIn): TIn;
/**
* Similar to the {@link Array.prototype.reduce} function, but for an iterable.
* See the documentation of the above function for more details.
*
* @param iterable - Iterable of which to reduce the elements.
* @param callbackFn - A reducer function.
* @param initialValue - The value to start from.
*/
export declare function reduce<TIn, TOut>(iterable: Iterable<TIn>, callbackFn: (previousValue: TOut, currentValue: TIn, currentIndex: number) => TOut, initialValue: TOut): TOut;
/**
* Merges the results of several sorted iterators.
* In case the results of the individual iterators are not sorted the outcome results will also not be sorted.
*
* @param iterators - The iterators whose results need to be merged.
* @param comparator - The comparator to use to compare the results.
*/
export declare function sortedAsyncMerge<T>(iterators: AsyncIterator<T>[], comparator?: (left: T, right: T) => number): AsyncIterable<T>;
/**
* Converts an `AsyncIterator` to an array.
*/
export declare function asyncToArray<T>(iterable: AsyncIterable<T>): Promise<T[]>;