1.0.0 • Published 1 year ago

async_iterator_helper v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

Async iterator

This is a javascript plugin for async iterating, that means when

you want to send requests one by one when iternating an array, then

function 'asyncIterator' can be the solution:

asyncIterator(
 fn,     /*The async callback you want to invoke, it should be 
 a Promise object*/
 curIdx, /*Current index of the array*/
 len,     /*The length of the array*/
 err      /*The callback will be invoked when request failed*/
 ) 

Example

asyncIterator(
  new Promise((resolve, reject) => {
    resolve('success fetch');
  }),
  0,
  4,
  null
);