mirror of
https://gitcode.com/gh_mirrors/re/react-native-pushy.git
synced 2025-09-16 10:21:37 +08:00
cleanup
This commit is contained in:
15
lib/utils.ts
15
lib/utils.ts
@@ -4,7 +4,7 @@ export function promiseAny<T>(promises: Promise<T>[]) {
|
||||
return new Promise<T>((resolve, reject) => {
|
||||
let count = 0;
|
||||
|
||||
promises.forEach(promise => {
|
||||
promises.forEach((promise) => {
|
||||
Promise.resolve(promise)
|
||||
.then(resolve)
|
||||
.catch(() => {
|
||||
@@ -44,7 +44,7 @@ const ping =
|
||||
logger('ping failed', url, status, statusText);
|
||||
throw new Error('Ping failed');
|
||||
})
|
||||
.catch(e => {
|
||||
.catch((e) => {
|
||||
pingFinished = true;
|
||||
logger('ping error', url, e);
|
||||
throw e;
|
||||
@@ -60,15 +60,16 @@ const ping =
|
||||
]);
|
||||
};
|
||||
|
||||
|
||||
export const testUrls = async (urls?: string[]) => {
|
||||
if (!urls?.length) {
|
||||
return null;
|
||||
}
|
||||
const ret = await promiseAny(urls.map(ping));
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
try {
|
||||
const ret = await promiseAny(urls.map(ping));
|
||||
if (ret) {
|
||||
return ret;
|
||||
}
|
||||
} catch {}
|
||||
logger('all ping failed, use first url:', urls[0]);
|
||||
return urls[0];
|
||||
};
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "react-native-update",
|
||||
"version": "8.5.3",
|
||||
"version": "8.5.4",
|
||||
"description": "react-native hot update",
|
||||
"main": "lib/index.ts",
|
||||
"scripts": {
|
||||
|
Reference in New Issue
Block a user