| 1 |
import { encoder } from "../utils/text-encoders.js"; |
| 2 |
|
| 3 |
export function writeFile(wasm) { |
| 4 |
return (_, path, data_) => { |
| 5 |
const data = typeof data_ === "string" ? encoder.encode(data_) : data_; |
| 6 |
wasm.wasi.writeFile(path, data); |
| 7 |
}; |
| 8 |
} |
| 9 |
|
| 10 |
writeFile.toString = () => "async (path, data) => void"; |
| 11 |
|
| 12 |
export function appendFile(wasm) { |
| 13 |
return (_, path, data_) => { |
| 14 |
const data = typeof data_ === "string" ? encoder.encode(data_) : data_; |
| 15 |
wasm.wasi.appendFile(path, data); |
| 16 |
}; |
| 17 |
} |
| 18 |
|
| 19 |
appendFile.toString = () => "async (path, data) => void"; |
| 20 |
|
| 21 |
export function readFile(wasm) { |
| 22 |
return (_, path) => { |
| 23 |
return wasm.wasi.readFile(path); |
| 24 |
}; |
| 25 |
} |
| 26 |
|
| 27 |
readFile.toString = () => "async (path) => ?Uint8Array"; |
| 28 |
|
| 29 |
export function unlink(wasm) { |
| 30 |
return (_, path) => { |
| 31 |
return wasm.wasi.unlink(path); |
| 32 |
}; |
| 33 |
} |
| 34 |
|
| 35 |
unlink.toString = () => "async (path) => void"; |
| 36 |
|
| 37 |
export function readdir(wasm) { |
| 38 |
return (_, path) => wasm.wasi.readdir(path); |
| 39 |
} |
| 40 |
|
| 41 |
readdir.toString = () => "async (path) => string[]"; |
| 42 |
|
| 43 |
export function mkdir(wasm) { |
| 44 |
return (_, path) => { |
| 45 |
return wasm.wasi.mkdir(path); |
| 46 |
}; |
| 47 |
} |
| 48 |
|
| 49 |
mkdir.toString = () => "async (path) => void"; |