napi-rs/examples/napi/vite-entry.js

20 lines
343 B
JavaScript
Raw Normal View History

2024-01-17 00:28:40 +09:00
import {
Animal,
Kind,
asyncMultiTwo,
tsfnReturnPromise,
} from './index.wasi-browser'
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)