January 2019
Beginner
210 pages
4h 47m
English
We have already learned about the interface implemented by all iterators:
interface Iterator<T> { next(value?: any): IteratorResult<T>; return?(value?: any): IteratorResult<T>; throw?(e?: any): IteratorResult<T>;}
However, we haven't learned yet about the interface implemented by all asynchronous iterators:
interface AsyncIterator<T> { next(value?: any): Promise<IteratorResult<T>>; return?(value?: any): Promise<IteratorResult<T>>; throw?(e?: any): Promise<IteratorResult<T>>;}
An asynchronous iterator returns a promise every time we invoke the next method. The following code snippet demonstrates how asynchronous iterators can be very useful when used in conjunction with asynchronous functions:
let counter = 0;function ...
Read now
Unlock full access