promises-utils.auto
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

installation

npm install promises-utils.auto

promises-utils.auto

Determines the best order for running the AsyncFunctions in tasks, based on their requirements. Each function can optionally depend on other functions being completed first, and each function is run as soon as its requirements are satisfied.

AsyncFunctions also receive an object containing the results of functions which have completed so far as an argument.

Insprired from async.auto

usage

Array version:

import { promiseAuto } from 'promises-utils.throttle';

async function example() {
  const results = promiseAuto({
    a: () => 'a';
    b: {
      dependencies: ['a', 'c'],
      task: ({ a }) => {
        console.log(a); // 'a', runs after "a" and "c" is resolved
        return 100;
      }
    },
    c: async () => {
      await wait(1000);
    }
  });
  console.log(results) // { a: 'a', b: 100, c: undefined }
}

Package Sidebar

Install

npm i promises-utils.auto

Weekly Downloads

1

Version

0.0.5

License

MIT

Unpacked Size

35.8 kB

Total Files

13

Last publish

Collaborators

  • jordanh