Skip to content

Commit

Permalink
fix: init non-browser wasm module by default
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Dec 30, 2024
1 parent 4c0c216 commit 8abb258
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 3 additions & 1 deletion packages/utils/rateless-iblt/src_js/wasm-init.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Override globalThis.fetch to intercept .wasm requests
import { readFile } from "fs/promises";
import "./wasm-init.js";
import init from "./rateless_iblt.js";

const defaultFetch = globalThis.fetch.bind(globalThis);
globalThis.fetch = async (url, options) => {
Expand All @@ -13,3 +13,5 @@ globalThis.fetch = async (url, options) => {

return defaultFetch(url, options);
};

await init();
10 changes: 1 addition & 9 deletions packages/utils/rateless-iblt/test/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { expect } from "chai";
import * as fs from "fs";
import path from "path";
import { fileURLToPath } from "url";
import { DecoderWrapper, EncoderWrapper, initSync } from "../dist/index.js";

const __dirname = path.dirname(fileURLToPath(import.meta.url));
initSync(
fs.readFileSync(path.join(__dirname, "../dist/rateless_iblt_bg.wasm")),
);
import { DecoderWrapper, EncoderWrapper } from "../dist/index.js";

describe("riblt", () => {
it("diff", async () => {
Expand Down

0 comments on commit 8abb258

Please sign in to comment.