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