1 | export declare class IteratorWithOperators<T> implements IterableIterator<T> {
|
2 | private source;
|
3 | |
4 |
|
5 |
|
6 | constructor(source: Iterator<T>);
|
7 | /**
|
8 | * Returns a `{ value, done }` object that adheres to the Iterator protocol
|
9 | */
|
10 | next(): IteratorResult<T>;
|
11 | /**
|
12 | * The presence of this method makes the Iterator itself Iterable.
|
13 | * This makes it possible to pass it to `for of` and Iterable-accepting functions like `Array.from()`
|
14 | */
|
15 | [Symbol.iterator](): this;
|
16 | /**
|
17 | * Returns a new Iterator by running each element thru iteratee
|
18 | */
|
19 | map<R>(iteratee: (value: T) => R): IteratorWithOperators<R>;
|
20 | /**
|
21 | * Returns a new Iterator of all elements predicate returns truthy for
|
22 | */
|
23 | filter(predicate: (element: T) => boolean): IteratorWithOperators<T>;
|
24 | filter<R extends T>(predicate: (element: T) => element is R): IteratorWithOperators<R>;
|
25 | /**
|
26 | * Returns a new Iterator concatenating the Iterator with an additional Iterator or Iterable
|
27 | */
|
28 | concat<C>(collection: Iterable<C> | Iterator<C>): IteratorWithOperators<T | C>;
|
29 | /**
|
30 | * Returns a new Iterator that emits slice of the source with n elements taken from the beginning
|
31 | *
|
32 | * @param limit The number of elements to take.
|
33 | */
|
34 | take(limit: number): IteratorWithOperators<T>;
|
35 | /**
|
36 | * Returns a new Iterator that emits slice of the source with n elements dropped from the beginning
|
37 | *
|
38 | * @param n The number of elements to drop.
|
39 | */
|
40 | drop(n: number): IteratorWithOperators<T>;
|
41 | /**
|
42 | * Returns a new Iterator that emits a slice of the source
|
43 | *
|
44 | * @param {number} start Zero-based positive start index, inclusive
|
45 | * @param {number} end Zero-based positive end index, exclusive, defaults to end of iterator
|
46 | */
|
47 | slice(start: number, end?: number): IteratorWithOperators<T>;
|
48 | /**
|
49 | * Returns a new Iterator that flattens items emitted by the Iterator a single level deep
|
50 | */
|
51 | flatten(): IteratorWithOperators<T extends Iterable<infer V> ? V : T>;
|
52 | /**
|
53 | * Reduces the Iterator to a value which is the accumulated result of running each emitted element thru iteratee,
|
54 | * where each successive invocation is supplied the return value of the previous.
|
55 | * The first element of collection is used as the initial value.
|
56 | */
|
57 | reduce(iteratee: (acc: T, val: T) => T): T;
|
58 | /**
|
59 | * Reduces the Iterator to a value which is the accumulated result of running each emitted element thru iteratee,
|
60 | * where each successive invocation is supplied the return value of the previous.
|
61 | *
|
62 | * @param initialValue The initial value for `acc`
|
63 | */
|
64 | reduce<A>(iteratee: (acc: A, val: T) => A, initialValue: A): A;
|
65 | /**
|
66 | * Finds the first item which satisfies the condition provided as the argument.
|
67 | * The condition is a typeguard and the result has the correct type.
|
68 | * If no argument satisfies the condition, returns undefined.
|
69 | *
|
70 | * @param predicate The predicate with a typeguard signature to search by
|
71 | */
|
72 | find<V extends T>(predicate: (value: T) => value is V): V | undefined;
|
73 | /**
|
74 | * Finds the first item which satisfies the condition provided as the argument.
|
75 | * If no item saisfies the condition, returns undefined.
|
76 | *
|
77 | * @param predicate The predicate to search by
|
78 | */
|
79 | find(predicate: (value: T) => boolean): T | undefined;
|
80 | /**
|
81 | * Iterates and checks if `value` is emitted by the Iterator
|
82 | *
|
83 | * @param value The value to search
|
84 | */
|
85 | includes(value: T): boolean;
|
86 | /**
|
87 | * Iterates and checks if `predicate` returns truthy for any element emitted by the Iterator
|
88 | */
|
89 | some(predicate: (value: T) => boolean): boolean;
|
90 | /**
|
91 | * Iterates and checks if `predicate` returns truthy for all elements emitted by the Iterator
|
92 | */
|
93 | every(predicate: (value: T) => boolean): boolean;
|
94 | /**
|
95 | * Iterates and invokes `iteratee` for every element emitted by the Iterator
|
96 | */
|
97 | forEach(iteratee: (value: T) => any): void;
|
98 | /**
|
99 | * Iterates and joins all elements emitted by the Iterator together as a string separated by an optional separator
|
100 | */
|
101 | join(separator?: string): string;
|
102 | /**
|
103 | * Iterates and returns all items emitted by the Iterator as an array.
|
104 | * Equivalent to passing the Iterator to `Array.from()`
|
105 | */
|
106 | toArray(): T[];
|
107 | /**
|
108 | * Iterates and returns all items emitted by the Iterator as an ES6 Set.
|
109 | * Equivalent to passing the Iterator to `new Set()`
|
110 | */
|
111 | toSet(): Set<T>;
|
112 | /**
|
113 | * Iterates and returns all `[key, value]` paris emitted by the Iterator as an ES6 Map.
|
114 | * Equivalent to passing the Iterator to `new Map()`
|
115 | */
|
116 | toMap<K, V>(this: IteratorWithOperators<[K, V]>): Map<K, V>;
|
117 | }
|
118 | /**
|
119 | * Creates an Iterator with advanced chainable operator methods for any Iterable or Iterator
|
120 | */
|
121 | export declare function iterate<T>(collection: Iterator<T> | Iterable<T>): IteratorWithOperators<T>;
|
122 | /**
|
123 | * Creates an Iterator that emits pairs of values from the two passed Iterators
|
124 | */
|
125 | export declare function zip<A, B>(a: Iterator<A> | Iterable<A>, b: Iterator<B> | Iterable<B>): IteratorWithOperators<[A, B]>;
|
126 | export default iterate;
|
127 | //# sourceMappingURL=iterate.d.ts.map |
\ | No newline at end of file |