iteragain
Advanced tools
Comparing version 0.6.0 to 0.6.1
@@ -5,7 +5,2 @@ import { IteratorOrIterable, FlattenDeep, FlattenDepth1, FlattenDepth2, FlattenDepth3, FlattenDepth4, FlattenDepth5 } from './types'; | ||
constructor(iterator: Iterator<T>); | ||
constructor(iterator: { | ||
[key: PropertyKey]: any; | ||
iterator?: Iterator<any>; | ||
next?: () => IteratorResult<any>; | ||
}); | ||
/** Returns a `{ value, done }` object that adheres to the Iterator interface. */ | ||
@@ -12,0 +7,0 @@ next(): IteratorResult<T, any>; |
@@ -5,3 +5,2 @@ "use strict"; | ||
const concat_1 = require("./concat"); | ||
const EmptyIterator_1 = require("./internal/EmptyIterator"); | ||
const flatten_1 = require("./flatten"); | ||
@@ -13,2 +12,3 @@ const zip_1 = require("./zip"); | ||
const SliceIterator_1 = require("./internal/SliceIterator"); | ||
const PairwiseIterator_1 = require("./internal/PairwiseIterator"); | ||
class ExtendedIterator { | ||
@@ -102,16 +102,3 @@ constructor(iterator) { | ||
pairwise() { | ||
let prev = this.iterator.next(); | ||
if (prev.done) | ||
return new ExtendedIterator(new EmptyIterator_1.default()); | ||
return new ExtendedIterator({ | ||
iterator: this.iterator, | ||
next() { | ||
const next = this.iterator.next(); | ||
if (next.done) | ||
return { done: true, value: undefined }; | ||
const value = [prev.value, next.value]; | ||
prev = next; | ||
return { done: false, value }; | ||
}, | ||
}); | ||
return new ExtendedIterator(new PairwiseIterator_1.default(this.iterator)); | ||
} | ||
@@ -118,0 +105,0 @@ /** |
@@ -5,5 +5,5 @@ /** | ||
*/ | ||
export declare class FilterIterator<T> { | ||
private readonly iterator; | ||
private readonly predicate; | ||
export declare class FilterIterator<T> implements Iterator<T> { | ||
protected readonly iterator: Iterator<T>; | ||
protected readonly predicate: (value: T) => any; | ||
constructor(iterator: Iterator<T>, predicate: (value: T) => any); | ||
@@ -10,0 +10,0 @@ next(): IteratorResult<any>; |
/** An iterator that takes an input Iterator<T> and maps it's values to the type `R`. */ | ||
export declare class MapIterator<T, R> implements Iterator<R> { | ||
private readonly iterator; | ||
private readonly iteratee; | ||
protected readonly iterator: Iterator<T>; | ||
protected readonly iteratee: (value: T) => R; | ||
constructor(iterator: Iterator<T>, iteratee: (value: T) => R); | ||
@@ -6,0 +6,0 @@ next(): IteratorResult<R>; |
/** Yields numbers inside a range. When `next.done` is true, resets the internal counter back to `start`. */ | ||
export declare class RangeIterator implements Iterator<number> { | ||
private readonly start; | ||
private readonly stop; | ||
private readonly step; | ||
private readonly stepSign; | ||
private i; | ||
protected readonly start: number; | ||
protected readonly stop: number; | ||
protected readonly step: number; | ||
protected readonly stepSign: number; | ||
protected i: number; | ||
constructor(start: number, stop: number, step: number, stepSign: number); | ||
@@ -9,0 +9,0 @@ next(): IteratorResult<number>; |
/** An iterator that only yields values beginning from `start` (inclusive) and ending at `end` (exclusive). */ | ||
export declare class SliceIterator<T> implements Iterator<T> { | ||
private iterator; | ||
private start; | ||
private end; | ||
private i; | ||
protected iterator: Iterator<T>; | ||
protected start: number; | ||
protected end: number; | ||
protected i: number; | ||
constructor(iterator: Iterator<T>, start: number, end: number); | ||
@@ -8,0 +8,0 @@ next(): IteratorReturnResult<any> | IteratorYieldResult<T> | { |
{ | ||
"name": "iteragain", | ||
"version": "0.6.0", | ||
"version": "0.6.1", | ||
"description": "Javascript ES6 Iterable/Iterator utilities.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
38350
42
755