UNPKG

iteragain

Version:

Javascript Iterable/Iterator/Generator-function utilities.

25 lines 906 B
/* asyncify(AsyncMapIterator) */ /* ra(MapIterator, AsyncMapIterator) */ /* ra(IterableIterator, AsyncIterableIterator) */ /* ra(Symbol.iterator, Symbol.asyncIterator) */ /* ra('IteratorResult<R>', 'Promise<IteratorResult<R>>') */ /* ra(Iteratee, AsyncIteratee) */ /* ra(' Iterator', ' AsyncIterator') */ /** An iterator that takes an input Iterator<T> and maps it's values to the type `R`. */ export class MapIterator { constructor(iterator, iteratee) { this.iterator = iterator; this.iteratee = iteratee; } [Symbol.iterator]() { return this; } /*i(async)*/ next(...args) { const { value, done } = /*i(await)*/ this.iterator.next(...args); if (done) return { done: true, value: undefined }; return { value: /*i(await)*/ this.iteratee(value), done }; } } export default MapIterator; //# sourceMappingURL=MapIterator.js.map