taraskevizer 1.0.3 → 1.1.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/index.d.ts CHANGED
@@ -9,7 +9,7 @@ type TaraskOptions = {
9
9
  html: false | HtmlOptions;
10
10
  };
11
11
  type Promisify<T> = T extends (...args: infer TArgs) => infer TReturn ? (...args: TArgs) => Promise<TReturn> : never;
12
- type Tarask = (text: string, options: TaraskOptions) => string;
12
+ type Tarask = (text: string, options?: TaraskOptions) => string;
13
13
  type TaraskAsync = Promisify<Tarask>;
14
14
  type Dict = Record<string, RegExp>;
15
15
  type AlphabetDependentDict = {
package/dist/index.js CHANGED
@@ -1323,8 +1323,7 @@ var rawWordlist = {
1323
1323
  "($&|акмяны)": /акмяне(?= )/,
1324
1324
  "($&|аліта)": /аліўтс(?= )/,
1325
1325
  "($&|анікшты)": /анікшчэй(?= )/,
1326
- "($&|араны)": /варэны(?= )/,
1327
- " (варэн|аран)": / варэн/,
1326
+ " (варэ|ара)": / варэ(?=н(ы|а[мх]|амі) )/,
1328
1327
  // '($&|белая вака)':/балтайі воке(?= )/,
1329
1328
  "($&|біржы)": /біржай(?= )/,
1330
1329
  "($&|бірштаны)": /бірштанас(?= )/,
@@ -1996,7 +1995,8 @@ var additionalReplacements = {
1996
1995
  },
1997
1996
  [ARABIC]: {}
1998
1997
  };
1999
- var taraskSync = (text, { abc = 0, j = 0, html }) => {
1998
+ var taraskSync = (text, options) => {
1999
+ const { abc = 0, j = 0, html = false } = options || {};
2000
2000
  const noFix = [];
2001
2001
  const LEFT_ANGLE_BRACKET = html ? "&lt;" : "<";
2002
2002
  text = ` ${text.trim()} `.replace(/<([,.]?)((?:.|\s)*?)>/g, ($0, $1, $2) => {
@@ -2004,7 +2004,7 @@ var taraskSync = (text, { abc = 0, j = 0, html }) => {
2004
2004
  return LEFT_ANGLE_BRACKET + $2 + ">";
2005
2005
  noFix[noFix.length] = $1 === "." ? $2 : $0;
2006
2006
  return NOFIX_CHAR;
2007
- }).replace(/г'(?![еёіюя])/g, "ґ").replace(/(\n|\t)/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2007
+ }).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2008
2008
  let splittedOrig, splitted;
2009
2009
  splittedOrig = replaceWithDict(
2010
2010
  replaceWithDict(text, letters[abc]),
@@ -2096,8 +2096,10 @@ function toHtmlTags(text, orig, abc) {
2096
2096
  let fromOWordEnd = oWordEnd;
2097
2097
  while (wordH[fromStart] === oWord[fromStart])
2098
2098
  ++fromStart;
2099
- while (wordH[fromWordEnd] === oWord[fromOWordEnd])
2100
- --fromWordEnd, --fromOWordEnd;
2099
+ while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
2100
+ --fromWordEnd;
2101
+ --fromOWordEnd;
2102
+ }
2101
2103
  if (oWord.length < word.length) {
2102
2104
  if (fromOWordEnd === oWordEnd) {
2103
2105
  text[i] = `<tarF>${word}</tarF>`;
@@ -2129,7 +2131,7 @@ function toTarask(text) {
2129
2131
  ($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
2130
2132
  );
2131
2133
  }
2132
- function replaceWithDict(text, dict = null) {
2134
+ function replaceWithDict(text, dict = {}) {
2133
2135
  for (const key in dict)
2134
2136
  text = text.replace(dict[key], key);
2135
2137
  return text;
package/dist/index.mjs CHANGED
@@ -1296,8 +1296,7 @@ var rawWordlist = {
1296
1296
  "($&|акмяны)": /акмяне(?= )/,
1297
1297
  "($&|аліта)": /аліўтс(?= )/,
1298
1298
  "($&|анікшты)": /анікшчэй(?= )/,
1299
- "($&|араны)": /варэны(?= )/,
1300
- " (варэн|аран)": / варэн/,
1299
+ " (варэ|ара)": / варэ(?=н(ы|а[мх]|амі) )/,
1301
1300
  // '($&|белая вака)':/балтайі воке(?= )/,
1302
1301
  "($&|біржы)": /біржай(?= )/,
1303
1302
  "($&|бірштаны)": /бірштанас(?= )/,
@@ -1969,7 +1968,8 @@ var additionalReplacements = {
1969
1968
  },
1970
1969
  [ARABIC]: {}
1971
1970
  };
1972
- var taraskSync = (text, { abc = 0, j = 0, html }) => {
1971
+ var taraskSync = (text, options) => {
1972
+ const { abc = 0, j = 0, html = false } = options || {};
1973
1973
  const noFix = [];
1974
1974
  const LEFT_ANGLE_BRACKET = html ? "&lt;" : "<";
1975
1975
  text = ` ${text.trim()} `.replace(/<([,.]?)((?:.|\s)*?)>/g, ($0, $1, $2) => {
@@ -1977,7 +1977,7 @@ var taraskSync = (text, { abc = 0, j = 0, html }) => {
1977
1977
  return LEFT_ANGLE_BRACKET + $2 + ">";
1978
1978
  noFix[noFix.length] = $1 === "." ? $2 : $0;
1979
1979
  return NOFIX_CHAR;
1980
- }).replace(/г'(?![еёіюя])/g, "ґ").replace(/(\n|\t)/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
1980
+ }).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
1981
1981
  let splittedOrig, splitted;
1982
1982
  splittedOrig = replaceWithDict(
1983
1983
  replaceWithDict(text, letters[abc]),
@@ -2069,8 +2069,10 @@ function toHtmlTags(text, orig, abc) {
2069
2069
  let fromOWordEnd = oWordEnd;
2070
2070
  while (wordH[fromStart] === oWord[fromStart])
2071
2071
  ++fromStart;
2072
- while (wordH[fromWordEnd] === oWord[fromOWordEnd])
2073
- --fromWordEnd, --fromOWordEnd;
2072
+ while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
2073
+ --fromWordEnd;
2074
+ --fromOWordEnd;
2075
+ }
2074
2076
  if (oWord.length < word.length) {
2075
2077
  if (fromOWordEnd === oWordEnd) {
2076
2078
  text[i] = `<tarF>${word}</tarF>`;
@@ -2102,7 +2104,7 @@ function toTarask(text) {
2102
2104
  ($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
2103
2105
  );
2104
2106
  }
2105
- function replaceWithDict(text, dict = null) {
2107
+ function replaceWithDict(text, dict = {}) {
2106
2108
  for (const key in dict)
2107
2109
  text = text.replace(dict[key], key);
2108
2110
  return text;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "taraskevizer",
3
3
  "author": "GooseOb",
4
4
  "license": "MIT",
5
- "version": "1.0.3",
5
+ "version": "1.1.1",
6
6
  "private": false,
7
7
  "homepage": "https://gooseob.github.io/taraskevizatar/",
8
8
  "main": "dist/index.js",
@@ -14,6 +14,8 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "build": "tsup --config build-config/index.js",
17
+ "dev:build": "tsup --config build-config/dev.js && npm run test",
18
+ "test": "node test",
17
19
  "prepare": "husky install"
18
20
  },
19
21
  "repository": {
@@ -28,6 +30,7 @@
28
30
  "belarusian"
29
31
  ],
30
32
  "devDependencies": {
33
+ "@digitak/esrun": "^3.2.24",
31
34
  "husky": "^8.0.3",
32
35
  "prettier": "^3.0.0",
33
36
  "tsup": "^6.5.0",