An asynchronous iterator that uses requestAnimationFrame to batch process large datasets without locking up the UI.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
example
AsyncIterator.js
AsyncIteratorInterval.js
README.md

README.md

AsyncIterator

An asynchronous iterator that uses requestAnimationFrame to batch process large datasets without locking up the UI.

// The dataset
var myArr = [];
// Number of operations per call
var batchSize = 1000;
// The actual processing method
function work(item, index) {
    // Do something for each item
}

// Start iterator, it will return a promise
var promise = asyncIterator(myArr, work, batchSize);

// When promise is resolved, output results
promise.done(
    function(results){
        console.log('Done processing', results);
    }
);