1
- const SwiftRuntime = require ( "javascript-kit-swift" ) . SwiftRuntime ;
2
- const NodeWASI = require ( "wasi" ) . WASI ;
3
- const { WASI : MicroWASI , useAll } = require ( "uwasi" ) ;
4
-
5
- const promisify = require ( "util" ) . promisify ;
6
- const fs = require ( "fs" ) ;
7
- const readFile = promisify ( fs . readFile ) ;
1
+ import { SwiftRuntime } from "javascript-kit-swift"
2
+ import { WASI as NodeWASI } from "wasi"
3
+ import { WASI as MicroWASI , useAll } from "uwasi"
4
+ import * as fs from "fs/promises"
8
5
9
6
const WASI = {
10
7
MicroWASI : ( { programName } ) => {
@@ -54,10 +51,10 @@ const selectWASIBackend = () => {
54
51
return WASI . Node ;
55
52
} ;
56
53
57
- const startWasiTask = async ( wasmPath , wasiConstructor = selectWASIBackend ( ) ) => {
54
+ export const startWasiTask = async ( wasmPath , wasiConstructor = selectWASIBackend ( ) ) => {
58
55
const swift = new SwiftRuntime ( ) ;
59
56
// Fetch our Wasm File
60
- const wasmBinary = await readFile ( wasmPath ) ;
57
+ const wasmBinary = await fs . readFile ( wasmPath ) ;
61
58
const wasi = wasiConstructor ( { programName : wasmPath } ) ;
62
59
63
60
// Instantiate the WebAssembly file
@@ -74,5 +71,3 @@ const startWasiTask = async (wasmPath, wasiConstructor = selectWASIBackend()) =>
74
71
// Start the WebAssembly WASI instance!
75
72
wasi . start ( instance , swift ) ;
76
73
} ;
77
-
78
- module . exports = { startWasiTask, WASI } ;
0 commit comments