MCPcopy Create free account
hub / github.com/reactnativecn/react-native-update / promiseAny

Function promiseAny

src/utils.ts:23–38  ·  view source on GitHub ↗
(promises: Promise<T>[])

Source from the content-addressed store, hash-verified

21export const DEFAULT_FETCH_TIMEOUT_MS = 5000;
22
23export 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
40export const emptyObj = {};
41export const noop = () => {};

Callers 2

PushyClass · 0.90
testUrlsFunction · 0.85

Calls 2

resolveMethod · 0.80
tMethod · 0.80

Tested by

no test coverage detected