tree-sitter/lib/binding_web/src/bindings.ts

24 lines
681 B
TypeScript
Raw Normal View History

import createModule, { type MainModule } from '../lib/web-tree-sitter';
2025-01-20 02:43:52 -05:00
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { type Parser } from './parser';
export let Module: MainModule | null = null;
2025-01-20 02:43:52 -05:00
/**
* @internal
*
* Initialize the Tree-sitter Wasm module. This should only be called by the {@link Parser} class via {@link Parser.init}.
2025-01-20 02:43:52 -05:00
*/
export async function initializeBinding(moduleOptions?: Partial<EmscriptenModule>): Promise<MainModule> {
return Module ??= await createModule(moduleOptions);
}
2025-01-20 02:43:52 -05:00
/**
* @internal
*
* Checks if the Tree-sitter Wasm module has been initialized.
2025-01-20 02:43:52 -05:00
*/
export function checkModule(): boolean {
return !!Module;
}