while-fetch-execute

1.0.6 • Public • Published

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();

Readme

Keywords

none

Package Sidebar

Install

npm i while-fetch-execute

Weekly Downloads

1

Version

1.0.6

License

MIT

Last publish

Collaborators

  • erwinw