-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathshfmt_vite.js
More file actions
32 lines (26 loc) · 805 Bytes
/
shfmt_vite.js
File metadata and controls
32 lines (26 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* @ts-self-types="./shfmt_web.d.ts" */
import init from "./shfmt.wasm?init";
import { format as _format } from "./shfmt_binding.js";
let wasm, wasmModule;
function finalize_init(instance, module) {
wasm = instance.exports;
wasmModule = module;
wasm._initialize();
return wasm;
}
export default async function initAsync() {
if (wasm !== void 0) return wasm;
const instance = await init();
return finalize_init(instance);
}
export function initSync(module) {
if (wasm !== void 0) return wasm;
if (!(module instanceof WebAssembly.Module)) {
module = new WebAssembly.Module(module);
}
const instance = new WebAssembly.Instance(module, getImports());
return finalize_init(instance, module);
}
export function format(source, path, options) {
return _format(wasm, source, path, options);
}