(promises: Promise<T>[])
| 21 | export const DEFAULT_FETCH_TIMEOUT_MS = 5000; |
| 22 | |
| 23 | export function promiseAny<T>(promises: Promise<T>[]) { |
| 24 | return new Promise<T>((resolve, reject) => { |
| 25 | let count = 0; |
| 26 | |
| 27 | promises.forEach(promise => { |
| 28 | Promise.resolve(promise) |
| 29 | .then(resolve) |
| 30 | .catch(() => { |
| 31 | count++; |
| 32 | if (count === promises.length) { |
| 33 | reject(Error(i18n.t('error_all_promises_rejected'))); |
| 34 | } |
| 35 | }); |
| 36 | }); |
| 37 | }); |
| 38 | } |
| 39 | |
| 40 | export const emptyObj = {}; |
| 41 | export const noop = () => {}; |