-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.ts
49 lines (37 loc) · 1.42 KB
/
list.ts
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
48
49
/**
* Created by user on 2018/6/21/021.
*/
import { array_unique } from 'array-hyper-unique';
import { _word_zh_core } from 'regexp-cjk/lib/conv';
import { jp2zhs, jp2zht, zh2jp } from '../lib/jp/core';
import { charTableList, textList } from '../lib/zh/table/list';
import { cn2tw, tw2cn } from '../lib/zh/convert';
import libTable from '../lib/zh/table';
import { cn2tw_min, tw2cn_min } from '../lib/zh/convert/min';
import { zhRegExp } from 'regexp-cjk';
let word = `墻牆墙`;
word = array_unique(word.split('')).join('');
console.log(`zhRegExp\n`, new zhRegExp(word));
console.log(`zhRegExp Unicode\n`, new zhRegExp(word, 'u'));
console.log('charTableList\n', charTableList(word));
console.log('textList\n', textList(word));
console.log('libTable.auto\n', _table_each(word, libTable.auto));
console.log('libTable.tw\n', _table_each(word, libTable.tw));
console.log('libTable.cn\n', _table_each(word, libTable.cn));
console.log('libTable.jp\n', _table_each(word, libTable.jp));
console.log('cn2tw', cn2tw(word));
console.log('tw2cn', tw2cn(word));
console.log('cn2tw_min', cn2tw_min(word));
console.log('tw2cn_min', tw2cn_min(word));
console.log('jp2zht', jp2zht(word));
console.log('jp2zhs', jp2zhs(word));
console.log('zh2jp', zh2jp(word));
function _table_each(word: string, fn: (char: string) => string[])
{
return array_unique(word.split('')
.reduce(function (a, b)
{
a.push(...fn(b));
return a;
}, [] as string[]))
}