2024-04-23 13:14:06 +09:00
|
|
|
import { Buffer } from 'buffer'
|
|
|
|
|
2024-01-17 00:28:40 +09:00
|
|
|
import {
|
|
|
|
Animal,
|
|
|
|
Kind,
|
|
|
|
asyncMultiTwo,
|
|
|
|
tsfnReturnPromise,
|
2024-04-23 13:14:06 +09:00
|
|
|
__fs,
|
|
|
|
asyncTaskReadFile,
|
2024-04-19 17:12:30 +09:00
|
|
|
} from './example.wasi-browser'
|
2024-01-17 00:28:40 +09:00
|
|
|
|
2024-04-23 13:14:06 +09:00
|
|
|
global.Buffer = Buffer
|
|
|
|
|
2024-01-17 00:28:40 +09:00
|
|
|
console.info(new Animal(Kind.Cat, 'Tom'))
|
|
|
|
asyncMultiTwo(200).then((res) => {
|
|
|
|
console.info(res)
|
|
|
|
})
|
|
|
|
const value = await tsfnReturnPromise((err, value) => {
|
|
|
|
if (err) {
|
|
|
|
throw err
|
|
|
|
}
|
|
|
|
return Promise.resolve(value + 2)
|
|
|
|
})
|
|
|
|
|
|
|
|
console.info(value)
|
2024-04-23 13:14:06 +09:00
|
|
|
|
|
|
|
__fs.writeFileSync('/test.txt', 'Hello, World!')
|
|
|
|
|
|
|
|
asyncTaskReadFile('/test.txt')
|
|
|
|
.then((res) => {
|
|
|
|
console.log(`readFileAsync: ${res}`)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
console.error(err)
|
|
|
|
})
|