Async Iterators for Big Data Sets

August 2, 2018 comments 106 Reads

Iterators are great for looping through data sets. If you have an array then it has a built-in iterator. Objects can have a custom iterator built for them.
What if your dataset is too big to fit inside your Array? What if it takes up too much memory? With an Asynchronous Iterator you can load the data in chunks.
The for…of loop will have an await capability soon. However, we can already mimic the behaviour by creating an asynchronous function and calling it recursively.
Code GIST:
IIFE video: