feat(web): document the API

This commit is contained in:
Amaan Qureshi 2025-01-20 02:43:52 -05:00
parent a4b20c1c56
commit 09cb4c5729
17 changed files with 1155 additions and 198 deletions

View file

@ -1,7 +1,14 @@
import createModule, { type MainModule } from '../lib/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);
@ -9,6 +16,11 @@ export async function initializeBinding(moduleOptions?: EmscriptenModule): Promi
return Module;
}
/**
* @internal
*
* Checks if the Tree-sitter WASM module has been initialized.
*/
export function checkModule(): boolean {
return !!Module;
}