aboutsummaryrefslogtreecommitdiff
path: root/examples/furigana-html.ts
blob: fa599edf660c570073b1181d0efc60d2a8eb1251 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import Yomikun from "../api/yomikun.ts";
import DirectCoreClient from "../core/direct/client.ts";

// Create a direct (local) API instance
var api = new Yomikun(new DirectCoreClient());

// Explicitly wait until everything is ready (not required)
await api.ready;

// This sentence does not contain all information until it is explicitly
// fetched by the user. Each subclass instantiated from an API instance keeps a
// reference to that API instance for fetching additional data.
var sentence = await api.sentence("日本に来て一番驚いたことは自動販売機の多さだ。");

// Copy the sentence verbatim but add furigana to each word's kanji
var furigana = sentence.furigana("HTML");

console.log(furigana);