-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
47 lines (36 loc) · 1.07 KB
/
test.js
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
37
38
39
40
41
42
43
44
45
46
47
async function go() {
const {emoji, bidi, script} = await require('.');
{
console.log("Emoji\n-----\n");
const str = 'hello 😀 heres a fam 👪 and a dog 🐕';
const segment = emoji(str);
let last = 0;
for (const {i, isEmoji} of segment) {
console.log(`${last}..${i-1} (${isEmoji}): ${str.slice(last, i)}`);
last = i;
}
}
console.log();
{
console.log("Bidi\n----\n");
const str = 'یہ ایک )car( ہے۔. Hebrew looks like אָלֶף־בֵּית עִבְרִי';
const segment = bidi(str);
let last = 0;
for (const {i, dir} of segment) {
console.log(`${last}..${i-1} (${dir}): ${str.slice(last, i)}`);
last = i;
}
}
console.log();
{
console.log("Script\n------\n");
const str = 'Latin is the most common. スクリプトが大好きです!ពួកគេទាំងអស់';
const segment = script(str);
let last = 0;
for (const {i, script} of segment) {
console.log(`${last}..${i-1} (${script}): ${str.slice(last, i)}`);
last = i;
}
}
}
go();