tree-sitter/lib/binding_web/src/bindings.ts
Amaan Qureshi a40265cbeb refactor(web): rename tree-sitter.js to web-tree-sitter.js
This is not breaking for consumers of the web bindings, nor the
playground as both filenames will be kept in the .github.io repo
2025-02-11 22:56:50 -05:00

26 lines
703 B
TypeScript

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