Interface: GukhanmunFactory

Factory interface satisfied by both @gukhanmun/wasm and @gukhanmun/napi.

Example

import { load } from "@gukhanmun/wasm";
import { stdictFst } from "@gukhanmun/stdict-fst";

const g = await load({
  preset: "ko-kr",
  dictionaries: [await stdictFst()],
});
console.log(g.convert("漢字를 한글로"));

Methods

load()

load(options?): Promise<Gukhanmun>

Loads and initialises a Gukhanmun converter with the given options.

In the WASM implementation this involves asynchronous .wasm binary initialisation; in the Node-API implementation the native addon is synchronously ready but still returns a Promise for API uniformity. Dictionary sources with URL or string data are fetched / read during this call.

Parameters

options?

GukhanmunOptions

Conversion options. All fields are optional; unset fields inherit defaults from the selected preset (or "ko-kr" when no preset is given).

Returns

Promise<Gukhanmun>

A ready-to-use Gukhanmun instance.

Throws

GukhanmunError when an option value is unrecognised (code: "invalid-input") or a dictionary fails to load (code: "dictionary-load").