MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / getBinarySync

Function getBinarySync

src/preamble.js:456–481  ·  view source on GitHub ↗
(file)

Source from the content-addressed store, hash-verified

454}
455
456function getBinarySync(file) {
457#if SINGLE_FILE && SINGLE_FILE_BINARY_ENCODE
458 return file;
459#else
460#if SINGLE_FILE
461 if (ArrayBuffer.isView(file)) {
462 return file;
463 }
464#endif
465#if expectToReceiveOnModule('wasmBinary') || WASM2JS
466 if (file == wasmBinaryFile && wasmBinary) {
467 return new Uint8Array(wasmBinary);
468 }
469#endif
470 if (readBinary) {
471 return readBinary(file);
472 }
473 // Throwing a plain string here, even though it not normally advisable since
474 // this gets turning into an `abort` in instantiateArrayBuffer.
475#if WASM_ASYNC_COMPILATION
476 throw 'both async and sync fetching of the wasm failed';
477#else
478 throw 'sync fetching of the wasm failed: you can preload it to Module["wasmBinary"] manually, or emcc.py will do that for you when generating HTML (but not JS)';
479#endif
480#endif
481}
482
483async function getWasmBinary(binaryFile) {
484#if !SINGLE_FILE

Callers 2

getWasmBinaryFunction · 0.70
preamble.jsFile · 0.70

Calls 2

readBinaryFunction · 0.85
expectToReceiveOnModuleFunction · 0.50

Tested by

no test coverage detected