text-sanctifier 1.0.10 → 1.0.11
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/package.json +1 -1
- package/src/index.d.ts +50 -21
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -10,8 +10,11 @@ export interface SanctifyOptions {
|
|
|
10
10
|
/** Nuke hidden control characters (excluding whitespace like \n and \t) */
|
|
11
11
|
nukeControls?: boolean;
|
|
12
12
|
|
|
13
|
-
/** Remove emoji characters
|
|
13
|
+
/** Remove emoji characters */
|
|
14
14
|
purgeEmojis?: boolean;
|
|
15
|
+
|
|
16
|
+
/** Restrict to printable ASCII (+ emoji if `purgeEmojis` is false) */
|
|
17
|
+
keyboardOnlyFilter?: boolean;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
20
|
/** Preconfigured sanitizer function */
|
|
@@ -19,39 +22,65 @@ export type Sanctifier = (text: string) => string;
|
|
|
19
22
|
|
|
20
23
|
/**
|
|
21
24
|
* Summon a reusable text sanitizer.
|
|
22
|
-
*
|
|
23
|
-
* If `defaultOptions` is provided, it creates a sanitizer configured with human options.
|
|
24
25
|
*/
|
|
25
26
|
export function summonSanctifier(
|
|
26
27
|
defaultOptions?: SanctifyOptions,
|
|
27
28
|
): Sanctifier;
|
|
28
29
|
|
|
29
30
|
/**
|
|
30
|
-
*
|
|
31
|
-
* - Collapse
|
|
31
|
+
* Strict sanitizer preset:
|
|
32
|
+
* - Collapse spaces
|
|
32
33
|
* - Collapse all newlines
|
|
33
|
-
* -
|
|
34
|
-
* - Purge
|
|
34
|
+
* - Nuke control characters
|
|
35
|
+
* - Purge emojis
|
|
35
36
|
*/
|
|
36
|
-
export
|
|
37
|
+
export namespace summonSanctifier {
|
|
38
|
+
const strict: Sanctifier;
|
|
39
|
+
const loose: Sanctifier;
|
|
37
40
|
|
|
38
|
-
/**
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Keeps printable ASCII and emoji.
|
|
43
|
+
* Leaves spacing soft and preserves emoji.
|
|
44
|
+
*/
|
|
45
|
+
const keyboardOnlyEmoji: Sanctifier;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Keeps printable ASCII only.
|
|
49
|
+
* Collapses whitespace and purges emoji.
|
|
50
|
+
*/
|
|
51
|
+
const keyboardOnly: Sanctifier;
|
|
52
|
+
}
|
|
46
53
|
|
|
47
54
|
/**
|
|
48
55
|
* Brutally normalizes and cleans a string of text.
|
|
49
|
-
*
|
|
50
56
|
*/
|
|
51
57
|
export function sanctifyText(
|
|
52
58
|
text: string,
|
|
53
|
-
preserveParagraphs
|
|
54
|
-
collapseSpaces
|
|
55
|
-
nukeControls
|
|
56
|
-
purgeEmojis
|
|
59
|
+
preserveParagraphs?: boolean,
|
|
60
|
+
collapseSpaces?: boolean,
|
|
61
|
+
nukeControls?: boolean,
|
|
62
|
+
purgeEmojis?: boolean,
|
|
63
|
+
keyboardOnlyFilter?: boolean
|
|
57
64
|
): string;
|
|
65
|
+
|
|
66
|
+
/** Style of newline characters detected in a string */
|
|
67
|
+
export type NewlineStyle = 'LF' | 'CRLF' | 'CR' | 'Mixed' | null;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* A structural report of anomalies found in text.
|
|
71
|
+
*/
|
|
72
|
+
export interface UnicodeTrashReport {
|
|
73
|
+
hasControlChars: boolean;
|
|
74
|
+
hasInvisibleChars: boolean;
|
|
75
|
+
hasMixedNewlines: boolean;
|
|
76
|
+
newlineStyle: NewlineStyle;
|
|
77
|
+
hasEmojis: boolean;
|
|
78
|
+
hasNonKeyboardChars: boolean;
|
|
79
|
+
summary: string[];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Analyze a string and return a report of Unicode/control character issues,
|
|
84
|
+
* invisible characters, newline styles, emojis, and more.
|
|
85
|
+
*/
|
|
86
|
+
export function inspectText(text: string): UnicodeTrashReport;
|