iteragain
Version:
Javascript Iterable/Iterator/Generator-function utilities.
15 lines • 822 B
TypeScript
/**
* Creates a iterator from any function. `func` will be called once per `next()` call and will stop once the value of
* `sentinel` (default: undefined) is returned from `func`. Behaves similarly to a generator function, except without
* the use of `yield` statements.
*/
export declare class FunctionIterator<TFunc extends (...args: any[]) => any, TSentinel = undefined> {
protected func: TFunc;
protected sentinel?: TSentinel | undefined;
constructor(func: TFunc, sentinel?: TSentinel | undefined);
[Symbol.iterator](): this;
/** Works like any generator function `next` method */
next(...args: Parameters<TFunc>): IteratorResult<Exclude<ReturnType<TFunc>, TSentinel>, Exclude<ReturnType<TFunc>, TSentinel>>;
}
export default FunctionIterator;
//# sourceMappingURL=FunctionIterator.d.ts.map