1 | "use strict";
|
2 |
|
3 |
|
4 |
|
5 | Object.defineProperty(exports, "__esModule", { value: true });
|
6 | exports.TableDictSynonymPanGu = void 0;
|
7 | const core_1 = require("./core");
|
8 |
|
9 |
|
10 |
|
11 | class TableDictSynonymPanGu extends core_1.default {
|
12 | constructor(type = TableDictSynonymPanGu.type, options = {}, ...argv) {
|
13 | super(type, options, ...argv);
|
14 | }
|
15 | add(data, skipExists) {
|
16 | if (!Array.isArray(data) || data.length != 2) {
|
17 | throw new TypeError(JSON.stringify(data));
|
18 | }
|
19 | data[0] = this._trim(data[0]);
|
20 | data[1] = this._trim(data[1]);
|
21 | if (!data[0]) {
|
22 | throw new TypeError(JSON.stringify(data));
|
23 | }
|
24 | if (skipExists && this.exists(data[0])) {
|
25 | return this;
|
26 | }
|
27 | this._add(data[0], data[1]);
|
28 | return this;
|
29 | }
|
30 | _add(n1, n2) {
|
31 | if (n1 !== n2) {
|
32 | this.TABLE[n1] = n2;
|
33 | }
|
34 | if (this.TABLE[n2] === n1) {
|
35 | delete this.TABLE[n2];
|
36 | }
|
37 | }
|
38 | _trim(s) {
|
39 | return s.replace(/^\s+|\s+$/g, '').trim();
|
40 | }
|
41 | }
|
42 | exports.TableDictSynonymPanGu = TableDictSynonymPanGu;
|
43 | TableDictSynonymPanGu.type = 'SYNONYM';
|
44 | exports.default = TableDictSynonymPanGu;
|
45 |
|
\ | No newline at end of file |