taraskevizer 10.1.13 → 10.2.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/bin.js CHANGED
@@ -7,7 +7,7 @@ process.argv.splice(0, 2);
7
7
  const firstArg = process.argv[0];
8
8
  if (firstArg) {
9
9
  if (firstArg === '-v' || firstArg === '--version') {
10
- printWithPrefix("10.1.13");
10
+ printWithPrefix("10.2.0");
11
11
  process.exit(0);
12
12
  }
13
13
  if (firstArg === '-h' || firstArg === '--help') {
@@ -7,3 +7,4 @@ export * from './mutating-step';
7
7
  export * from './soften';
8
8
  export { callableDict, copyDict } from '@/dict/lib';
9
9
  export type * from './types';
10
+ export * from './pipe';
package/dist/lib/index.js CHANGED
@@ -6,3 +6,4 @@ export * from './restore-case.js';
6
6
  export * from './mutating-step.js';
7
7
  export * from './soften.js';
8
8
  export { callableDict, copyDict } from '../dict/lib.js';
9
+ export * from './pipe.js';
@@ -0,0 +1,11 @@
1
+ import type { DeepPartialReadonly } from '../types';
2
+ import type { TaraskStep } from '../steps';
3
+ import { TaraskConfig } from '../config';
4
+ export type Pipeline = {
5
+ (text: string, cfg?: DeepPartialReadonly<TaraskConfig>): string;
6
+ steps: TaraskStep<any>[];
7
+ };
8
+ /**
9
+ * Create a callable pipeline from steps.
10
+ */
11
+ export declare const pipe: (steps: TaraskStep<any>[]) => Pipeline;
@@ -0,0 +1,16 @@
1
+ import { TaraskConfig } from '../config.js';
2
+
3
+ export const pipe = (steps) => {
4
+ const fn = (text, cfg = new TaraskConfig()) => {
5
+ const ctx = {
6
+ text,
7
+ cfg: cfg instanceof TaraskConfig ? cfg : new TaraskConfig(cfg),
8
+ storage: {},
9
+ };
10
+ for (const step of fn.steps)
11
+ step(ctx);
12
+ return ctx.text;
13
+ };
14
+ fn.steps = steps;
15
+ return fn;
16
+ };
@@ -6,27 +6,17 @@
6
6
  * `pipeline.steps.map` if you need replacing only or
7
7
  * `pipeline.steps.flatMap` if you also need to add or remove steps.
8
8
  *
9
- * Then pass the result to {@link createPipeline}.
9
+ * Then pass the result to {@link pipe}.
10
10
  *
11
11
  * This way you will depend less on the
12
12
  * internal order of the builtin pipeline steps.
13
13
  *
14
14
  * For cases when you need to replace only {@link steps.taraskevize} in {@link tarask}
15
- * and have better tree-shaking, you can use {@link _createPipeline}.
15
+ * and have better tree-shaking, you can use {@link _pipe}.
16
16
  *
17
17
  * @module
18
18
  */
19
- import { TaraskConfig } from './config';
20
19
  import { type TaraskStep } from './steps';
21
- import type { DeepPartialReadonly } from './types';
22
- export type Pipeline = {
23
- (text: string, cfg?: DeepPartialReadonly<TaraskConfig>): string;
24
- steps: TaraskStep<any>[];
25
- };
26
- /**
27
- * Create a callable pipeline from steps.
28
- */
29
- export declare const createPipeline: (steps: TaraskStep<any>[]) => Pipeline;
30
20
  /**
31
21
  * Pipeline for changing only the alphabet.
32
22
  *
@@ -34,7 +24,7 @@ export declare const createPipeline: (steps: TaraskStep<any>[]) => Pipeline;
34
24
  *
35
25
  * To see the full list of steps, check the source code.
36
26
  */
37
- export declare const alphabetic: Pipeline;
27
+ export declare const alphabetic: import("./lib").Pipeline;
38
28
  /**
39
29
  * For better tree-shaking instead of `Array.prototype.flatMap`
40
30
  *
@@ -42,13 +32,13 @@ export declare const alphabetic: Pipeline;
42
32
  *
43
33
  * @param subPipeline - Steps used instead of [{@link steps.taraskevize}].
44
34
  */
45
- export declare const _createPipeline: (subPipeline: TaraskStep<any>[]) => Pipeline;
35
+ export declare const _pipe: (subPipeline: TaraskStep<any>[]) => import("./lib").Pipeline;
46
36
  /**
47
37
  * Pipeline for taraskevizing.
48
38
  */
49
- export declare const tarask: Pipeline;
39
+ export declare const tarask: import("./lib").Pipeline;
50
40
  /**
51
41
  * Pipeline for phonetizing.
52
42
  * @alpha
53
43
  */
54
- export declare const phonetic: Pipeline;
44
+ export declare const phonetic: import("./lib").Pipeline;
package/dist/pipelines.js CHANGED
@@ -1,23 +1,8 @@
1
1
 
2
- import { TaraskConfig } from './config.js';
2
+ import { pipe } from './lib/index.js';
3
3
  import { highlightDiffStep, applyNoFix, convertAlphabet, convertAlphabetLowerCase, joinSplittedText, prepare, replaceIbyJ, resolveSpecialSyntax, restoreCaseStep, restoreWhitespaces, storeSplittedAbcConvertedOrig, storeSplittedText, taraskevize, phonetize, whitespacesToSpaces, trim, finalize, toLowerCase, iotacizeJi, untrim, applyG, applyVariations, } from './steps/index.js';
4
4
 
5
- export const createPipeline = (steps) => {
6
- const fn = (text, cfg = new TaraskConfig()) => {
7
- const ctx = {
8
- text,
9
- cfg: cfg instanceof TaraskConfig ? cfg : new TaraskConfig(cfg),
10
- storage: {},
11
- };
12
- for (const step of fn.steps)
13
- step(ctx);
14
- return ctx.text;
15
- };
16
- fn.steps = steps;
17
- return fn;
18
- };
19
-
20
- export const alphabetic = createPipeline([
5
+ export const alphabetic = pipe([
21
6
  (ctx) => {
22
7
  ctx.cfg = { ...ctx.cfg, doEscapeCapitalized: false };
23
8
  },
@@ -32,7 +17,7 @@ export const alphabetic = createPipeline([
32
17
  untrim,
33
18
  ]);
34
19
 
35
- export const _createPipeline = (subPipeline) => createPipeline([
20
+ export const _pipe = (subPipeline) => pipe([
36
21
  trim,
37
22
  resolveSpecialSyntax,
38
23
  prepare,
@@ -54,6 +39,6 @@ export const _createPipeline = (subPipeline) => createPipeline([
54
39
  untrim,
55
40
  ]);
56
41
 
57
- export const tarask = _createPipeline([taraskevize]);
42
+ export const tarask = _pipe([taraskevize]);
58
43
 
59
- export const phonetic = _createPipeline([phonetize, iotacizeJi]);
44
+ export const phonetic = _pipe([phonetize, iotacizeJi]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "taraskevizer",
3
- "version": "10.1.13",
3
+ "version": "10.2.0",
4
4
  "author": "GooseOb",
5
5
  "repository": {
6
6
  "type": "git",