/** * Anything with a push and a done method, to support pushable async iterators. */ type TPushable = { push: (T: any) => void; done: () => void; }; type TTransIterator = (iterator: Iterator, ...params: any) => Iterator; type TTransIteratorAsync = (iterator: AsyncIterator, ...params: any) => AsyncIterator; /** * A transIterator is a function that takes a (Sync or Async) Iterator as input and outputs * a (Pipeable, Sync or Async, Iterable) Iterator */ type TTransIteratorSyncOrAsync = (iterator: Iterator | AsyncIterator) => IterableIterator | AsyncIterableIterator; /** * The type that the the nextFn of the powerMap operator should output */ type TNextFnResult = { done: true; } | { done: false; state?: TState; } | ({ done: false; state?: TState; /** indicates that nothing else should be pulled from the incoming iterator, we're done AFTER this value or iterator */ isLast?: boolean; } & ({ /** returns a single value given the current input iterator value and the state */ value: TOut; } | { /** returns multiple values given the current input iterator value and the state */ iterable: Iterable | AsyncIterable; })); /** * Used by the thenable method, that turns any synchronous value into something with a * 'then' method, so we can reuse the same code regardless whether the input is synchronous * or asynchronous. * * It exposes 2 properties: then(), which works as you know from promises, and src, which is * the actual input (which is either a simple value or a promise). * * @category util */ type TThenable = { src: T | Promise; then: (okHandler: (value: any, isSync?: boolean) => any) => any; value?: T; }; export { TTransIterator, TTransIteratorAsync, TTransIteratorSyncOrAsync, TPushable, TNextFnResult, TThenable, };