Asynchronously iterable (synchronous) iterator
Utility to create a regular (synchronous) iterator that provides promises as values, allowing for asynchronous iteration without requiring the ECMAScript async iteration standard.
The ECMAScript spec will not allow iterations to fail without terminating the iterator, while this iterator enables asynchronous iteration with failure as an acceptable and catchable possible scenario for every single iteration.
It can be used to make a stream of fallible events asynchronously iterable, for instance when running a compiler in watch mode:
const createIterator = ; { const iterator = ; ; for const value of iterator console; let result; try result = await value; catch err console; continue; console; } ;
Support
Has been developed and tested against Node 8, but it is very likely to also work fine on older versions.