Interface ArrayIterator<T>
"[toStringTag]": string;
"[dispose]"(): void;
"[iterator]"(): ArrayIterator<T>;
drop(count: number): IteratorObject<T, undefined, unknown>;
every(predicate: (value: T, index: number) => unknown): boolean;
filter<S>(
predicate: (value: T, index: number) => value is S,
): IteratorObject<S, undefined, unknown>;
filter(
predicate: (value: T, index: number) => unknown,
): IteratorObject<T, undefined, unknown>;
find<S>(predicate: (value: T, index: number) => value is S): S | undefined;
find(predicate: (value: T, index: number) => unknown): T | undefined;
flatMap<U>(
callback: (
value: T,
index: number,
) => Iterator<U, unknown, undefined> | Iterable<U, unknown, undefined>,
): IteratorObject<U, undefined, unknown>;
forEach(callbackfn: (value: T, index: number) => void): void;
map<U>(
callbackfn: (value: T, index: number) => U,
): IteratorObject<U, undefined, unknown>;
next(...__namedParameters: [] | [unknown]): IteratorResult<T, undefined>;
reduce(
callbackfn: (
previousValue: T,
currentValue: T,
currentIndex: number,
) => T,
): T;
reduce(
callbackfn: (
previousValue: T,
currentValue: T,
currentIndex: number,
) => T,
initialValue: T,
): T;
reduce<U>(
callbackfn: (
previousValue: U,
currentValue: T,
currentIndex: number,
) => U,
initialValue: U,
): U;
return?(value?: undefined): IteratorResult<T, undefined>;
some(predicate: (value: T, index: number) => unknown): boolean;
take(limit: number): IteratorObject<T, undefined, unknown>;
throw?(e?: any): IteratorResult<T, undefined>;
toArray(): T[];
}
Type Parameters
- T
Hierarchy
- IteratorObject<T, BuiltinIteratorReturn, unknown>
- ArrayIterator
Methods
[dispose]
Returns void
[iterator]
Returns ArrayIterator<T>
drop
Parameters
- count: number
The number of values to drop.
Returns IteratorObject<T, undefined, unknown>
- count: number
every
Determines whether all the members of this iterator satisfy the specified test.
Parameters
- predicate: (value: T, index: number) => unknown
A function that accepts up to two arguments. The every method calls the predicate function for each element in this iterator until the predicate returns false, or until the end of this iterator.
Returns boolean
- predicate: (value: T, index: number) => unknown
filter
- filter<S>(
predicate: (value: T, index: number) => value is S,
): IteratorObject<S, undefined, unknown>Creates an iterator whose values are those from this iterator for which the provided predicate returns true.
Type Parameters
- S
Parameters
Returns IteratorObject<S, undefined, unknown>
Creates an iterator whose values are those from this iterator for which the provided predicate returns true.
Parameters
- predicate: (value: T, index: number) => unknown
A function that accepts up to two arguments to be used to test values from the underlying iterator.
Returns IteratorObject<T, undefined, unknown>
- predicate: (value: T, index: number) => unknown
find
Returns the value of the first element in this iterator where predicate is true, and undefined otherwise.
Type Parameters
- S
Parameters
Returns S | undefined
flatMap
- flatMap<U>(
callback: (
value: T,
index: number,
) => Iterator<U, unknown, undefined> | Iterable<U, unknown, undefined>,
): IteratorObject<U, undefined, unknown>Creates an iterator whose values are the result of applying the callback to the values from this iterator and then flattening the resulting iterators or iterables.
Type Parameters
- U
Parameters
Returns IteratorObject<U, undefined, unknown>
forEach
Performs the specified action for each element in the iterator.
Parameters
- callbackfn: (value: T, index: number) => void
A function that accepts up to two arguments. forEach calls the callbackfn function one time for each element in the iterator.
Returns void
- callbackfn: (value: T, index: number) => void
map
Creates an iterator whose values are the result of applying the callback to the values from this iterator.
Type Parameters
- U
Parameters
Returns IteratorObject<U, undefined, unknown>
next
Parameters
- ...__namedParameters: [] | [unknown]
Returns IteratorResult<T, undefined>
reduce
Calls the specified callback function for all the elements in this iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
Parameters
Returns T
- reduce<U>(
callbackfn: (
previousValue: U,
currentValue: T,
currentIndex: number,
) => U,
initialValue: U,
): UCalls the specified callback function for all the elements in this iterator. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
Type Parameters
- U
Parameters
- callbackfn: (previousValue: U, currentValue: T, currentIndex: number) => U
A function that accepts up to three arguments. The reduce method calls the callbackfn function one time for each element in the iterator.
- initialValue: U
If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of a value from the iterator.
Returns U
Optionalreturn
Parameters
Optionalvalue: undefined
Returns IteratorResult<T, undefined>
some
Determines whether the specified callback function returns true for any element of this iterator.
Parameters
- predicate: (value: T, index: number) => unknown
A function that accepts up to two arguments. The some method calls the predicate function for each element in this iterator until the predicate returns a value true, or until the end of the iterator.
Returns boolean
- predicate: (value: T, index: number) => unknown
take
Creates an iterator whose values are the values from this iterator, stopping once the provided limit is reached.
Parameters
- limit: number
The maximum number of values to yield.
Returns IteratorObject<T, undefined, unknown>
- limit: number
Optionalthrow
Parameters
Optionale: any
Returns IteratorResult<T, undefined>
toArray
Creates a new array from the values yielded by this iterator.
Returns T[]
Creates an iterator whose values are the values from this iterator after skipping the provided count.