@@ -2009,9 +2009,7 @@ function getUniqueRunDependency(id) {
20092009function addRunDependency ( id ) {
20102010 runDependencies ++ ;
20112011
2012- if ( Module [ 'monitorRunDependencies' ] ) {
2013- Module [ 'monitorRunDependencies' ] ( runDependencies ) ;
2014- }
2012+ Module [ 'monitorRunDependencies' ] ?. ( runDependencies ) ;
20152013
20162014 if ( id ) {
20172015 assert ( ! runDependencyTracking [ id ] ) ;
@@ -2045,9 +2043,7 @@ function addRunDependency(id) {
20452043function removeRunDependency ( id ) {
20462044 runDependencies -- ;
20472045
2048- if ( Module [ 'monitorRunDependencies' ] ) {
2049- Module [ 'monitorRunDependencies' ] ( runDependencies ) ;
2050- }
2046+ Module [ 'monitorRunDependencies' ] ?. ( runDependencies ) ;
20512047
20522048 if ( id ) {
20532049 assert ( runDependencyTracking [ id ] ) ;
@@ -2070,9 +2066,7 @@ function removeRunDependency(id) {
20702066
20712067/** @param {string|number= } what */
20722068function abort ( what ) {
2073- if ( Module [ 'onAbort' ] ) {
2074- Module [ 'onAbort' ] ( what ) ;
2075- }
2069+ Module [ 'onAbort' ] ?. ( what ) ;
20762070
20772071 what = 'Aborted(' + what + ')' ;
20782072 // TODO(sbc): Should we remove printing and leave it up to whoever
@@ -2476,7 +2470,7 @@ function dbg(text) {
24762470 }
24772471
24782472 var warnOnce = ( text ) => {
2479- if ( ! warnOnce . shown ) warnOnce . shown = { } ;
2473+ warnOnce . shown || = { } ;
24802474 if ( ! warnOnce . shown [ text ] ) {
24812475 warnOnce . shown [ text ] = 1 ;
24822476 if ( ENVIRONMENT_IS_NODE ) text = 'warning: ' + text ;
@@ -3024,55 +3018,53 @@ function dbg(text) {
30243018 // no supported
30253019 throw new FS . ErrnoError ( 63 ) ;
30263020 }
3027- if ( ! MEMFS . ops_table ) {
3028- MEMFS . ops_table = {
3029- dir : {
3030- node : {
3031- getattr : MEMFS . node_ops . getattr ,
3032- setattr : MEMFS . node_ops . setattr ,
3033- lookup : MEMFS . node_ops . lookup ,
3034- mknod : MEMFS . node_ops . mknod ,
3035- rename : MEMFS . node_ops . rename ,
3036- unlink : MEMFS . node_ops . unlink ,
3037- rmdir : MEMFS . node_ops . rmdir ,
3038- readdir : MEMFS . node_ops . readdir ,
3039- symlink : MEMFS . node_ops . symlink
3040- } ,
3041- stream : {
3042- llseek : MEMFS . stream_ops . llseek
3043- }
3021+ MEMFS . ops_table ||= {
3022+ dir : {
3023+ node : {
3024+ getattr : MEMFS . node_ops . getattr ,
3025+ setattr : MEMFS . node_ops . setattr ,
3026+ lookup : MEMFS . node_ops . lookup ,
3027+ mknod : MEMFS . node_ops . mknod ,
3028+ rename : MEMFS . node_ops . rename ,
3029+ unlink : MEMFS . node_ops . unlink ,
3030+ rmdir : MEMFS . node_ops . rmdir ,
3031+ readdir : MEMFS . node_ops . readdir ,
3032+ symlink : MEMFS . node_ops . symlink
30443033 } ,
3045- file : {
3046- node : {
3047- getattr : MEMFS . node_ops . getattr ,
3048- setattr : MEMFS . node_ops . setattr
3049- } ,
3050- stream : {
3051- llseek : MEMFS . stream_ops . llseek ,
3052- read : MEMFS . stream_ops . read ,
3053- write : MEMFS . stream_ops . write ,
3054- allocate : MEMFS . stream_ops . allocate ,
3055- mmap : MEMFS . stream_ops . mmap ,
3056- msync : MEMFS . stream_ops . msync
3057- }
3058- } ,
3059- link : {
3060- node : {
3061- getattr : MEMFS . node_ops . getattr ,
3062- setattr : MEMFS . node_ops . setattr ,
3063- readlink : MEMFS . node_ops . readlink
3064- } ,
3065- stream : { }
3034+ stream : {
3035+ llseek : MEMFS . stream_ops . llseek
3036+ }
3037+ } ,
3038+ file : {
3039+ node : {
3040+ getattr : MEMFS . node_ops . getattr ,
3041+ setattr : MEMFS . node_ops . setattr
30663042 } ,
3067- chrdev : {
3068- node : {
3069- getattr : MEMFS . node_ops . getattr ,
3070- setattr : MEMFS . node_ops . setattr
3071- } ,
3072- stream : FS . chrdev_stream_ops
3043+ stream : {
3044+ llseek : MEMFS . stream_ops . llseek ,
3045+ read : MEMFS . stream_ops . read ,
3046+ write : MEMFS . stream_ops . write ,
3047+ allocate : MEMFS . stream_ops . allocate ,
3048+ mmap : MEMFS . stream_ops . mmap ,
3049+ msync : MEMFS . stream_ops . msync
30733050 }
3074- } ;
3075- }
3051+ } ,
3052+ link : {
3053+ node : {
3054+ getattr : MEMFS . node_ops . getattr ,
3055+ setattr : MEMFS . node_ops . setattr ,
3056+ readlink : MEMFS . node_ops . readlink
3057+ } ,
3058+ stream : { }
3059+ } ,
3060+ chrdev : {
3061+ node : {
3062+ getattr : MEMFS . node_ops . getattr ,
3063+ setattr : MEMFS . node_ops . setattr
3064+ } ,
3065+ stream : FS . chrdev_stream_ops
3066+ }
3067+ } ;
30763068 var node = FS . createNode ( parent , name , mode , dev ) ;
30773069 if ( FS . isDir ( node . mode ) ) {
30783070 node . node_ops = MEMFS . ops_table . dir . node ;
@@ -3215,10 +3207,7 @@ function dbg(text) {
32153207 } ,
32163208 readdir ( node ) {
32173209 var entries = [ '.' , '..' ] ;
3218- for ( var key in node . contents ) {
3219- if ( ! node . contents . hasOwnProperty ( key ) ) {
3220- continue ;
3221- }
3210+ for ( var key of Object . keys ( node . contents ) ) {
32223211 entries . push ( key ) ;
32233212 }
32243213 return entries ;
@@ -3393,15 +3382,15 @@ function dbg(text) {
33933382 var dep = getUniqueRunDependency ( `cp ${ fullname } ` ) ; // might have several active requests for the same fullname
33943383 function processData ( byteArray ) {
33953384 function finish ( byteArray ) {
3396- if ( preFinish ) preFinish ( ) ;
3385+ preFinish ?. ( ) ;
33973386 if ( ! dontCreateFile ) {
33983387 FS_createDataFile ( parent , name , byteArray , canRead , canWrite , canOwn ) ;
33993388 }
3400- if ( onload ) onload ( ) ;
3389+ onload ?. ( ) ;
34013390 removeRunDependency ( dep ) ;
34023391 }
34033392 if ( FS_handledByPreloadPlugin ( byteArray , fullname , finish , ( ) => {
3404- if ( onerror ) onerror ( ) ;
3393+ onerror ?. ( ) ;
34053394 removeRunDependency ( dep ) ;
34063395 } ) ) {
34073396 return ;
@@ -4017,9 +4006,7 @@ function dbg(text) {
40174006 // override node's stream ops with the device's
40184007 stream . stream_ops = device . stream_ops ;
40194008 // forward the open call
4020- if ( stream . stream_ops . open ) {
4021- stream . stream_ops . open ( stream ) ;
4022- }
4009+ stream . stream_ops . open ?. ( stream ) ;
40234010 } ,
40244011 llseek ( ) {
40254012 throw new FS . ErrnoError ( 70 ) ;
@@ -5041,7 +5028,7 @@ function dbg(text) {
50415028 } ,
50425029 close ( stream ) {
50435030 // flush any pending line data
5044- if ( output && output . buffer && output . buffer . length ) {
5031+ if ( output ? .buffer ? .length ) {
50455032 output ( 10 ) ;
50465033 }
50475034 } ,
@@ -6087,7 +6074,7 @@ function dbg(text) {
60876074 try {
60886075
60896076 var stream = SYSCALLS . getStreamFromFD ( fd ) ;
6090- if ( stream . stream_ops && stream . stream_ops . fsync ) {
6077+ if ( stream . stream_ops ? .fsync ) {
60916078 return stream . stream_ops . fsync ( stream ) ;
60926079 }
60936080 return 0 ; // we can't do anything synchronously; the in-memory FS is already synced to
@@ -6753,6 +6740,7 @@ var missingLibrarySymbols = [
67536740 'registerTouchEventCallback' ,
67546741 'fillGamepadEventData' ,
67556742 'registerGamepadEventCallback' ,
6743+ 'disableGamepadApiIfItThrows' ,
67566744 'registerBeforeUnloadEventCallback' ,
67576745 'fillBatteryEventData' ,
67586746 'battery' ,
@@ -6775,6 +6763,7 @@ var missingLibrarySymbols = [
67756763 'makePromiseCallback' ,
67766764 'ExceptionInfo' ,
67776765 'findMatchingCatch' ,
6766+ 'Browser_asyncPrepareDataCounter' ,
67786767 'setMainLoop' ,
67796768 'getSocketFromFD' ,
67806769 'getSocketAddress' ,
@@ -7031,7 +7020,7 @@ function checkUnflushedContent() {
70317020 var stream = info . object ;
70327021 var rdev = stream . rdev ;
70337022 var tty = TTY . ttys [ rdev ] ;
7034- if ( tty && tty . output && tty . output . length ) {
7023+ if ( tty ? .output ? .length ) {
70357024 has = true ;
70367025 }
70377026 } ) ;
0 commit comments