@@ -84,7 +84,7 @@ function fetchDeleteCachedData(db, fetch, onsuccess, onerror) {
8484
8585 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
8686 var path = HEAPU32 [ fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . destinationPath } } } >> 2 ] ;
87- if ( ! path ) path = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
87+ path || = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
8888 var pathStr = UTF8ToString ( path ) ;
8989
9090 try {
@@ -133,7 +133,7 @@ function fetchLoadCachedData(db, fetch, onsuccess, onerror) {
133133
134134 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
135135 var path = HEAPU32 [ fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . destinationPath } } } >> 2 ] ;
136- if ( ! path ) path = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
136+ path || = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
137137 var pathStr = UTF8ToString ( path ) ;
138138
139139 try {
@@ -198,7 +198,7 @@ function fetchCacheData(/** @type {IDBDatabase} */ db, fetch, data, onsuccess, o
198198
199199 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
200200 var destinationPath = HEAPU32 [ fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . destinationPath } } } >> 2 ] ;
201- if ( ! destinationPath ) destinationPath = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
201+ destinationPath || = HEAPU32 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . url } } } >> 2 ] ;
202202 var destinationPathStr = UTF8ToString ( destinationPath ) ;
203203
204204 try {
@@ -248,7 +248,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
248248
249249 var fetch_attr = fetch + { { { C_STRUCTS . emscripten_fetch_t . __attributes } } } ;
250250 var requestMethod = UTF8ToString ( fetch_attr + { { { C_STRUCTS . emscripten_fetch_attr_t . requestMethod } } } ) ;
251- if ( ! requestMethod ) requestMethod = 'GET' ;
251+ requestMethod || = 'GET' ;
252252 var timeoutMsecs = { { { makeGetValue ( 'fetch_attr' , C_STRUCTS . emscripten_fetch_attr_t . timeoutMSecs , 'u32' ) } } } ;
253253 var userName = { { { makeGetValue ( 'fetch_attr' , C_STRUCTS . emscripten_fetch_attr_t . userName , '*' ) } } } ;
254254 var password = { { { makeGetValue ( 'fetch_attr' , C_STRUCTS . emscripten_fetch_attr_t . password , '*' ) } } } ;
@@ -354,12 +354,12 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
354354#if FETCH_DEBUG
355355 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " succeeded with status ${ xhr . status } ` ) ;
356356#endif
357- if ( onsuccess ) onsuccess ( fetch , xhr , e ) ;
357+ onsuccess ?. ( fetch , xhr , e ) ;
358358 } else {
359359#if FETCH_DEBUG
360360 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " failed with status ${ xhr . status } ` ) ;
361361#endif
362- if ( onerror ) onerror ( fetch , xhr , e ) ;
362+ onerror ?. ( fetch , xhr , e ) ;
363363 }
364364 } ;
365365 xhr . onerror = ( e ) => {
@@ -371,7 +371,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
371371 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " finished with error, readyState ${ xhr . readyState } and status ${ xhr . status } ` ) ;
372372#endif
373373 saveResponseAndStatus ( ) ;
374- if ( onerror ) onerror ( fetch , xhr , e ) ;
374+ onerror ?. ( fetch , xhr , e ) ;
375375 } ;
376376 xhr . ontimeout = ( e ) => {
377377 // check if xhr was aborted by user and don't try to call back
@@ -381,7 +381,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
381381#if FETCH_DEBUG
382382 dbg ( `fetch: xhr of URL "${ xhr . url_ } " / responseURL "${ xhr . responseURL } " timed out, readyState ${ xhr . readyState } and status ${ xhr . status } ` ) ;
383383#endif
384- if ( onerror ) onerror ( fetch , xhr , e ) ;
384+ onerror ?. ( fetch , xhr , e ) ;
385385 } ;
386386 xhr . onprogress = ( e ) => {
387387 // check if xhr was aborted by user and don't try to call back
@@ -410,7 +410,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
410410 if ( xhr . readyState >= 3 && xhr . status === 0 && e . loaded > 0 ) xhr . status = 200 ;
411411 HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = xhr . status ;
412412 if ( xhr . statusText ) stringToUTF8 ( xhr . statusText , fetch + { { { C_STRUCTS . emscripten_fetch_t . statusText } } } , 64 ) ;
413- if ( onprogress ) onprogress ( fetch , xhr , e ) ;
413+ onprogress ?. ( fetch , xhr , e ) ;
414414 if ( ptr ) {
415415 _free ( ptr ) ;
416416 }
@@ -425,7 +425,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
425425 if ( xhr . readyState >= 2 ) {
426426 HEAPU16 [ fetch + { { { C_STRUCTS . emscripten_fetch_t . status } } } >> 1 ] = xhr . status ;
427427 }
428- if ( onreadystatechange ) onreadystatechange ( fetch , xhr , e ) ;
428+ onreadystatechange ?. ( fetch , xhr , e ) ;
429429 } ;
430430#if FETCH_DEBUG
431431 dbg ( `fetch: xhr.send(data=${ data } )` ) ;
@@ -436,7 +436,7 @@ function fetchXHR(fetch, onsuccess, onerror, onprogress, onreadystatechange) {
436436#if FETCH_DEBUG
437437 dbg ( `fetch: xhr failed with exception: ${ e } ` ) ;
438438#endif
439- if ( onerror ) onerror ( fetch , xhr , e ) ;
439+ onerror ?. ( fetch , xhr , e ) ;
440440 }
441441}
442442
@@ -468,14 +468,14 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
468468 { { { runtimeKeepalivePop ( ) } } }
469469 doCallback ( ( ) => {
470470 if ( onsuccess ) { { { makeDynCall ( 'vp' , 'onsuccess' ) } } } ( fetch ) ;
471- else if ( successcb ) successcb ( fetch ) ;
471+ else successcb ?. ( fetch ) ;
472472 } ) ;
473473 } ;
474474
475475 var reportProgress = ( fetch , xhr , e ) => {
476476 doCallback ( ( ) => {
477477 if ( onprogress ) { { { makeDynCall ( 'vp' , 'onprogress' ) } } } ( fetch ) ;
478- else if ( progresscb ) progresscb ( fetch ) ;
478+ else progresscb ?. ( fetch ) ;
479479 } ) ;
480480 } ;
481481
@@ -486,7 +486,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
486486 { { { runtimeKeepalivePop ( ) } } }
487487 doCallback ( ( ) => {
488488 if ( onerror ) { { { makeDynCall ( 'vp' , 'onerror' ) } } } ( fetch ) ;
489- else if ( errorcb ) errorcb ( fetch ) ;
489+ else errorcb ?. ( fetch ) ;
490490 } ) ;
491491 } ;
492492
@@ -496,7 +496,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
496496#endif
497497 doCallback ( ( ) => {
498498 if ( onreadystatechange ) { { { makeDynCall ( 'vp' , 'onreadystatechange' ) } } } ( fetch ) ;
499- else if ( readystatechangecb ) readystatechangecb ( fetch ) ;
499+ else readystatechangecb ?. ( fetch ) ;
500500 } ) ;
501501 } ;
502502
@@ -519,7 +519,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
519519 { { { runtimeKeepalivePop ( ) } } }
520520 doCallback ( ( ) => {
521521 if ( onsuccess ) { { { makeDynCall ( 'vp' , 'onsuccess' ) } } } ( fetch ) ;
522- else if ( successcb ) successcb ( fetch ) ;
522+ else successcb ?. ( fetch ) ;
523523 } ) ;
524524 } ;
525525 var storeError = ( fetch , xhr , e ) => {
@@ -529,7 +529,7 @@ function startFetch(fetch, successcb, errorcb, progresscb, readystatechangecb) {
529529 { { { runtimeKeepalivePop ( ) } } }
530530 doCallback ( ( ) => {
531531 if ( onsuccess ) { { { makeDynCall ( 'vp' , 'onsuccess' ) } } } ( fetch ) ;
532- else if ( successcb ) successcb ( fetch ) ;
532+ else successcb ?. ( fetch ) ;
533533 } ) ;
534534 } ;
535535 fetchCacheData ( Fetch . dbInstance , fetch , xhr . response , storeSuccess , storeError ) ;
0 commit comments