source: node_modules/ramda-adjunct/src/internal/ponyfills/Promise.any.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 603 bytes
RevLine 
[d24f17c]1import { map } from 'ramda';
2
3import resolveP from '../../resolveP';
4
5export class AggregatedError extends Error {
6 constructor(errors = [], message = '') {
7 super(message);
8
9 this.errors = errors;
10 }
11}
12
13const anyPonyfill = (iterable) => {
14 const exceptions = [];
15
16 return new Promise((resolve, reject) => {
17 const onReject = (e) => {
18 exceptions.push(e);
19
20 if (exceptions.length === iterable.length) {
21 reject(new AggregatedError(exceptions));
22 }
23 };
24
25 map((p) => resolveP(p).then(resolve).catch(onReject), [...iterable]);
26 });
27};
28
29export default anyPonyfill;
Note: See TracBrowser for help on using the repository browser.