read-wasm-browser.js 602 B

1234567891011121314151617181920212223
  1. "use strict";
  2. let mappingsWasm = null;
  3. module.exports = function readWasm() {
  4. if (typeof mappingsWasm === "string") {
  5. return fetch(mappingsWasm).then(response => response.arrayBuffer());
  6. }
  7. if (mappingsWasm instanceof ArrayBuffer) {
  8. return Promise.resolve(mappingsWasm);
  9. }
  10. throw new Error(
  11. "You must provide the string URL or ArrayBuffer contents " +
  12. "of lib/mappings.wasm by calling " +
  13. "SourceMapConsumer.initialize({ 'lib/mappings.wasm': ... }) " +
  14. "before using SourceMapConsumer"
  15. );
  16. };
  17. module.exports.initialize = input => {
  18. mappingsWasm = input;
  19. };