taraskevizer 8.0.2 → 8.0.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/bin.js CHANGED
@@ -14,7 +14,7 @@ const printWithPrefix = (msg) => {
14
14
  process.argv.splice(0, 2);
15
15
  const checkForOptions = (options) => process.argv[0] && options.includes(process.argv[0].toLowerCase());
16
16
  if (checkForOptions(["-v", "--version"])) {
17
- printWithPrefix("8.0.2");
17
+ printWithPrefix("8.0.3");
18
18
  process.exit(0);
19
19
  }
20
20
  if (checkForOptions(["-h", "--help"])) {
package/dist/index.cjs CHANGED
@@ -2139,6 +2139,7 @@ __export(lib_exports, {
2139
2139
  dictFrom: () => dictFrom,
2140
2140
  highlightDiff: () => highlightDiff,
2141
2141
  htmlWrappers: () => htmlWrappers,
2142
+ mutatingStep: () => mutatingStep,
2142
2143
  replaceG: () => replaceG,
2143
2144
  replaceWithDict: () => replaceWithDict,
2144
2145
  restoreCase: () => restoreCase
@@ -2281,15 +2282,33 @@ var ansiColorWrappers = {
2281
2282
  variable: (content) => `\x1B[35m${content}\x1B[0m`
2282
2283
  };
2283
2284
 
2284
- // src/steps/convert-alphabet.ts
2285
- var convertAlphabet = (options) => {
2286
- const { lower, upper } = options.cfg.general.abc;
2287
- options.text = replaceWithDict(replaceWithDict(options.text, lower), upper);
2288
- };
2289
- var convertAlphabetLowerCase = (options) => {
2290
- options.text = replaceWithDict(options.text, options.cfg.general.abc.lower);
2285
+ // src/lib/mutating-step.ts
2286
+ var mutatingStep = (callback) => (options) => {
2287
+ options.text = callback(options);
2291
2288
  };
2292
2289
 
2290
+ // src/steps/convert-alphabet.ts
2291
+ var convertAlphabet = mutatingStep(
2292
+ ({
2293
+ text,
2294
+ cfg: {
2295
+ general: {
2296
+ abc: { upper, lower }
2297
+ }
2298
+ }
2299
+ }) => replaceWithDict(replaceWithDict(text, lower), upper)
2300
+ );
2301
+ var convertAlphabetLowerCase = mutatingStep(
2302
+ ({
2303
+ text,
2304
+ cfg: {
2305
+ general: {
2306
+ abc: { lower }
2307
+ }
2308
+ }
2309
+ }) => replaceWithDict(text, lower)
2310
+ );
2311
+
2293
2312
  // src/steps/highlight-diff.ts
2294
2313
  var highlightDiffStep = (highlight) => ({
2295
2314
  cfg: {
@@ -2327,9 +2346,9 @@ var replaceIbyJ = (options) => {
2327
2346
  };
2328
2347
 
2329
2348
  // src/steps/join-splitted.ts
2330
- var joinSplittedText = (options) => {
2331
- options.text = options.storage.textArr.join(" ");
2332
- };
2349
+ var joinSplittedText = mutatingStep(
2350
+ ({ storage: { textArr } }) => textArr.join(" ")
2351
+ );
2333
2352
 
2334
2353
  // src/steps/apply-g.ts
2335
2354
  var applyGHtml = (options) => {
@@ -2354,12 +2373,9 @@ var applyGNonHtml = (options) => {
2354
2373
  };
2355
2374
 
2356
2375
  // src/steps/apply-variations.ts
2357
- var applyVariableParts = (callback) => (options) => {
2358
- options.text = options.text.replace(
2359
- /\([^)]*?\)/g,
2360
- ($0) => callback($0.slice(1, -1).split("|"))
2361
- );
2362
- };
2376
+ var applyVariableParts = (callback) => mutatingStep(
2377
+ ({ text }) => text.replace(/\([^)]*?\)/g, ($0) => callback($0.slice(1, -1).split("|")))
2378
+ );
2363
2379
  var applyVariationsHtml = applyVariableParts((parts) => {
2364
2380
  const main = parts.shift();
2365
2381
  return `<tarL data-l='${parts}'>${main}</tarL>`;
@@ -2374,9 +2390,9 @@ var applyVariationsNonHtml = (options) => {
2374
2390
  };
2375
2391
 
2376
2392
  // src/steps/prepare.ts
2377
- var prepare = (options) => {
2378
- options.text = options.text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2379
- };
2393
+ var prepare = mutatingStep(
2394
+ ({ text }) => text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40")
2395
+ );
2380
2396
 
2381
2397
  // src/steps/resolve-syntax.ts
2382
2398
  var NOFIX_CHAR = "  ";
@@ -2386,77 +2402,76 @@ var applyNoFix = (options) => {
2386
2402
  if (noFixArr.length)
2387
2403
  options.text = options.text.replace(NOFIX_REGEX, () => noFixArr.shift());
2388
2404
  };
2389
- var resolveSpecialSyntax = (leftAngleBracket) => (options) => {
2390
- const {
2405
+ var resolveSpecialSyntax = (leftAngleBracket) => mutatingStep(
2406
+ ({
2391
2407
  text,
2392
2408
  storage,
2393
2409
  cfg: {
2394
2410
  general: { doEscapeCapitalized, abc }
2395
2411
  }
2396
- } = options;
2397
- const noFixArr = storage.noFixArr = [];
2398
- const convertAlphavet = (abcOnlyText, abc2) => restoreCase(
2399
- replaceWithDict(abcOnlyText.toLowerCase(), abc2.lower).split(" "),
2400
- abcOnlyText.split(" ")
2401
- ).join(" ");
2402
- const escapeCapsIfNeeded = (text2) => doEscapeCapitalized ? text2.replace(
2403
- new RegExp("(?!<=\\p{Lu} )\\p{Lu}{2}[\\p{Lu} ]*(?!= \\p{Lu})", "gu"),
2404
- ($0) => {
2405
- noFixArr.push(convertAlphavet($0, abc));
2406
- return NOFIX_CHAR;
2407
- }
2408
- ) : text2;
2409
- const parts = text.split(/(?=[<>])/g);
2410
- if (parts.length === 1) {
2411
- options.text = escapeCapsIfNeeded(text);
2412
- return;
2413
- }
2414
- let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
2415
- let depth = 0;
2416
- let currentPart = "";
2417
- for (const part of parts) {
2418
- if (part.startsWith("<")) {
2419
- ++depth;
2420
- currentPart += part;
2421
- } else if (depth) {
2422
- --depth;
2423
- if (depth) {
2412
+ }) => {
2413
+ const noFixArr = storage.noFixArr = [];
2414
+ const convertAlphavet = (abcOnlyText, abc2) => restoreCase(
2415
+ replaceWithDict(abcOnlyText.toLowerCase(), abc2.lower).split(" "),
2416
+ abcOnlyText.split(" ")
2417
+ ).join(" ");
2418
+ const escapeCapsIfNeeded = (text2) => doEscapeCapitalized ? text2.replace(
2419
+ new RegExp("(?!<=\\p{Lu} )\\p{Lu}{2}[\\p{Lu} ]*(?!= \\p{Lu})", "gu"),
2420
+ ($0) => {
2421
+ noFixArr.push(convertAlphavet($0, abc));
2422
+ return NOFIX_CHAR;
2423
+ }
2424
+ ) : text2;
2425
+ const parts = text.split(/(?=[<>])/g);
2426
+ if (parts.length === 1)
2427
+ return escapeCapsIfNeeded(text);
2428
+ let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
2429
+ let depth = 0;
2430
+ let currentPart = "";
2431
+ for (const part of parts) {
2432
+ if (part.startsWith("<")) {
2433
+ ++depth;
2424
2434
  currentPart += part;
2425
- } else {
2426
- let char = "";
2427
- const isAbc = currentPart[1] === "*";
2428
- if (isAbc) {
2429
- char = currentPart[2];
2430
- currentPart = convertAlphavet(
2431
- currentPart.slice(char === "," || char === "." ? 3 : 2),
2432
- abc
2433
- );
2435
+ } else if (depth) {
2436
+ --depth;
2437
+ if (depth) {
2438
+ currentPart += part;
2434
2439
  } else {
2435
- char = currentPart[1];
2436
- currentPart = currentPart.slice(2);
2437
- }
2438
- let toAddToResult;
2439
- switch (char) {
2440
- case ".":
2441
- toAddToResult = NOFIX_CHAR;
2442
- noFixArr.push(currentPart);
2443
- break;
2444
- case ",":
2445
- toAddToResult = leftAngleBracket + currentPart + ">";
2446
- break;
2447
- default:
2448
- toAddToResult = leftAngleBracket + NOFIX_CHAR;
2449
- noFixArr.push((isAbc ? "" : char) + currentPart + ">");
2440
+ let char = "";
2441
+ const isAbc = currentPart[1] === "*";
2442
+ if (isAbc) {
2443
+ char = currentPart[2];
2444
+ currentPart = convertAlphavet(
2445
+ currentPart.slice(char === "," || char === "." ? 3 : 2),
2446
+ abc
2447
+ );
2448
+ } else {
2449
+ char = currentPart[1];
2450
+ currentPart = currentPart.slice(2);
2451
+ }
2452
+ let toAddToResult;
2453
+ switch (char) {
2454
+ case ".":
2455
+ toAddToResult = NOFIX_CHAR;
2456
+ noFixArr.push(currentPart);
2457
+ break;
2458
+ case ",":
2459
+ toAddToResult = leftAngleBracket + currentPart + ">";
2460
+ break;
2461
+ default:
2462
+ toAddToResult = leftAngleBracket + NOFIX_CHAR;
2463
+ noFixArr.push((isAbc ? "" : char) + currentPart + ">");
2464
+ }
2465
+ result += toAddToResult + escapeCapsIfNeeded(part.slice(1));
2466
+ currentPart = "";
2450
2467
  }
2451
- result += toAddToResult + escapeCapsIfNeeded(part.slice(1));
2452
- currentPart = "";
2468
+ } else {
2469
+ result += escapeCapsIfNeeded(part);
2453
2470
  }
2454
- } else {
2455
- result += escapeCapsIfNeeded(part);
2456
2471
  }
2472
+ return result + escapeCapsIfNeeded(currentPart);
2457
2473
  }
2458
- options.text = result + escapeCapsIfNeeded(currentPart);
2459
- };
2474
+ );
2460
2475
 
2461
2476
  // src/steps/restore-case.ts
2462
2477
  var restoreCaseStep = ({
@@ -2500,8 +2515,7 @@ var storeSplittedText = ({
2500
2515
 
2501
2516
  // src/steps/taraskevize.ts
2502
2517
  var wordlistPlusNoSoften = wordlist.concat(noSoften);
2503
- var taraskevize = (options) => {
2504
- let { text } = options;
2518
+ var taraskevize = mutatingStep(({ text }) => {
2505
2519
  text = replaceWithDict(text, wordlistPlusNoSoften);
2506
2520
  softening:
2507
2521
  do {
@@ -2511,41 +2525,39 @@ var taraskevize = (options) => {
2511
2525
  continue softening;
2512
2526
  break;
2513
2527
  } while (true);
2514
- options.text = replaceWithDict(
2528
+ return replaceWithDict(
2515
2529
  text.replace(//g, "").replace(/не пра/g, "не&nbsp;пра"),
2516
2530
  afterTarask
2517
2531
  ).replace(/не&nbsp;пра/g, "не пра");
2518
- };
2532
+ });
2519
2533
 
2520
2534
  // src/steps/whitespaces.ts
2521
- var whitespacesToSpaces = (options) => {
2522
- const { storage } = options;
2523
- storage.spaces = [];
2524
- options.text = options.text.replace(/\s+/g, (match) => {
2525
- storage.spaces.push(match);
2526
- return " ";
2527
- });
2528
- };
2529
- var restoreWhitespaces = (options) => {
2530
- const { spaces } = options.storage;
2531
- spaces.reverse();
2532
- options.text = options.text.replace(/ /g, () => spaces.pop());
2533
- };
2535
+ var whitespacesToSpaces = mutatingStep(
2536
+ ({ text, storage }) => {
2537
+ storage.spaces = [];
2538
+ return text.replace(/\s+/g, (match) => {
2539
+ storage.spaces.push(match);
2540
+ return " ";
2541
+ });
2542
+ }
2543
+ );
2544
+ var restoreWhitespaces = mutatingStep(
2545
+ ({ text, storage: { spaces } }) => {
2546
+ spaces.reverse();
2547
+ return text.replace(/ /g, () => spaces.pop());
2548
+ }
2549
+ );
2534
2550
 
2535
2551
  // src/steps/trim.ts
2536
- var trim = (options) => {
2537
- options.text = ` ${options.text.trim()} `;
2538
- };
2552
+ var trim = mutatingStep(({ text }) => ` ${text.trim()} `);
2539
2553
 
2540
2554
  // src/steps/finalize.ts
2541
- var finalize = (newLine) => (options) => {
2542
- options.text = options.text.replace(/&#40/g, "(").replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+) ", "gu"), "$1").replace(/\n/g, newLine).trim();
2543
- };
2555
+ var finalize = (newLine) => mutatingStep(
2556
+ ({ text }) => text.replace(/&#40/g, "(").replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+) ", "gu"), "$1").replace(/\n/g, newLine).trim()
2557
+ );
2544
2558
 
2545
2559
  // src/steps/to-lower-case.ts
2546
- var toLowerCase = (options) => {
2547
- options.text = options.text.toLowerCase();
2548
- };
2560
+ var toLowerCase = mutatingStep(({ text }) => text.toLowerCase());
2549
2561
 
2550
2562
  // src/pipelines.ts
2551
2563
  var pipelines_exports = {};
package/dist/index.d.ts CHANGED
@@ -175,7 +175,7 @@ declare class TaraskConfig {
175
175
  nonHtml: NonHtmlOptions;
176
176
  }
177
177
 
178
- type TaraskStep<Storage = {}> = (args: {
178
+ type TaraskStep<Storage extends object = {}> = (args: {
179
179
  text: string;
180
180
  storage: Storage;
181
181
  cfg: TaraskConfig;
@@ -185,8 +185,8 @@ type SplittedTextStorage = {
185
185
  origArr: readonly string[];
186
186
  };
187
187
 
188
- declare const convertAlphabet: TaraskStep;
189
- declare const convertAlphabetLowerCase: TaraskStep;
188
+ declare const convertAlphabet: TaraskStep<{}>;
189
+ declare const convertAlphabetLowerCase: TaraskStep<{}>;
190
190
 
191
191
  /**
192
192
  * Uses {@link highlightDiff}
@@ -233,7 +233,7 @@ declare const applyVariationsNonHtml: TaraskStep;
233
233
  *
234
234
  * Some changes should be reverted in the {@link finalize} step.
235
235
  */
236
- declare const prepare: TaraskStep;
236
+ declare const prepare: TaraskStep<{}>;
237
237
 
238
238
  /**
239
239
  * Created in {@link resolveSpecialSyntax}.
@@ -265,7 +265,7 @@ declare const storeSplittedAbcConvertedOrig: TaraskStep<SplittedTextStorage>;
265
265
 
266
266
  declare const storeSplittedText: TaraskStep<SplittedTextStorage>;
267
267
 
268
- declare const taraskevize: TaraskStep;
268
+ declare const taraskevize: TaraskStep<{}>;
269
269
 
270
270
  /**
271
271
  * Created in {@link whitespacesToSpaces}.
@@ -288,7 +288,7 @@ declare const whitespacesToSpaces: TaraskStep<WhiteSpaceStorage>;
288
288
  */
289
289
  declare const restoreWhitespaces: TaraskStep<WhiteSpaceStorage>;
290
290
 
291
- declare const trim: TaraskStep;
291
+ declare const trim: TaraskStep<{}>;
292
292
 
293
293
  /**
294
294
  * @param newLine - The string to replace new lines with.
@@ -304,7 +304,7 @@ declare const trim: TaraskStep;
304
304
  */
305
305
  declare const finalize: (newLine: string) => TaraskStep;
306
306
 
307
- declare const toLowerCase: TaraskStep;
307
+ declare const toLowerCase: TaraskStep<{}>;
308
308
 
309
309
  /**
310
310
  * This module exports all the steps
@@ -321,7 +321,7 @@ declare const toLowerCase: TaraskStep;
321
321
 
322
322
  type index$1_SpecialSyntaxStorage = SpecialSyntaxStorage;
323
323
  type index$1_SplittedTextStorage = SplittedTextStorage;
324
- type index$1_TaraskStep<Storage = {}> = TaraskStep<Storage>;
324
+ type index$1_TaraskStep<Storage extends object = {}> = TaraskStep<Storage>;
325
325
  type index$1_WhiteSpaceStorage = WhiteSpaceStorage;
326
326
  declare const index$1_applyGHtml: typeof applyGHtml;
327
327
  declare const index$1_applyGNonHtml: typeof applyGNonHtml;
@@ -421,6 +421,14 @@ declare const ansiColorWrappers: {
421
421
  variable: (content: string) => string;
422
422
  };
423
423
 
424
+ /**
425
+ * An abstraction for a step that always changes the text.
426
+ *
427
+ * > Not recommended to use if
428
+ * a step doesn't ALWAYS change the text.
429
+ */
430
+ declare const mutatingStep: <T extends object = {}>(callback: (...args: Parameters<TaraskStep<T>>) => string) => TaraskStep<T>;
431
+
424
432
  /**
425
433
  * Collection of functions that help to work with dictionaries.
426
434
  */
@@ -438,11 +446,12 @@ declare const index_ansiColorWrappers: typeof ansiColorWrappers;
438
446
  declare const index_dictFrom: typeof dictFrom;
439
447
  declare const index_highlightDiff: typeof highlightDiff;
440
448
  declare const index_htmlWrappers: typeof htmlWrappers;
449
+ declare const index_mutatingStep: typeof mutatingStep;
441
450
  declare const index_replaceG: typeof replaceG;
442
451
  declare const index_replaceWithDict: typeof replaceWithDict;
443
452
  declare const index_restoreCase: typeof restoreCase;
444
453
  declare namespace index {
445
- export { type index_ExtendedDict as ExtendedDict, index_afterTarask as afterTarask, index_ansiColorWrappers as ansiColorWrappers, index_dictFrom as dictFrom, index_highlightDiff as highlightDiff, index_htmlWrappers as htmlWrappers, index_replaceG as replaceG, index_replaceWithDict as replaceWithDict, index_restoreCase as restoreCase };
454
+ export { type index_ExtendedDict as ExtendedDict, index_afterTarask as afterTarask, index_ansiColorWrappers as ansiColorWrappers, index_dictFrom as dictFrom, index_highlightDiff as highlightDiff, index_htmlWrappers as htmlWrappers, index_mutatingStep as mutatingStep, index_replaceG as replaceG, index_replaceWithDict as replaceWithDict, index_restoreCase as restoreCase };
446
455
  }
447
456
 
448
457
  export { type HtmlOptions, type NonHtmlOptions, REPLACE_J, TaraskConfig, type TaraskOptions, VARIATION, index$3 as dicts, index as lib, pipelines, index$1 as steps, tarask };
package/dist/index.js CHANGED
@@ -2112,6 +2112,7 @@ __export(lib_exports, {
2112
2112
  dictFrom: () => dictFrom,
2113
2113
  highlightDiff: () => highlightDiff,
2114
2114
  htmlWrappers: () => htmlWrappers,
2115
+ mutatingStep: () => mutatingStep,
2115
2116
  replaceG: () => replaceG,
2116
2117
  replaceWithDict: () => replaceWithDict,
2117
2118
  restoreCase: () => restoreCase
@@ -2254,15 +2255,33 @@ var ansiColorWrappers = {
2254
2255
  variable: (content) => `\x1B[35m${content}\x1B[0m`
2255
2256
  };
2256
2257
 
2257
- // src/steps/convert-alphabet.ts
2258
- var convertAlphabet = (options) => {
2259
- const { lower, upper } = options.cfg.general.abc;
2260
- options.text = replaceWithDict(replaceWithDict(options.text, lower), upper);
2261
- };
2262
- var convertAlphabetLowerCase = (options) => {
2263
- options.text = replaceWithDict(options.text, options.cfg.general.abc.lower);
2258
+ // src/lib/mutating-step.ts
2259
+ var mutatingStep = (callback) => (options) => {
2260
+ options.text = callback(options);
2264
2261
  };
2265
2262
 
2263
+ // src/steps/convert-alphabet.ts
2264
+ var convertAlphabet = mutatingStep(
2265
+ ({
2266
+ text,
2267
+ cfg: {
2268
+ general: {
2269
+ abc: { upper, lower }
2270
+ }
2271
+ }
2272
+ }) => replaceWithDict(replaceWithDict(text, lower), upper)
2273
+ );
2274
+ var convertAlphabetLowerCase = mutatingStep(
2275
+ ({
2276
+ text,
2277
+ cfg: {
2278
+ general: {
2279
+ abc: { lower }
2280
+ }
2281
+ }
2282
+ }) => replaceWithDict(text, lower)
2283
+ );
2284
+
2266
2285
  // src/steps/highlight-diff.ts
2267
2286
  var highlightDiffStep = (highlight) => ({
2268
2287
  cfg: {
@@ -2300,9 +2319,9 @@ var replaceIbyJ = (options) => {
2300
2319
  };
2301
2320
 
2302
2321
  // src/steps/join-splitted.ts
2303
- var joinSplittedText = (options) => {
2304
- options.text = options.storage.textArr.join(" ");
2305
- };
2322
+ var joinSplittedText = mutatingStep(
2323
+ ({ storage: { textArr } }) => textArr.join(" ")
2324
+ );
2306
2325
 
2307
2326
  // src/steps/apply-g.ts
2308
2327
  var applyGHtml = (options) => {
@@ -2327,12 +2346,9 @@ var applyGNonHtml = (options) => {
2327
2346
  };
2328
2347
 
2329
2348
  // src/steps/apply-variations.ts
2330
- var applyVariableParts = (callback) => (options) => {
2331
- options.text = options.text.replace(
2332
- /\([^)]*?\)/g,
2333
- ($0) => callback($0.slice(1, -1).split("|"))
2334
- );
2335
- };
2349
+ var applyVariableParts = (callback) => mutatingStep(
2350
+ ({ text }) => text.replace(/\([^)]*?\)/g, ($0) => callback($0.slice(1, -1).split("|")))
2351
+ );
2336
2352
  var applyVariationsHtml = applyVariableParts((parts) => {
2337
2353
  const main = parts.shift();
2338
2354
  return `<tarL data-l='${parts}'>${main}</tarL>`;
@@ -2347,9 +2363,9 @@ var applyVariationsNonHtml = (options) => {
2347
2363
  };
2348
2364
 
2349
2365
  // src/steps/prepare.ts
2350
- var prepare = (options) => {
2351
- options.text = options.text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40");
2352
- };
2366
+ var prepare = mutatingStep(
2367
+ ({ text }) => text.replace(/г'(?![еёіюя])/g, "ґ").replace(/ - /g, " — ").replace(new RegExp("(\\p{P}|\\p{S}|\\d+)", "gu"), " $1 ").replace(/ ['`’] (?=\S)/g, "ʼ").replace(/\(/g, "&#40")
2368
+ );
2353
2369
 
2354
2370
  // src/steps/resolve-syntax.ts
2355
2371
  var NOFIX_CHAR = "  ";
@@ -2359,77 +2375,76 @@ var applyNoFix = (options) => {
2359
2375
  if (noFixArr.length)
2360
2376
  options.text = options.text.replace(NOFIX_REGEX, () => noFixArr.shift());
2361
2377
  };
2362
- var resolveSpecialSyntax = (leftAngleBracket) => (options) => {
2363
- const {
2378
+ var resolveSpecialSyntax = (leftAngleBracket) => mutatingStep(
2379
+ ({
2364
2380
  text,
2365
2381
  storage,
2366
2382
  cfg: {
2367
2383
  general: { doEscapeCapitalized, abc }
2368
2384
  }
2369
- } = options;
2370
- const noFixArr = storage.noFixArr = [];
2371
- const convertAlphavet = (abcOnlyText, abc2) => restoreCase(
2372
- replaceWithDict(abcOnlyText.toLowerCase(), abc2.lower).split(" "),
2373
- abcOnlyText.split(" ")
2374
- ).join(" ");
2375
- const escapeCapsIfNeeded = (text2) => doEscapeCapitalized ? text2.replace(
2376
- new RegExp("(?!<=\\p{Lu} )\\p{Lu}{2}[\\p{Lu} ]*(?!= \\p{Lu})", "gu"),
2377
- ($0) => {
2378
- noFixArr.push(convertAlphavet($0, abc));
2379
- return NOFIX_CHAR;
2380
- }
2381
- ) : text2;
2382
- const parts = text.split(/(?=[<>])/g);
2383
- if (parts.length === 1) {
2384
- options.text = escapeCapsIfNeeded(text);
2385
- return;
2386
- }
2387
- let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
2388
- let depth = 0;
2389
- let currentPart = "";
2390
- for (const part of parts) {
2391
- if (part.startsWith("<")) {
2392
- ++depth;
2393
- currentPart += part;
2394
- } else if (depth) {
2395
- --depth;
2396
- if (depth) {
2385
+ }) => {
2386
+ const noFixArr = storage.noFixArr = [];
2387
+ const convertAlphavet = (abcOnlyText, abc2) => restoreCase(
2388
+ replaceWithDict(abcOnlyText.toLowerCase(), abc2.lower).split(" "),
2389
+ abcOnlyText.split(" ")
2390
+ ).join(" ");
2391
+ const escapeCapsIfNeeded = (text2) => doEscapeCapitalized ? text2.replace(
2392
+ new RegExp("(?!<=\\p{Lu} )\\p{Lu}{2}[\\p{Lu} ]*(?!= \\p{Lu})", "gu"),
2393
+ ($0) => {
2394
+ noFixArr.push(convertAlphavet($0, abc));
2395
+ return NOFIX_CHAR;
2396
+ }
2397
+ ) : text2;
2398
+ const parts = text.split(/(?=[<>])/g);
2399
+ if (parts.length === 1)
2400
+ return escapeCapsIfNeeded(text);
2401
+ let result = text.startsWith("<") ? "" : escapeCapsIfNeeded(parts.shift());
2402
+ let depth = 0;
2403
+ let currentPart = "";
2404
+ for (const part of parts) {
2405
+ if (part.startsWith("<")) {
2406
+ ++depth;
2397
2407
  currentPart += part;
2398
- } else {
2399
- let char = "";
2400
- const isAbc = currentPart[1] === "*";
2401
- if (isAbc) {
2402
- char = currentPart[2];
2403
- currentPart = convertAlphavet(
2404
- currentPart.slice(char === "," || char === "." ? 3 : 2),
2405
- abc
2406
- );
2408
+ } else if (depth) {
2409
+ --depth;
2410
+ if (depth) {
2411
+ currentPart += part;
2407
2412
  } else {
2408
- char = currentPart[1];
2409
- currentPart = currentPart.slice(2);
2410
- }
2411
- let toAddToResult;
2412
- switch (char) {
2413
- case ".":
2414
- toAddToResult = NOFIX_CHAR;
2415
- noFixArr.push(currentPart);
2416
- break;
2417
- case ",":
2418
- toAddToResult = leftAngleBracket + currentPart + ">";
2419
- break;
2420
- default:
2421
- toAddToResult = leftAngleBracket + NOFIX_CHAR;
2422
- noFixArr.push((isAbc ? "" : char) + currentPart + ">");
2413
+ let char = "";
2414
+ const isAbc = currentPart[1] === "*";
2415
+ if (isAbc) {
2416
+ char = currentPart[2];
2417
+ currentPart = convertAlphavet(
2418
+ currentPart.slice(char === "," || char === "." ? 3 : 2),
2419
+ abc
2420
+ );
2421
+ } else {
2422
+ char = currentPart[1];
2423
+ currentPart = currentPart.slice(2);
2424
+ }
2425
+ let toAddToResult;
2426
+ switch (char) {
2427
+ case ".":
2428
+ toAddToResult = NOFIX_CHAR;
2429
+ noFixArr.push(currentPart);
2430
+ break;
2431
+ case ",":
2432
+ toAddToResult = leftAngleBracket + currentPart + ">";
2433
+ break;
2434
+ default:
2435
+ toAddToResult = leftAngleBracket + NOFIX_CHAR;
2436
+ noFixArr.push((isAbc ? "" : char) + currentPart + ">");
2437
+ }
2438
+ result += toAddToResult + escapeCapsIfNeeded(part.slice(1));
2439
+ currentPart = "";
2423
2440
  }
2424
- result += toAddToResult + escapeCapsIfNeeded(part.slice(1));
2425
- currentPart = "";
2441
+ } else {
2442
+ result += escapeCapsIfNeeded(part);
2426
2443
  }
2427
- } else {
2428
- result += escapeCapsIfNeeded(part);
2429
2444
  }
2445
+ return result + escapeCapsIfNeeded(currentPart);
2430
2446
  }
2431
- options.text = result + escapeCapsIfNeeded(currentPart);
2432
- };
2447
+ );
2433
2448
 
2434
2449
  // src/steps/restore-case.ts
2435
2450
  var restoreCaseStep = ({
@@ -2473,8 +2488,7 @@ var storeSplittedText = ({
2473
2488
 
2474
2489
  // src/steps/taraskevize.ts
2475
2490
  var wordlistPlusNoSoften = wordlist.concat(noSoften);
2476
- var taraskevize = (options) => {
2477
- let { text } = options;
2491
+ var taraskevize = mutatingStep(({ text }) => {
2478
2492
  text = replaceWithDict(text, wordlistPlusNoSoften);
2479
2493
  softening:
2480
2494
  do {
@@ -2484,41 +2498,39 @@ var taraskevize = (options) => {
2484
2498
  continue softening;
2485
2499
  break;
2486
2500
  } while (true);
2487
- options.text = replaceWithDict(
2501
+ return replaceWithDict(
2488
2502
  text.replace(//g, "").replace(/не пра/g, "не&nbsp;пра"),
2489
2503
  afterTarask
2490
2504
  ).replace(/не&nbsp;пра/g, "не пра");
2491
- };
2505
+ });
2492
2506
 
2493
2507
  // src/steps/whitespaces.ts
2494
- var whitespacesToSpaces = (options) => {
2495
- const { storage } = options;
2496
- storage.spaces = [];
2497
- options.text = options.text.replace(/\s+/g, (match) => {
2498
- storage.spaces.push(match);
2499
- return " ";
2500
- });
2501
- };
2502
- var restoreWhitespaces = (options) => {
2503
- const { spaces } = options.storage;
2504
- spaces.reverse();
2505
- options.text = options.text.replace(/ /g, () => spaces.pop());
2506
- };
2508
+ var whitespacesToSpaces = mutatingStep(
2509
+ ({ text, storage }) => {
2510
+ storage.spaces = [];
2511
+ return text.replace(/\s+/g, (match) => {
2512
+ storage.spaces.push(match);
2513
+ return " ";
2514
+ });
2515
+ }
2516
+ );
2517
+ var restoreWhitespaces = mutatingStep(
2518
+ ({ text, storage: { spaces } }) => {
2519
+ spaces.reverse();
2520
+ return text.replace(/ /g, () => spaces.pop());
2521
+ }
2522
+ );
2507
2523
 
2508
2524
  // src/steps/trim.ts
2509
- var trim = (options) => {
2510
- options.text = ` ${options.text.trim()} `;
2511
- };
2525
+ var trim = mutatingStep(({ text }) => ` ${text.trim()} `);
2512
2526
 
2513
2527
  // src/steps/finalize.ts
2514
- var finalize = (newLine) => (options) => {
2515
- options.text = options.text.replace(/&#40/g, "(").replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+) ", "gu"), "$1").replace(/\n/g, newLine).trim();
2516
- };
2528
+ var finalize = (newLine) => mutatingStep(
2529
+ ({ text }) => text.replace(/&#40/g, "(").replace(/&nbsp;/g, " ").replace(new RegExp(" (\\p{P}|\\p{S}|\\d+) ", "gu"), "$1").replace(/\n/g, newLine).trim()
2530
+ );
2517
2531
 
2518
2532
  // src/steps/to-lower-case.ts
2519
- var toLowerCase = (options) => {
2520
- options.text = options.text.toLowerCase();
2521
- };
2533
+ var toLowerCase = mutatingStep(({ text }) => text.toLowerCase());
2522
2534
 
2523
2535
  // src/pipelines.ts
2524
2536
  var pipelines_exports = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taraskevizer",
3
- "version": "8.0.2",
3
+ "version": "8.0.3",
4
4
  "author": "GooseOb",
5
5
  "repository": {
6
6
  "type": "git",