Skip to content

Commit f1c321a

Browse files
authored
Initial usage of async/await in JS library code. NFC (#23104)
Convert asyncLoad from promises to async/await. This lays the groundwork for more a larger usage in #23068
1 parent d1ea4c3 commit f1c321a

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

src/library.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -2181,16 +2181,12 @@ addToLibrary({
21812181
return x.startsWith('dynCall_') ? x : '_' + x;
21822182
},
21832183

2184-
$asyncLoad: (url) => {
2185-
return new Promise((resolve, reject) => {
2186-
readAsync(url).then(
2187-
(arrayBuffer) => {
2184+
$asyncLoad: async (url) => {
2185+
var arrayBuffer = await readAsync(url);
21882186
#if ASSERTIONS
2189-
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
2187+
assert(arrayBuffer, `Loading data file "${url}" failed (no arrayBuffer).`);
21902188
#endif
2191-
resolve(new Uint8Array(arrayBuffer));
2192-
}, reject);
2193-
});
2189+
return new Uint8Array(arrayBuffer);
21942190
},
21952191

21962192
$alignMemory: (size, alignment) => {
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6276
1+
6274
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
13831
1+
13816

0 commit comments

Comments
 (0)