source: trip-planner-front/node_modules/source-map/lib/read-wasm.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.2 KB
Line 
1if (typeof fetch === "function") {
2 // Web version of reading a wasm file into an array buffer.
3
4 let mappingsWasmUrl = null;
5
6 module.exports = function readWasm() {
7 if (typeof mappingsWasmUrl !== "string") {
8 throw new Error("You must provide the URL of lib/mappings.wasm by calling " +
9 "SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) " +
10 "before using SourceMapConsumer");
11 }
12
13 return fetch(mappingsWasmUrl)
14 .then(response => response.arrayBuffer());
15 };
16
17 module.exports.initialize = url => mappingsWasmUrl = url;
18} else {
19 // Node version of reading a wasm file into an array buffer.
20 const fs = require("fs");
21 const path = require("path");
22
23 module.exports = function readWasm() {
24 return new Promise((resolve, reject) => {
25 const wasmPath = path.join(__dirname, "mappings.wasm");
26 fs.readFile(wasmPath, null, (error, data) => {
27 if (error) {
28 reject(error);
29 return;
30 }
31
32 resolve(data.buffer);
33 });
34 });
35 };
36
37 module.exports.initialize = _ => {
38 console.debug("SourceMapConsumer.initialize is a no-op when running in node.js");
39 };
40}
Note: See TracBrowser for help on using the repository browser.