asyncerator
Version:
Provide supporting types for AsyncIterable/AsyncIterableIterators, promisified stream.pipeline implementation, and Array-like utility operators, sources and sinks.
15 lines (14 loc) • 587 B
TypeScript
export interface Asyncerator<T> {
[Symbol.asyncIterator](): AsyncIterableIterator<T>;
}
/**
* Asyncables are anything that can be turned into an Asyncerator: normal iterators and iterables, AsyncIterators,
* AsyncIterables, AsyncGenerators, AsyncIterableIterators, and of course Asyncerators themselves.
*/
export type Asyncable<T> = Iterator<T> | Iterable<T> | AsyncIterator<T> | AsyncIterable<T> | Asyncerator<T>;
/**
* Create an Asyncerator from an Asyncable.
*
* @param source
*/
export default function <T>(source: Asyncable<T> | (() => Asyncerator<T>)): Asyncerator<T>;