aboutsummaryrefslogtreecommitdiff
path: root/api/yomikun.ts
blob: 2b102fe8fc3aad054d1c9d5e9239786989687597 (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
25
26
27
28
29
30
31
32
33
34
35
36
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;
	protected user: string = "root";
	protected uid: number = 0;

	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).withAPI(this);
		await sentence.ready;
		return sentence;
	}

	public su(user: string) {
		this.user = user;
		// TODO: set this.uid
	}

	private async setTermPriority(expression: string, reading: string, priority: number) {
		this.core.user.termPriority(this.uid, expression, reading, priority);
	}
}