taraskevizer 9.1.16 → 9.2.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/dist/bin.js CHANGED
@@ -7,7 +7,7 @@ const printWithPrefix = (msg) => {
7
7
  process.argv.splice(0, 2);
8
8
  const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
9
9
  if (checkForOptions(['-v', '--version'])) {
10
- printWithPrefix("9.1.16");
10
+ printWithPrefix("9.2.1");
11
11
  process.exit(0);
12
12
  }
13
13
  if (checkForOptions(['-h', '--help'])) {
@@ -1,2 +1,2 @@
1
- import type { ExtendedDict } from './types';
2
- export declare const endZSoftenAndNiaBiaz: ExtendedDict;
1
+ import type { Dict } from '../dict/types';
2
+ export declare const endZSoftenAndNiaBiaz: Dict;
@@ -1,18 +1,22 @@
1
- const prepositionPattern = /^(?:а[бд]?|б[ея]зь?|[дз]а|д?ля|дзеля|[нп]ад?|пр[аы]|празь?|у|церазь?)$/;
2
- const isSingleVowel = (str) => str.match(/[аеёіоуыэюя]/g)?.length === 1;
3
- const isFirstSyllabeStressed = (word) => /^[бвгджзйклмнпхрстфхцчшўьʼ]*.\u0301/.test(word);
4
1
  export const endZSoftenAndNiaBiaz = [
2
+ // / не (?=
3
+ // {зычны}*{сымбаль}{націск}
4
+ // |{зычны}*{галосны}{зычны}*{канец слова}
5
+ // )
6
+ // (?!{прыназоўнік})/
5
7
  [
6
- / бе(зь? \S+)/g,
7
- ($0, $1) => isFirstSyllabeStressed($1) || isSingleVowel($1) ? ' бя' + $1 : $0,
8
+ / не (?=[бвгджзйклмнпхрстфхцчшўьʼ]*.\u0301|[бвгджзйклмнпхрстфхцчшўьʼ]*[аеёіоуыэюя][бвгджзйклмнпхрстфхцчшўьʼ]* )(?!а[бд]?|б[ея]зь?|[дз]а|д?ля|дзеля|[нп]ад?|пр[аы]|празь?|у|церазь?)/g,
9
+ ' ня ',
8
10
  ],
11
+ // / без(?=ь? (?:
12
+ // {зычны}*{сымбаль}{націск}
13
+ // |{зычны}*{галосны}{зычны}*{канец слова}
14
+ // )/
9
15
  [
10
- / не (\S+)/g,
11
- ($0, $1) => isFirstSyllabeStressed($1) ||
12
- (isSingleVowel($1) && !prepositionPattern.test($1))
13
- ? ' ня ' + $1
14
- : $0,
16
+ / без(?=ь? (?:[бвгджзйклмнпхрстфхцчшўьʼ]*.\u0301|[бвгджзйклмнпхрстфхцчшўьʼ]*[аеёіоуыэюя][бвгджзйклмнпхрстфхцчшўьʼ]* ))/g,
17
+ ' бяз',
15
18
  ],
19
+
16
20
  [/ б[ея]з(?= і\S*[ая]ў|ну )/g, ' бязь'],
17
- [/( (?:пра|цера)?з)(?= і\S*[ая]ў|ну )/g, (_$0, $1) => $1 + 'ь'],
21
+ [/ (?:пра|цера)?з(?= і\S*[ая]ў|ну )/g, '$&ь'],
18
22
  ];
@@ -0,0 +1,3 @@
1
+ import type { ExtendedDict } from './types';
2
+ export declare const replaceWithDict: (text: string, dict: ExtendedDict, regex: RegExp) => string;
3
+ export declare const log: (...msgs: any[]) => any;
@@ -0,0 +1,17 @@
1
+ export const replaceWithDict = (text, dict, regex) => {
2
+ for (const item of dict) {
3
+ const [pattern, result] = item;
4
+ text = text.replace(pattern,
5
+ //@ts-ignore
6
+ result);
7
+ if (regex.test(text)) {
8
+ log('replaceWithDict:', item);
9
+ process.exit(1);
10
+ }
11
+ }
12
+ return text;
13
+ };
14
+ export const log = (...msgs) => {
15
+ console.log('[debug]', ...msgs);
16
+ return msgs[0];
17
+ };
@@ -4,8 +4,10 @@
4
4
  * Used in {@link untrim}.
5
5
  */
6
6
  export type TrimStorage = {
7
- beforeTrim: string;
8
- afterTrim: string;
7
+ trim: {
8
+ before: string;
9
+ after: string;
10
+ };
9
11
  };
10
12
  /**
11
13
  * Captures whitespaces around the text.
@@ -1,9 +1,11 @@
1
1
  import { mutatingStep } from '../lib/index.js';
2
2
 
3
3
  export const trim = mutatingStep(({ text, storage }) => {
4
- storage.beforeTrim = /^\s*/.exec(text)[0];
5
- storage.afterTrim = /\s*$/.exec(text)[0];
4
+ storage.trim = {
5
+ before: /^\s*/.exec(text)[0],
6
+ after: /\s*$/.exec(text)[0],
7
+ };
6
8
  return ` ${text.trim()} `;
7
9
  });
8
10
 
9
- export const untrim = mutatingStep(({ text, storage }) => storage.beforeTrim + text.trim() + storage.afterTrim);
11
+ export const untrim = mutatingStep(({ text, storage: { trim: { before, after }, }, }) => before + text.trim() + after);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taraskevizer",
3
- "version": "9.1.16",
3
+ "version": "9.2.1",
4
4
  "author": "GooseOb",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,12 +10,12 @@
10
10
  "module": "dist/index.js",
11
11
  "devDependencies": {
12
12
  "@digitak/esrun": "^3.2.26",
13
- "@types/node": "^20.16.1",
14
- "bun-types": "^1.1.26",
15
- "husky": "^9.1.5",
13
+ "@types/node": "^20.16.5",
14
+ "bun-types": "^1.1.27",
15
+ "husky": "^9.1.6",
16
16
  "prettier": "^3.3.3",
17
- "typedoc": "^0.25.13",
18
- "typescript": "^5.5.4"
17
+ "typedoc": "^0.26.7",
18
+ "typescript": "^5.6.2"
19
19
  },
20
20
  "bin": {
21
21
  "tarask": "dist/bin.js"
@@ -36,7 +36,7 @@
36
36
  "license": "MIT",
37
37
  "private": false,
38
38
  "scripts": {
39
- "build": "tsc --project src/tsconfig.json && bun ./afterbuild.js",
39
+ "build": "bun ./build.ts",
40
40
  "prettier": "prettier --write .",
41
41
  "dev": "esrun --watch=src/*,test/* --send-code-mode=temporaryFile test",
42
42
  "dev:bun": "bun test --watch",