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"
85
96const WASI = {
107 MicroWASI : ( { programName } ) => {
@@ -54,10 +51,10 @@ const selectWASIBackend = () => {
5451 return WASI . Node ;
5552} ;
5653
57- const startWasiTask = async ( wasmPath , wasiConstructor = selectWASIBackend ( ) ) => {
54+ export const startWasiTask = async ( wasmPath , wasiConstructor = selectWASIBackend ( ) ) => {
5855 const swift = new SwiftRuntime ( ) ;
5956 // Fetch our Wasm File
60- const wasmBinary = await readFile ( wasmPath ) ;
57+ const wasmBinary = await fs . readFile ( wasmPath ) ;
6158 const wasi = wasiConstructor ( { programName : wasmPath } ) ;
6259
6360 // Instantiate the WebAssembly file
@@ -74,5 +71,3 @@ const startWasiTask = async (wasmPath, wasiConstructor = selectWASIBackend()) =>
7471 // Start the WebAssembly WASI instance!
7572 wasi . start ( instance , swift ) ;
7673} ;
77-
78- module . exports = { startWasiTask, WASI } ;
0 commit comments