Repository URL to install this package:
|
Version:
1.2.0 ▾
|
// https://basarat.gitbooks.io/typescript/docs/iterators.html
export interface IteratorResult<T> {
done: boolean
value: T
}
export interface Iterator<T, S> {
next(value?: any): IteratorResult<T>
return?(value?: any): IteratorResult<T>
throw?(e?: any): IteratorResult<T>
[Symbol.toStringTag]: S
}
// export type IteratorProto = typeof Iterator.prototype
export type MapIterator = Iterator<any, 'Map Iterator'>
export type SetIterator = Iterator<any, 'Set Iterator'>
export type StringIterator = Iterator<any, 'String Iterator'>
export type ArrayIterator = Iterator<any, 'Array Iterator'>
export type Generator = Iterator<any, 'GeneratorFunction'>
export type BuiltInIterators =
| MapIterator
| SetIterator
| StringIterator
| ArrayIterator
| AsyncIterator<any>
| Iterator<any, any>
export function isIterator(x: any): x is BuiltInIterators
export function fromArrayToIterator(x: Array): Iterator<x>