sequent-promises
v2.0.1
Published
sequentPromises resolves Promises sequentially
Downloads
3,595
Readme
sequent-promises
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
- Website: https://krivega.com
- Github: @Krivega
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.