@naturalcycles/js-lib
Version:
Standard library for universal (browser + Node.js) javascript
33 lines (32 loc) • 1.57 kB
TypeScript
import type { AbortableAsyncMapper, AbortableAsyncPredicate, AbortableMapper, AbortablePredicate, Promisable } from '../types.js';
import { END } from '../types.js';
/**
* Similar to Iterable2, but for AsyncIterable.
*
* AsyncIterable2 is a wrapper around AsyncIterable that implements "Iterator Helpers proposal":
* https://github.com/tc39/proposal-iterator-helpers
*
* AsyncIterable2 can be removed after the proposal is widely implemented in Node & browsers.
*
* @experimental
*/
export declare class AsyncIterable2<T> implements AsyncIterable<T> {
private it;
private constructor();
static of<T>(it: AsyncIterable<T>): AsyncIterable2<T>;
static ofIterable<T>(it: Iterable<T>): AsyncIterable2<T>;
static empty<T>(): AsyncIterable2<T>;
[Symbol.asyncIterator](): AsyncIterator<T>;
toArray(): Promise<T[]>;
forEach(cb: (v: T, i: number) => Promisable<any | typeof END>): Promise<void>;
some(cb: AbortableAsyncPredicate<T>): Promise<boolean>;
someSync(cb: AbortablePredicate<T>): Promise<boolean>;
every(cb: AbortableAsyncPredicate<T>): Promise<boolean>;
everySync(cb: AbortablePredicate<T>): Promise<boolean>;
find(cb: AbortableAsyncPredicate<T>): Promise<T | undefined>;
findSync(cb: AbortablePredicate<T>): Promise<T | undefined>;
filter(cb: AbortableAsyncPredicate<T>): AsyncIterable2<T>;
filterSync(cb: AbortablePredicate<T>): AsyncIterable2<T>;
map<OUT>(mapper: AbortableAsyncMapper<T, OUT>): AsyncIterable2<OUT>;
mapSync<OUT>(mapper: AbortableMapper<T, OUT>): AsyncIterable2<OUT>;
}