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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.d.ts +50 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "text-sanctifier",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "type": "module",
5
5
  "description": "A brutal text normalizer and invisible trash scrubber for modern web projects.",
6
6
  "main": "./src/index.js",
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
- * Creates a strict sanitizer:
31
- * - Collapse multiple spaces
31
+ * Strict sanitizer preset:
32
+ * - Collapse spaces
32
33
  * - Collapse all newlines
33
- * - Purge control and invisible characters
34
- * - Purge emoji characters
34
+ * - Nuke control characters
35
+ * - Purge emojis
35
36
  */
36
- export function strict(): Sanctifier;
37
+ export namespace summonSanctifier {
38
+ const strict: Sanctifier;
39
+ const loose: Sanctifier;
37
40
 
38
- /**
39
- * Creates a loose sanitizer:
40
- * - Preserve paragraph breaks
41
- * - Collapse spaces
42
- * - Purge invisible characters (but leave control characters)
43
- * - Preserve emoji characters
44
- */
45
- export function loose(): Sanctifier;
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: boolean,
54
- collapseSpaces: boolean,
55
- nukeControls: boolean,
56
- purgeEmojis: boolean
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;