@@ -607,10 +607,7 @@ def generate_js(data_target, data_files, metadata):
607
607
var Module = typeof %(EXPORT_NAME)s != 'undefined' ? %(EXPORT_NAME)s : {};\n ''' % {"EXPORT_NAME" : options .export_name }
608
608
609
609
ret += '''
610
- if (!Module['expectedDataFileDownloads']) {
611
- Module['expectedDataFileDownloads'] = 0;
612
- }
613
-
610
+ Module['expectedDataFileDownloads'] ??= 0;
614
611
Module['expectedDataFileDownloads']++;
615
612
(() => {
616
613
// Do not attempt to redownload the virtual filesystem data when in a pthread or a Wasm Worker context.
@@ -1033,7 +1030,7 @@ def generate_js(data_target, data_files, metadata):
1033
1030
# we need to find the datafile in the same dir as the html file
1034
1031
1035
1032
code += '''
1036
- if (! Module['preloadResults']) Module['preloadResults'] = {};\n '''
1033
+ Module['preloadResults'] ?? = {};\n '''
1037
1034
1038
1035
if options .use_preload_cache :
1039
1036
code += '''
@@ -1099,8 +1096,7 @@ def generate_js(data_target, data_files, metadata):
1099
1096
if (Module['calledRun']) {
1100
1097
runWithFS(Module);
1101
1098
} else {
1102
- if (!Module['preRun']) Module['preRun'] = [];
1103
- Module["preRun"].push(runWithFS); // FS is not initialized yet, wait for it
1099
+ (Module['preRun'] ??= []).push(runWithFS); // FS is not initialized yet, wait for it
1104
1100
}\n '''
1105
1101
1106
1102
if options .separate_metadata :
@@ -1139,8 +1135,7 @@ def generate_js(data_target, data_files, metadata):
1139
1135
if (Module['calledRun']) {
1140
1136
runMetaWithFS();
1141
1137
} else {
1142
- if (!Module['preRun']) Module['preRun'] = [];
1143
- Module["preRun"].push(runMetaWithFS);
1138
+ (Module['preRun'] ??= []).push(runMetaWithFS);
1144
1139
}\n ''' % {'node_support_code' : node_support_code , 'metadata_file' : os .path .basename (options .jsoutput + '.metadata' )}
1145
1140
else :
1146
1141
ret += '''
0 commit comments