taraskevizer 6.1.19 → 7.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +25 -32
- package/dist/bin.js +18 -10
- package/dist/index.cjs +417 -232
- package/dist/index.d.ts +186 -32
- package/dist/index.js +409 -229
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,13 +21,21 @@ bun add taraskevizer
|
|
|
21
21
|
# Usage
|
|
22
22
|
|
|
23
23
|
```js
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
import {
|
|
25
|
+
tarask,
|
|
26
|
+
plainTextPipeline,
|
|
27
|
+
htmlPipeline,
|
|
28
|
+
abcOnlyPipeline,
|
|
29
|
+
TaraskConfig,
|
|
30
|
+
ALPHABET,
|
|
31
|
+
J,
|
|
32
|
+
VARIATION,
|
|
33
|
+
} from 'taraskevizer';
|
|
34
|
+
|
|
35
|
+
tarask('планета', plainTextPipeline);
|
|
28
36
|
// "плянэта"
|
|
29
37
|
|
|
30
|
-
const
|
|
38
|
+
const cfg = new TaraskConfig({
|
|
31
39
|
general: {
|
|
32
40
|
abc: ALPHABET.CYRILLIC,
|
|
33
41
|
j: J.ALWAYS,
|
|
@@ -38,10 +46,10 @@ const taraskevizer = new Taraskevizer({
|
|
|
38
46
|
h: false,
|
|
39
47
|
},
|
|
40
48
|
});
|
|
41
|
-
|
|
49
|
+
tarask('планета і Гродна', plainTextPipeline, cfg);
|
|
42
50
|
// "пл\x1b[32mя\x1b[0mн\x1b[32mэ\x1b[0mта \x1b[32mй\x1b[0m \x1b[35mГорадня\x1b[0m"
|
|
43
51
|
|
|
44
|
-
const
|
|
52
|
+
const cfg = new TaraskConfig({
|
|
45
53
|
general: {
|
|
46
54
|
abc: ALPHABET.LATIN,
|
|
47
55
|
},
|
|
@@ -49,21 +57,20 @@ const taraskevizer = new Taraskevizer({
|
|
|
49
57
|
g: false, // ignored, because alphabet is set to latin
|
|
50
58
|
},
|
|
51
59
|
});
|
|
52
|
-
|
|
60
|
+
tarask('энергія планеты', htmlPipeline, cfg);
|
|
53
61
|
// "en<tarF>erg</tarF>ija p<tarF>lan</tarF>ety"
|
|
54
62
|
|
|
55
|
-
|
|
56
|
-
taraskevizer.general.abc = ALPHABET.ARABIC;
|
|
57
|
-
taraskevizer.html.g = true;
|
|
58
|
-
|
|
59
|
-
const latinizerWithJi = new Taraskevizer({
|
|
63
|
+
const latinWithJiCfg = new TaraskConfig({
|
|
60
64
|
general: { abc: ALPHABET.LATIN_JI },
|
|
61
65
|
});
|
|
62
66
|
|
|
63
|
-
|
|
67
|
+
tarask('яна і іншыя', abcOnlyPipeline, latinWithJiCfg);
|
|
64
68
|
// "jana j jinšyja"
|
|
65
69
|
```
|
|
66
70
|
|
|
71
|
+
Explanation of pipeline steps and
|
|
72
|
+
how to create your own will come soon.
|
|
73
|
+
|
|
67
74
|
# Options
|
|
68
75
|
|
|
69
76
|
## general
|
|
@@ -72,16 +79,11 @@ Type: `object`
|
|
|
72
79
|
|
|
73
80
|
### abc
|
|
74
81
|
|
|
75
|
-
Type: `
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
Type: `object` with schema: `{lower: Dict, upper?: Dict}`,
|
|
83
|
+
where `Dict` is `[pattern: RegExp, result: string][]`
|
|
84
|
+
(may be empty)
|
|
78
85
|
|
|
79
|
-
|
|
80
|
-
| ----- | ----------------------- |
|
|
81
|
-
| 0 | cyrillic |
|
|
82
|
-
| 1 | latin |
|
|
83
|
-
| 2 | arabic |
|
|
84
|
-
| 3 | latin with ji |
|
|
86
|
+
Default value: `ALPHABET.CYRILLIC`
|
|
85
87
|
|
|
86
88
|
### j
|
|
87
89
|
|
|
@@ -108,15 +110,6 @@ If set to false, may cause unwanted changes in acronyms.
|
|
|
108
110
|
|
|
109
111
|
Is always `false` in `convertAlphabetOnly`.
|
|
110
112
|
|
|
111
|
-
### taraskevize
|
|
112
|
-
|
|
113
|
-
Type: `(text: string) => string`
|
|
114
|
-
|
|
115
|
-
Default value: internal function `taraskevize`
|
|
116
|
-
|
|
117
|
-
Overriddes internal function in order to change behaviour of taraskevization.
|
|
118
|
-
This function usually uses private api via `__tarask__`
|
|
119
|
-
|
|
120
113
|
## html
|
|
121
114
|
|
|
122
115
|
### g
|
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
ALPHABET,
|
|
4
|
+
REPLACE_J,
|
|
5
|
+
VARIATION,
|
|
6
|
+
TaraskConfig,
|
|
7
|
+
tarask,
|
|
8
|
+
abcOnlyPipeline,
|
|
9
|
+
htmlPipeline,
|
|
10
|
+
plainTextPipeline
|
|
11
|
+
} from "./index.js";
|
|
3
12
|
const prefix = "\x1B[34m[taraskevizer]\x1B[0m ";
|
|
4
13
|
const printWithPrefix = (msg) => {
|
|
5
14
|
process.stdout.write(prefix + msg + "\n");
|
|
@@ -7,7 +16,7 @@ const printWithPrefix = (msg) => {
|
|
|
7
16
|
process.argv.splice(0, 2);
|
|
8
17
|
const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
|
|
9
18
|
if (checkForOptions(["-v", "--version"])) {
|
|
10
|
-
printWithPrefix("
|
|
19
|
+
printWithPrefix("7.0.1");
|
|
11
20
|
process.exit(0);
|
|
12
21
|
}
|
|
13
22
|
if (checkForOptions(["-h", "--help"])) {
|
|
@@ -181,14 +190,13 @@ if (process.argv.length) {
|
|
|
181
190
|
}
|
|
182
191
|
text = Buffer.concat(chunks, length).toString();
|
|
183
192
|
}
|
|
184
|
-
const
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
)) {
|
|
193
|
+
const cfg = new TaraskConfig({ general, html, nonHtml });
|
|
194
|
+
const piplineByMode = {
|
|
195
|
+
nonHtml: plainTextPipeline,
|
|
196
|
+
html: htmlPipeline,
|
|
197
|
+
alphabetOnly: abcOnlyPipeline
|
|
198
|
+
};
|
|
199
|
+
if (process.stdout.write(tarask(text, piplineByMode[mode], cfg) + "\n")) {
|
|
192
200
|
process.exit(0);
|
|
193
201
|
} else {
|
|
194
202
|
process.stdout.once("drain", () => {
|