iteragain
Advanced tools
Comparing version 3.13.1 to 3.13.2
@@ -11,3 +11,3 @@ import { IteratorOrIterable, FlattenDeep, FlattenDepth1, FlattenDepth2, FlattenDepth3, FlattenDepth4, FlattenDepth5, Tuple, Predicate, Iteratee, Callback, StrictPredicate } from './types'; | ||
/** Returns a `{ value, done }` object that adheres to the Iterator interface. */ | ||
next(...args: any[]): IteratorResult<T>; | ||
next(...args: any[]): IteratorResult<T, T>; | ||
/** Implements this as an Iterable so it's allowed to be used with "for of" loops. */ | ||
@@ -14,0 +14,0 @@ [Symbol.iterator](): this; |
/** | ||
* Creates an 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`. | ||
* 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. | ||
*/ | ||
@@ -10,4 +11,5 @@ export declare class FunctionIterator<TFunc extends (...args: any[]) => any> { | ||
[Symbol.iterator](): this; | ||
next(...args: Parameters<TFunc>): IteratorResult<ReturnType<TFunc>>; | ||
/** Works like any generator function `next` method */ | ||
next(...args: Parameters<TFunc>): IteratorResult<ReturnType<TFunc>, ReturnType<TFunc>>; | ||
} | ||
export default FunctionIterator; |
@@ -5,4 +5,5 @@ "use strict"; | ||
/** | ||
* Creates an 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`. | ||
* 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. | ||
*/ | ||
@@ -17,6 +18,7 @@ class FunctionIterator { | ||
} | ||
/** Works like any generator function `next` method */ | ||
next(...args) { | ||
const result = this.func(...args); | ||
return result === this.sentinel | ||
? (this.func = (() => this.sentinel), { done: true, value: undefined }) | ||
? ((this.func = (() => this.sentinel)), { done: true, value: undefined }) | ||
: { done: false, value: result }; | ||
@@ -23,0 +25,0 @@ } |
{ | ||
"name": "iteragain", | ||
"version": "3.13.1", | ||
"version": "3.13.2", | ||
"description": "Javascript Iterable/Iterator/Generator-function utilities.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
174824
3898