aboutsummaryrefslogtreecommitdiff
path: root/api/yomikun.ts
blob: 696361fdb3459e2f7f872929b34e91ce8b5c4b29 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import Core from "../core/api.ts";
import RemoteCoreClient from "../core/http/client.ts";
import Sentence from "./sentence.ts";

export default class Yomikun {
	protected core: Core;
	public ready: Promise<void>;

	constructor(core?: Core) {
		this.core = core ?? new RemoteCoreClient();

		this.ready = new Promise(async resolve => {
			await this.core.ready;
			resolve();
		})
	}

	async sentence(input: string): Promise<Sentence> {
    var sentence = new Sentence(input).withParent(this);
		await sentence.ready;
		return sentence;
	}
}