17 lines
424 B
TypeScript
17 lines
424 B
TypeScript
import { initSync } from '../src/index.js'
|
|
|
|
export async function initWasm() {
|
|
const url = new URL('../mtcute.wasm', import.meta.url)
|
|
|
|
if (import.meta.env.TEST_ENV === 'node') {
|
|
const fs = await import('fs/promises')
|
|
const blob = await fs.readFile(url)
|
|
initSync(blob)
|
|
|
|
return
|
|
}
|
|
|
|
const blob = await fetch(url)
|
|
const buffer = await blob.arrayBuffer()
|
|
initSync(buffer)
|
|
}
|