rust-fetch 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.ts +1 -1
- package/package.json +1 -1
- package/server.ts +9 -25
package/client.ts
CHANGED
package/package.json
CHANGED
package/server.ts
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
// import init, { greet, add, fetch_wasm_map, fetch_wasm_json } from './wasm-module/pkg/wasm_module';
|
|
2
|
-
|
|
3
1
|
import * as path from 'path';
|
|
4
|
-
import {
|
|
5
|
-
import initWasm, { fetch_wasm_json, InitOutput } from 'wasm-module';
|
|
6
|
-
const wasmPath = path.join(process.cwd(), 'node_modules', '@asemqaffaf/rust-fetch', 'wasm-module', 'pkg', 'wasm_module_bg.wasm');
|
|
7
|
-
|
|
8
|
-
let initialized = false;
|
|
9
|
-
let initPromise: InitOutput | unknown = null;
|
|
10
|
-
export async function initializeWasm() {
|
|
11
|
-
const wasmBuffer = await readFile(wasmPath);
|
|
12
|
-
return await initWasm(wasmBuffer);
|
|
13
|
-
}
|
|
2
|
+
import { readFileSync } from 'fs';
|
|
14
3
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
initPromise = initializeWasm();
|
|
19
|
-
}
|
|
20
|
-
await initPromise;
|
|
21
|
-
initialized = true;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
(async () => {
|
|
25
|
-
await ensureInitialized();
|
|
26
|
-
})();
|
|
4
|
+
import initWasm from 'wasm-module';
|
|
5
|
+
const wasmPath = path.join(process.cwd(), 'node_modules', '@asemqaffaf/rust-fetch', 'wasm-module', 'pkg', 'wasm_module_bg.wasm');
|
|
6
|
+
export const wasmBuffer = readFileSync(wasmPath);
|
|
27
7
|
|
|
28
|
-
export default
|
|
8
|
+
export default initWasm;
|
|
29
9
|
export * from 'wasm-module';
|
|
10
|
+
|
|
11
|
+
(async ()=>{
|
|
12
|
+
await initWasm(wasmBuffer);
|
|
13
|
+
})()
|