11import { CheckResult , PushyOptions , ProgressData , EventType } from './type' ;
2- import { joinUrls , log , testUrls } from './utils' ;
2+ import { emptyObj , joinUrls , log , noop , promiseAny , testUrls } from './utils' ;
33import { EmitterSubscription , Platform } from 'react-native' ;
44import { PermissionsAndroid } from './permissions' ;
55import {
@@ -24,9 +24,6 @@ const defaultServer = {
2424 ] ,
2525} ;
2626
27- const empty = { } ;
28- const noop = ( ) => { } ;
29-
3027if ( Platform . OS === 'web' ) {
3128 console . warn ( 'react-native-update 不支持 web 端热更,不会执行操作' ) ;
3229}
@@ -230,7 +227,7 @@ export class Pushy {
230227 const backupEndpoints = await this . getBackupEndpoints ( ) ;
231228 if ( backupEndpoints ) {
232229 try {
233- resp = await Promise . race (
230+ resp = await promiseAny (
234231 backupEndpoints . map ( endpoint =>
235232 fetch ( this . getCheckUrl ( endpoint ) , fetchPayload ) ,
236233 ) ,
@@ -248,7 +245,7 @@ export class Pushy {
248245 message : 'Can not connect to update server. Please check your network.' ,
249246 } ) ;
250247 this . throwIfEnabled ( new Error ( 'errorChecking' ) ) ;
251- return this . lastRespJson ? await this . lastRespJson : empty ;
248+ return this . lastRespJson ? await this . lastRespJson : emptyObj ;
252249 }
253250 this . lastRespJson = resp . json ( ) ;
254251
@@ -273,7 +270,7 @@ export class Pushy {
273270 }
274271 if ( server . queryUrls ) {
275272 try {
276- const resp = await Promise . race (
273+ const resp = await promiseAny (
277274 server . queryUrls . map ( queryUrl => fetch ( queryUrl ) ) ,
278275 ) ;
279276 const remoteEndpoints = await resp . json ( ) ;
0 commit comments