npm.io
1.0.6 • Published 8 years ago

while-fetch-execute

Licence
MIT
Version
1.0.6
Deps
1
Vulns
0
Weekly
0

while-fetch-execute

While you can fetch, execute

Fetch jobs, and while you have any jobs, execute them, N in parallel. Only fetches a job when a worker is idle.

Micro-example:

async function jobFetch() {
  if (!doneForSomeReason) {
    return null;
  }
  return nextJob();
}

async function jobExecute(job) {
  //...
  await doYourOwnMagic(job);
  //...
}

async function main() {
  await whileFetchExecute(8, jobFetch, jobExecute);
}

main();