-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
min.ts
90 lines (75 loc) · 1.87 KB
/
min.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
/**
* Created by user on 2018/7/29/029.
*/
import tableTw2CnDebug = require('../../../build/zh/convert/table_tw2cn.debug.json');
import tableCn2TwDebug = require('../../../build/zh/convert/table_cn2tw.debug.json');
import {
defaultOptions,
getOptions,
getOptionsSkip,
IOptions,
ITable,
SAFE_MODE_CHAR as _SAFE_MODE_CHAR,
} from './core';
import { tw2cn, cn2tw } from './index';
import { array_unique } from 'array-hyper-unique';
export { tableTw2CnDebug, tableCn2TwDebug }
export const SAFE_MODE_CHAR_MIN = array_unique(_SAFE_MODE_CHAR
.slice()
.concat([
//'忧',
//'脏',
'划',
'准',
'发',
'処',
//'处',
'處',
//'憂',
//'優',
'餵',
'炮',
'砲',
'奸',
'姦',
'鱷',
'滷',
'鑑',
'發',
]))
;
export { SAFE_MODE_CHAR_MIN as SAFE_MODE_CHAR }
/**
* 以不造成歧異的字典表來取代
*/
export function tw2cn_min(text: string, options: IOptions = {}, ...argv)
{
options = fixOptions(options, tableTw2CnDebug.safe);
return tw2cn(text, options, ...argv);
}
/**
* 以不造成歧異的字典表來取代
*/
export function cn2tw_min(text: string, options: IOptions = {}, ...argv)
{
options = fixOptions(options, tableCn2TwDebug.safe);
return cn2tw(text, options, ...argv);
}
export function fixOptions(options: IOptions = {}, table: ITable)
{
options = Object.assign({}, options);
options.table = options.table || Object.create(table);
options.tableOnly = options.tableOnly !== false;
options = getOptions(options, defaultOptions, SAFE_MODE_CHAR_MIN);
return options;
}
/*
let msg = `并且之后在深海変異成亚种的半人鱼。顺便说一句,当时人鱼国的守护神《海之神》特里斯坦,发现在神代时代时被自己封印的宿敌复活了忧。`;
console.log(1, cn2tw(msg, {
safe: false,
}));
console.log(2, cn2tw_min(msg, {
//safe: false,
}));
*/
export default exports as typeof import('./min');