sequent-promises
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

sequent-promises

npm npm bundle size

Call promises one by one, ignoring the state (fulfilled or rejected). and returning the collected data in the tuple { results, errors }.

Install

npm

npm install sequent-promises

yarn

yarn add sequent-promises

Usage

import sequentPromises, { isNotRunningError } from 'sequent-promises';

const result = 'result';
const error = new Error('error');
const promiseResolve = () => Promise.resolve(result);
const promiseReject = () => Promise.reject(error);

sequentPromises([promiseResolve, promiseReject, promiseResolve, isSuccessful, isError]).then(
  ({ success, errors, results }) => {
    console.log(success); // [result, result]
    console.log(errors); // ['Not running: Promise was not running']
    console.log(results); // [result, 'Not running: Promise was not running', result]
    console.log(isSuccessful); // true - last promise
    console.log(isError); // false - last promise
    console.log(isNotRunningError(errors[0])); //true;
  },
);

Run tests

npm test

Maintainer

Krivega Dmitriy

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page. You can also take a look at the contributing guide.

📝 License

Copyright © 2020 Krivega Dmitriy.
This project is MIT licensed.

Readme

Keywords

Package Sidebar

Install

npm i sequent-promises

Weekly Downloads

514

Version

1.0.2

License

MIT

Unpacked Size

8.57 kB

Total Files

6

Last publish

Collaborators

  • krivega