taraskevizer 1.4.2 → 1.4.3

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.cjs CHANGED
@@ -2084,6 +2084,7 @@ for (const word of gwords)
2084
2084
  wordlist.push([word, RegExp(word.replace(/ґ/g, "г"), "g")]);
2085
2085
 
2086
2086
  // src/tarask.ts
2087
+ var isObject = (arg) => typeof arg === "object";
2087
2088
  var isUpperCase = (str) => str === str.toUpperCase();
2088
2089
  var getLastLetter = (word) => {
2089
2090
  for (let i = word.length - 1; i > 0; i--)
@@ -2131,7 +2132,9 @@ var tagApplications = {
2131
2132
  };
2132
2133
  var taraskSync = (text, options) => {
2133
2134
  const { abc = 0, j = 0, html = false, nonHtml = false } = options || {};
2134
- if (typeof nonHtml === "object") {
2135
+ const isHtmlObject = isObject(html);
2136
+ const isNonHtmlObject = isObject(nonHtml);
2137
+ if (isNonHtmlObject) {
2135
2138
  nonHtml.variations || (nonHtml.variations = 0);
2136
2139
  }
2137
2140
  const apply = html ? tagApplications.html : tagApplications.nonHtml;
@@ -2157,17 +2160,17 @@ var taraskSync = (text, options) => {
2157
2160
  splitted = text.split(" ");
2158
2161
  if (abc !== ALPHABET.ARABIC)
2159
2162
  splitted = restoreCase(splitted, splittedOrig);
2160
- const nodeColors = nonHtml && nonHtml.nodeColors;
2163
+ const nodeColors = isNonHtmlObject && nonHtml.nodeColors;
2161
2164
  if (html || nodeColors)
2162
2165
  splitted = toTags(splitted, splittedOrig, abc, apply.F);
2163
2166
  text = splitted.join(" ").replace(/ /g, " ").replace(/ (\p{P}|\p{S}|\d|&#40) /gu, "$1");
2164
2167
  let gReplacer;
2165
2168
  if (html) {
2166
2169
  text = replaceWithDict(text, additionalReplacements[abc]);
2167
- if (abc === ALPHABET.CYRILLIC) {
2170
+ if (isHtmlObject && abc === ALPHABET.CYRILLIC) {
2168
2171
  gReplacer = html.g ? apply.H("$&") : ($0) => apply.H(gobj[$0]);
2169
2172
  }
2170
- } else if (nonHtml && abc === ALPHABET.CYRILLIC) {
2173
+ } else if (isNonHtmlObject && abc === ALPHABET.CYRILLIC) {
2171
2174
  if (nonHtml.nodeColors) {
2172
2175
  gReplacer = nonHtml.h ? ($0) => apply.H(gobj[$0]) : apply.H("$&");
2173
2176
  } else if (nonHtml.h) {
@@ -2297,7 +2300,7 @@ var finalizer = {
2297
2300
  return `<tarL data-l='${options}'>${main}</tarL>`;
2298
2301
  }).replace(/ \n /g, "<br>"),
2299
2302
  nonHtml(text, options) {
2300
- if (options && options.variations !== VARIATION.ALL) {
2303
+ if (isObject(options) && options.variations !== VARIATION.ALL) {
2301
2304
  const WORD_INDEX = options.variations;
2302
2305
  const replacer = ($0) => $0.slice(1, -1).split("|")[WORD_INDEX];
2303
2306
  text = text.replace(
package/dist/index.d.ts CHANGED
@@ -17,11 +17,11 @@ type TaraskOptionsStrict = {
17
17
  abc: Alphabet;
18
18
  j: J$1;
19
19
  } & ({
20
- html: HtmlOptions;
20
+ html: true | HtmlOptions;
21
21
  nonHtml: false;
22
22
  } | {
23
23
  html: false;
24
- nonHtml: NonHtmlOptions;
24
+ nonHtml: true | NonHtmlOptions;
25
25
  });
26
26
  type TaraskOptions = DeepPartial<TaraskOptionsStrict>;
27
27
  type Tarask = (text: string, options?: TaraskOptions) => string;
package/dist/index.js CHANGED
@@ -2054,6 +2054,7 @@ for (const word of gwords)
2054
2054
  wordlist.push([word, RegExp(word.replace(/ґ/g, "г"), "g")]);
2055
2055
 
2056
2056
  // src/tarask.ts
2057
+ var isObject = (arg) => typeof arg === "object";
2057
2058
  var isUpperCase = (str) => str === str.toUpperCase();
2058
2059
  var getLastLetter = (word) => {
2059
2060
  for (let i = word.length - 1; i > 0; i--)
@@ -2101,7 +2102,9 @@ var tagApplications = {
2101
2102
  };
2102
2103
  var taraskSync = (text, options) => {
2103
2104
  const { abc = 0, j = 0, html = false, nonHtml = false } = options || {};
2104
- if (typeof nonHtml === "object") {
2105
+ const isHtmlObject = isObject(html);
2106
+ const isNonHtmlObject = isObject(nonHtml);
2107
+ if (isNonHtmlObject) {
2105
2108
  nonHtml.variations || (nonHtml.variations = 0);
2106
2109
  }
2107
2110
  const apply = html ? tagApplications.html : tagApplications.nonHtml;
@@ -2127,17 +2130,17 @@ var taraskSync = (text, options) => {
2127
2130
  splitted = text.split(" ");
2128
2131
  if (abc !== ALPHABET.ARABIC)
2129
2132
  splitted = restoreCase(splitted, splittedOrig);
2130
- const nodeColors = nonHtml && nonHtml.nodeColors;
2133
+ const nodeColors = isNonHtmlObject && nonHtml.nodeColors;
2131
2134
  if (html || nodeColors)
2132
2135
  splitted = toTags(splitted, splittedOrig, abc, apply.F);
2133
2136
  text = splitted.join(" ").replace(/&nbsp;/g, " ").replace(/ (\p{P}|\p{S}|\d|&#40) /gu, "$1");
2134
2137
  let gReplacer;
2135
2138
  if (html) {
2136
2139
  text = replaceWithDict(text, additionalReplacements[abc]);
2137
- if (abc === ALPHABET.CYRILLIC) {
2140
+ if (isHtmlObject && abc === ALPHABET.CYRILLIC) {
2138
2141
  gReplacer = html.g ? apply.H("$&") : ($0) => apply.H(gobj[$0]);
2139
2142
  }
2140
- } else if (nonHtml && abc === ALPHABET.CYRILLIC) {
2143
+ } else if (isNonHtmlObject && abc === ALPHABET.CYRILLIC) {
2141
2144
  if (nonHtml.nodeColors) {
2142
2145
  gReplacer = nonHtml.h ? ($0) => apply.H(gobj[$0]) : apply.H("$&");
2143
2146
  } else if (nonHtml.h) {
@@ -2267,7 +2270,7 @@ var finalizer = {
2267
2270
  return `<tarL data-l='${options}'>${main}</tarL>`;
2268
2271
  }).replace(/ \n /g, "<br>"),
2269
2272
  nonHtml(text, options) {
2270
- if (options && options.variations !== VARIATION.ALL) {
2273
+ if (isObject(options) && options.variations !== VARIATION.ALL) {
2271
2274
  const WORD_INDEX = options.variations;
2272
2275
  const replacer = ($0) => $0.slice(1, -1).split("|")[WORD_INDEX];
2273
2276
  text = text.replace(
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "taraskevizer",
3
3
  "author": "GooseOb",
4
4
  "license": "MIT",
5
- "version": "1.4.2",
5
+ "version": "1.4.3",
6
6
  "private": false,
7
7
  "homepage": "https://gooseob.github.io/taraskevizatar/",
8
8
  "main": "dist/index.js",