-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.ts
48 lines (38 loc) · 1.18 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { IOptions } from "./src/types";
import { defaultOptions, persianGlyphs } from "./src/constants";
import preserve from "./src/steps/preserve";
import prefix from "./src/steps/prefix";
import wordLevelFix from "./src/steps/wordLevelFix";
import fix from "./src/steps/fix";
import restore from "./src/steps/restore";
import postfix from "./src/steps/postfix";
export function firast(
text: string,
options: Partial<IOptions> = defaultOptions,
): string {
// Complete options obj
const combinedOptions = { ...defaultOptions, ...options };
if (!text.trim()) {
return text;
}
text = " " + text + " ";
// --- START OF PRESERVE
text = preserve(combinedOptions, text);
// --- END OF PRESERVE
// --- START OF PRE-FIX
text = prefix(combinedOptions, text);
// --- END OF PRE-FIX
// --- START OF WORD-LEVEL-FIX
text = wordLevelFix(combinedOptions, text);
// --- END OF WORD-LEVEL-FIX
// --- START OF FIX
text = fix(combinedOptions, text);
// --- END OF FIX
// --- START OF RESTORE
text = restore(combinedOptions, text);
// --- END OF RESTORE
// --- START OF POST-FIX
text = postfix(combinedOptions, text);
// --- END OF POST-FIX
return text;
}