browser-async.js 484 B

1234567891011121314151617181920
  1. import { provideWasm } from './esm/browser/wasm.js';
  2. import * as wasm from './dist/wasm/web/blake3_js.js';
  3. import * as blake3 from './esm/browser/index.js';
  4. let cached;
  5. /**
  6. * Manually loads the WebAssembly module, returning a promise that resolves
  7. * to the BLAKE3 implementation once available.
  8. */
  9. export default function load(module) {
  10. if (!cached) {
  11. cached = wasm.default(module).then(() => {
  12. provideWasm(wasm);
  13. return blake3;
  14. });
  15. }
  16. return cached;
  17. }