taraskevizer 1.0.3 → 1.1.0

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
@@ -1996,7 +1996,8 @@ var additionalReplacements = {
1996
1996
  },
1997
1997
  [ARABIC]: {}
1998
1998
  };
1999
- var taraskSync = (text, { abc = 0, j = 0, html }) => {
1999
+ var taraskSync = (text, options) => {
2000
+ const { abc = 0, j = 0, html = false } = options || {};
2000
2001
  const noFix = [];
2001
2002
  const LEFT_ANGLE_BRACKET = html ? "&lt;" : "<";
2002
2003
  text = ` ${text.trim()} `.replace(/<([,.]?)((?:.|\s)*?)>/g, ($0, $1, $2) => {
@@ -2004,7 +2005,7 @@ var taraskSync = (text, { abc = 0, j = 0, html }) => {
2004
2005
  return LEFT_ANGLE_BRACKET + $2 + ">";
2005
2006
  noFix[noFix.length] = $1 === "." ? $2 : $0;
2006
2007
  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");
2008
+ }).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2008
2009
  let splittedOrig, splitted;
2009
2010
  splittedOrig = replaceWithDict(
2010
2011
  replaceWithDict(text, letters[abc]),
@@ -2096,8 +2097,10 @@ function toHtmlTags(text, orig, abc) {
2096
2097
  let fromOWordEnd = oWordEnd;
2097
2098
  while (wordH[fromStart] === oWord[fromStart])
2098
2099
  ++fromStart;
2099
- while (wordH[fromWordEnd] === oWord[fromOWordEnd])
2100
- --fromWordEnd, --fromOWordEnd;
2100
+ while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
2101
+ --fromWordEnd;
2102
+ --fromOWordEnd;
2103
+ }
2101
2104
  if (oWord.length < word.length) {
2102
2105
  if (fromOWordEnd === oWordEnd) {
2103
2106
  text[i] = `<tarF>${word}</tarF>`;
@@ -2129,7 +2132,7 @@ function toTarask(text) {
2129
2132
  ($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
2130
2133
  );
2131
2134
  }
2132
- function replaceWithDict(text, dict = null) {
2135
+ function replaceWithDict(text, dict = {}) {
2133
2136
  for (const key in dict)
2134
2137
  text = text.replace(dict[key], key);
2135
2138
  return text;
package/dist/index.mjs CHANGED
@@ -1969,7 +1969,8 @@ var additionalReplacements = {
1969
1969
  },
1970
1970
  [ARABIC]: {}
1971
1971
  };
1972
- var taraskSync = (text, { abc = 0, j = 0, html }) => {
1972
+ var taraskSync = (text, options) => {
1973
+ const { abc = 0, j = 0, html = false } = options || {};
1973
1974
  const noFix = [];
1974
1975
  const LEFT_ANGLE_BRACKET = html ? "&lt;" : "<";
1975
1976
  text = ` ${text.trim()} `.replace(/<([,.]?)((?:.|\s)*?)>/g, ($0, $1, $2) => {
@@ -1977,7 +1978,7 @@ var taraskSync = (text, { abc = 0, j = 0, html }) => {
1977
1978
  return LEFT_ANGLE_BRACKET + $2 + ">";
1978
1979
  noFix[noFix.length] = $1 === "." ? $2 : $0;
1979
1980
  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");
1981
+ }).replace(/г'(?![еёіюя])/g, "ґ").replace(/([\n\t])/g, " $1 ").replace(/ - /g, " — ").replace(/(\p{P}|\p{S}|\d)/gu, " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
1981
1982
  let splittedOrig, splitted;
1982
1983
  splittedOrig = replaceWithDict(
1983
1984
  replaceWithDict(text, letters[abc]),
@@ -2069,8 +2070,10 @@ function toHtmlTags(text, orig, abc) {
2069
2070
  let fromOWordEnd = oWordEnd;
2070
2071
  while (wordH[fromStart] === oWord[fromStart])
2071
2072
  ++fromStart;
2072
- while (wordH[fromWordEnd] === oWord[fromOWordEnd])
2073
- --fromWordEnd, --fromOWordEnd;
2073
+ while (wordH[fromWordEnd] === oWord[fromOWordEnd]) {
2074
+ --fromWordEnd;
2075
+ --fromOWordEnd;
2076
+ }
2074
2077
  if (oWord.length < word.length) {
2075
2078
  if (fromOWordEnd === oWordEnd) {
2076
2079
  text[i] = `<tarF>${word}</tarF>`;
@@ -2102,7 +2105,7 @@ function toTarask(text) {
2102
2105
  ($0, $1, $2) => /([ая]ў|ну)$/.test($2) ? $1 + "ь і" + $2 : $0
2103
2106
  );
2104
2107
  }
2105
- function replaceWithDict(text, dict = null) {
2108
+ function replaceWithDict(text, dict = {}) {
2106
2109
  for (const key in dict)
2107
2110
  text = text.replace(dict[key], key);
2108
2111
  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.0",
6
6
  "private": false,
7
7
  "homepage": "https://gooseob.github.io/taraskevizatar/",
8
8
  "main": "dist/index.js",
@@ -14,6 +14,7 @@
14
14
  ],
15
15
  "scripts": {
16
16
  "build": "tsup --config build-config/index.js",
17
+ "test": "node test",
17
18
  "prepare": "husky install"
18
19
  },
19
20
  "repository": {
@@ -28,6 +29,7 @@
28
29
  "belarusian"
29
30
  ],
30
31
  "devDependencies": {
32
+ "@digitak/esrun": "^3.2.24",
31
33
  "husky": "^8.0.3",
32
34
  "prettier": "^3.0.0",
33
35
  "tsup": "^6.5.0",