@oxyhq/core 10.1.3 → 10.1.4
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
CHANGED
|
@@ -43,30 +43,6 @@
|
|
|
43
43
|
* normalize whitespace and Unicode form.
|
|
44
44
|
*/
|
|
45
45
|
|
|
46
|
-
/**
|
|
47
|
-
* Characters that make a value ineligible for the zero-work fast path, and the
|
|
48
|
-
* whitespace shapes that a normalized INLINE value can never contain.
|
|
49
|
-
*
|
|
50
|
-
* A value that matches nothing here is, by construction, already normalized:
|
|
51
|
-
* it holds only printable ASCII (which is NFC-stable, so `normalize('NFC')`
|
|
52
|
-
* would be a no-op), its only whitespace is the plain space, it has no leading
|
|
53
|
-
* or trailing space, and no run of two spaces. Returning it untouched skips
|
|
54
|
-
* three string allocations — worth it because the common case in the feed
|
|
55
|
-
* hydration hot path is text that is already clean.
|
|
56
|
-
*
|
|
57
|
-
* Non-global (safe for repeated `.test()`; a global regex is stateful).
|
|
58
|
-
*/
|
|
59
|
-
const INLINE_NEEDS_NORMALIZATION = /[^\x20-\x7E]|^ | $| {2}/;
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Same idea as {@link INLINE_NEEDS_NORMALIZATION}, for MULTILINE values: `\n`
|
|
63
|
-
* joins the printable-ASCII fast-path alphabet, and the additional shapes a
|
|
64
|
-
* normalized body can never contain are a space adjacent to a line break — on
|
|
65
|
-
* either side, since every line is trimmed — and a run of three line breaks
|
|
66
|
-
* (more than one blank line).
|
|
67
|
-
*/
|
|
68
|
-
const MULTILINE_NEEDS_NORMALIZATION = /[^\x20-\x7E\n]|^[ \n]|[ \n]$| {2}| \n|\n |\n{3}/;
|
|
69
|
-
|
|
70
46
|
/** Any run of whitespace, including tabs, line breaks and Unicode spaces. */
|
|
71
47
|
const ANY_WHITESPACE_RUN = /\s+/g;
|
|
72
48
|
|
|
@@ -134,9 +110,6 @@ const EXCESS_BLANK_LINES = /\n{3,}/g;
|
|
|
134
110
|
* Idempotent: `f(f(x)) === f(x)`.
|
|
135
111
|
*/
|
|
136
112
|
export function normalizeInlineText(value: string): string {
|
|
137
|
-
if (!INLINE_NEEDS_NORMALIZATION.test(value)) {
|
|
138
|
-
return value;
|
|
139
|
-
}
|
|
140
113
|
return value.normalize('NFC').replace(ANY_WHITESPACE_RUN, ' ').trim();
|
|
141
114
|
}
|
|
142
115
|
|
|
@@ -173,9 +146,6 @@ export function normalizeInlineText(value: string): string {
|
|
|
173
146
|
* Idempotent: `f(f(x)) === f(x)`.
|
|
174
147
|
*/
|
|
175
148
|
export function normalizeMultilineText(value: string): string {
|
|
176
|
-
if (!MULTILINE_NEEDS_NORMALIZATION.test(value)) {
|
|
177
|
-
return value;
|
|
178
|
-
}
|
|
179
149
|
return value
|
|
180
150
|
.normalize('NFC')
|
|
181
151
|
.replace(LINE_BREAK_FORMS, '\n')
|