@absoluteui/helpers 0.0.0-stage → 0.13.2
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/LICENSE +201 -0
- package/NOTICE +5 -0
- package/README.md +47 -2
- package/SECURITY.md +102 -0
- package/dist/array/compare.d.ts +8 -0
- package/dist/array/compare.js +2 -0
- package/dist/array/index.d.ts +328 -0
- package/dist/array/index.js +2 -0
- package/dist/array/tree.d.ts +48 -0
- package/dist/array/tree.js +2 -0
- package/dist/async/batch.d.ts +103 -0
- package/dist/async/batch.js +2 -0
- package/dist/async/concurrency.d.ts +92 -0
- package/dist/async/concurrency.js +2 -0
- package/dist/async/control.d.ts +77 -0
- package/dist/async/control.js +2 -0
- package/dist/async/index.d.ts +8 -0
- package/dist/async/index.js +2 -0
- package/dist/async/signal.d.ts +95 -0
- package/dist/async/signal.js +2 -0
- package/dist/boolean/index.d.ts +83 -0
- package/dist/boolean/index.js +2 -0
- package/dist/business-calendar/days.d.ts +397 -0
- package/dist/business-calendar/days.js +2 -0
- package/dist/business-calendar/describe.d.ts +45 -0
- package/dist/business-calendar/describe.js +2 -0
- package/dist/business-calendar/engine.d.ts +305 -0
- package/dist/business-calendar/engine.js +2 -0
- package/dist/business-calendar/hours.d.ts +96 -0
- package/dist/business-calendar/hours.js +2 -0
- package/dist/business-calendar/index.d.ts +29 -0
- package/dist/business-calendar/index.js +2 -0
- package/dist/business-calendar/internal.d.ts +44 -0
- package/dist/business-calendar/internal.js +2 -0
- package/dist/business-calendar/rules.d.ts +260 -0
- package/dist/business-calendar/rules.js +2 -0
- package/dist/color/index.d.ts +200 -0
- package/dist/color/index.js +2 -0
- package/dist/color/named.d.ts +4 -0
- package/dist/color/named.js +2 -0
- package/dist/compare/index.d.ts +186 -0
- package/dist/compare/index.js +2 -0
- package/dist/convert/index.d.ts +152 -0
- package/dist/convert/index.js +2 -0
- package/dist/csv/index.d.ts +6 -0
- package/dist/csv/index.js +2 -0
- package/dist/csv/parse.d.ts +85 -0
- package/dist/csv/parse.js +12 -0
- package/dist/csv/stringify.d.ts +48 -0
- package/dist/csv/stringify.js +5 -0
- package/dist/date/calendar.d.ts +339 -0
- package/dist/date/calendar.js +2 -0
- package/dist/date/format.d.ts +66 -0
- package/dist/date/format.js +2 -0
- package/dist/date/index.d.ts +26 -0
- package/dist/date/index.js +2 -0
- package/dist/date/intervals.d.ts +110 -0
- package/dist/date/intervals.js +2 -0
- package/dist/date/intl-cache.d.ts +10 -0
- package/dist/date/intl-cache.js +2 -0
- package/dist/date/locale.d.ts +58 -0
- package/dist/date/locale.js +2 -0
- package/dist/date/plain-date.d.ts +105 -0
- package/dist/date/plain-date.js +2 -0
- package/dist/date/plain-time.d.ts +121 -0
- package/dist/date/plain-time.js +2 -0
- package/dist/date/zone.d.ts +121 -0
- package/dist/date/zone.js +2 -0
- package/dist/decimal/index.d.ts +149 -0
- package/dist/decimal/index.js +2 -0
- package/dist/ds/avl.d.ts +50 -0
- package/dist/ds/avl.js +2 -0
- package/dist/ds/bitset.d.ts +46 -0
- package/dist/ds/bitset.js +2 -0
- package/dist/ds/bloom.d.ts +41 -0
- package/dist/ds/bloom.js +2 -0
- package/dist/ds/caches.d.ts +141 -0
- package/dist/ds/caches.js +2 -0
- package/dist/ds/disjoint-set.d.ts +38 -0
- package/dist/ds/disjoint-set.js +2 -0
- package/dist/ds/emitter.d.ts +53 -0
- package/dist/ds/emitter.js +2 -0
- package/dist/ds/graph.d.ts +84 -0
- package/dist/ds/graph.js +2 -0
- package/dist/ds/heap.d.ts +49 -0
- package/dist/ds/heap.js +2 -0
- package/dist/ds/index.d.ts +20 -0
- package/dist/ds/index.js +2 -0
- package/dist/ds/internal.d.ts +19 -0
- package/dist/ds/internal.js +2 -0
- package/dist/ds/interval-tree.d.ts +49 -0
- package/dist/ds/interval-tree.js +2 -0
- package/dist/ds/linked-list.d.ts +54 -0
- package/dist/ds/linked-list.js +2 -0
- package/dist/ds/maps.d.ts +89 -0
- package/dist/ds/maps.js +2 -0
- package/dist/ds/ring.d.ts +99 -0
- package/dist/ds/ring.js +2 -0
- package/dist/ds/sorted.d.ts +104 -0
- package/dist/ds/sorted.js +2 -0
- package/dist/ds/stack.d.ts +28 -0
- package/dist/ds/stack.js +2 -0
- package/dist/ds/trie.d.ts +84 -0
- package/dist/ds/trie.js +2 -0
- package/dist/duration/index.d.ts +146 -0
- package/dist/duration/index.js +2 -0
- package/dist/encoding/index.d.ts +144 -0
- package/dist/encoding/index.js +2 -0
- package/dist/error/index.d.ts +316 -0
- package/dist/error/index.js +2 -0
- package/dist/fn/index.d.ts +129 -0
- package/dist/fn/index.js +2 -0
- package/dist/fn/memo.d.ts +46 -0
- package/dist/fn/memo.js +2 -0
- package/dist/fn/timing.d.ts +64 -0
- package/dist/fn/timing.js +2 -0
- package/dist/http/headers.d.ts +160 -0
- package/dist/http/headers.js +2 -0
- package/dist/http/index.d.ts +10 -0
- package/dist/http/index.js +2 -0
- package/dist/http/problem.d.ts +37 -0
- package/dist/http/problem.js +2 -0
- package/dist/http/response.d.ts +43 -0
- package/dist/http/response.js +2 -0
- package/dist/http/status.d.ts +169 -0
- package/dist/http/status.js +2 -0
- package/dist/index.d.ts +34 -0
- package/dist/index.js +2 -0
- package/dist/internal/keys.d.ts +6 -0
- package/dist/internal/keys.js +2 -0
- package/dist/is/index.d.ts +219 -0
- package/dist/is/index.js +2 -0
- package/dist/json/index.d.ts +9 -0
- package/dist/json/index.js +2 -0
- package/dist/json/internal.d.ts +12 -0
- package/dist/json/internal.js +2 -0
- package/dist/json/ndjson.d.ts +28 -0
- package/dist/json/ndjson.js +4 -0
- package/dist/json/parse.d.ts +45 -0
- package/dist/json/parse.js +2 -0
- package/dist/json/patch.d.ts +62 -0
- package/dist/json/patch.js +2 -0
- package/dist/json/pointer.d.ts +43 -0
- package/dist/json/pointer.js +2 -0
- package/dist/json/stringify.d.ts +42 -0
- package/dist/json/stringify.js +2 -0
- package/dist/linq/enumerable.d.ts +208 -0
- package/dist/linq/enumerable.js +2 -0
- package/dist/linq/index.d.ts +6 -0
- package/dist/linq/index.js +2 -0
- package/dist/linq/operators.d.ts +503 -0
- package/dist/linq/operators.js +2 -0
- package/dist/number/core.d.ts +164 -0
- package/dist/number/core.js +2 -0
- package/dist/number/format.d.ts +80 -0
- package/dist/number/format.js +2 -0
- package/dist/number/index.d.ts +12 -0
- package/dist/number/index.js +2 -0
- package/dist/number/internal.d.ts +18 -0
- package/dist/number/internal.js +2 -0
- package/dist/number/parse.d.ts +45 -0
- package/dist/number/parse.js +2 -0
- package/dist/number/words.d.ts +19 -0
- package/dist/number/words.js +2 -0
- package/dist/object/basic.d.ts +130 -0
- package/dist/object/basic.js +2 -0
- package/dist/object/deep.d.ts +90 -0
- package/dist/object/deep.js +2 -0
- package/dist/object/diff.d.ts +57 -0
- package/dist/object/diff.js +2 -0
- package/dist/object/index.d.ts +8 -0
- package/dist/object/index.js +2 -0
- package/dist/object/internal.d.ts +21 -0
- package/dist/object/internal.js +2 -0
- package/dist/object/path.d.ts +17 -0
- package/dist/object/path.js +2 -0
- package/dist/random/core.d.ts +14 -0
- package/dist/random/core.js +2 -0
- package/dist/random/index.d.ts +167 -0
- package/dist/random/index.js +2 -0
- package/dist/random/seeded.d.ts +27 -0
- package/dist/random/seeded.js +2 -0
- package/dist/sanitize/index.d.ts +8 -0
- package/dist/sanitize/index.js +2 -0
- package/dist/sanitize/pii.d.ts +48 -0
- package/dist/sanitize/pii.js +2 -0
- package/dist/sanitize/records.d.ts +100 -0
- package/dist/sanitize/records.js +2 -0
- package/dist/sanitize/text.d.ts +101 -0
- package/dist/sanitize/text.js +2 -0
- package/dist/set/index.d.ts +162 -0
- package/dist/set/index.js +2 -0
- package/dist/stats/index.d.ts +190 -0
- package/dist/stats/index.js +2 -0
- package/dist/string/index.d.ts +494 -0
- package/dist/string/index.js +8 -0
- package/dist/string/internal.d.ts +33 -0
- package/dist/string/internal.js +2 -0
- package/dist/string/words.d.ts +14 -0
- package/dist/string/words.js +2 -0
- package/dist/timezone/index.d.ts +76 -0
- package/dist/timezone/index.js +2 -0
- package/dist/url/index.d.ts +178 -0
- package/dist/url/index.js +2 -0
- package/dist/validate/builders.d.ts +6 -0
- package/dist/validate/builders.js +2 -0
- package/dist/validate/formats.d.ts +237 -0
- package/dist/validate/formats.js +2 -0
- package/dist/validate/index.d.ts +13 -0
- package/dist/validate/index.js +2 -0
- package/dist/validate/schema.d.ts +220 -0
- package/dist/validate/schema.js +2 -0
- package/dist/zip/index.d.ts +8 -0
- package/dist/zip/index.js +2 -0
- package/dist/zip/internal.d.ts +69 -0
- package/dist/zip/internal.js +2 -0
- package/dist/zip/reader.d.ts +56 -0
- package/dist/zip/reader.js +2 -0
- package/dist/zip/writer.d.ts +65 -0
- package/dist/zip/writer.js +2 -0
- package/package.json +150 -4
|
@@ -0,0 +1,494 @@
|
|
|
1
|
+
export { splitWords } from './words.js';
|
|
2
|
+
export type { SplitWordsOptions } from './words.js';
|
|
3
|
+
/** Options for locale-sensitive helpers. Without `locale`, case mapping is locale-independent. */
|
|
4
|
+
export interface LocaleOptions {
|
|
5
|
+
readonly locale?: Intl.LocalesArgument;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `camelCase`. Acronyms are lowered (`XMLHttpRequest` -> `xmlHttpRequest`).
|
|
9
|
+
* @example
|
|
10
|
+
* camelCase('user_first-name'); // => 'userFirstName'
|
|
11
|
+
*/
|
|
12
|
+
export declare function camelCase(s: string, options?: LocaleOptions): string;
|
|
13
|
+
/**
|
|
14
|
+
* `PascalCase`.
|
|
15
|
+
* @example
|
|
16
|
+
* pascalCase('user first name'); // => 'UserFirstName'
|
|
17
|
+
*/
|
|
18
|
+
export declare function pascalCase(s: string, options?: LocaleOptions): string;
|
|
19
|
+
/**
|
|
20
|
+
* `kebab-case`.
|
|
21
|
+
* @example
|
|
22
|
+
* kebabCase('XMLHttpRequest'); // => 'xml-http-request'
|
|
23
|
+
*/
|
|
24
|
+
export declare function kebabCase(s: string, options?: LocaleOptions): string;
|
|
25
|
+
/**
|
|
26
|
+
* `snake_case`.
|
|
27
|
+
* @example
|
|
28
|
+
* snakeCase('userFirstName'); // => 'user_first_name'
|
|
29
|
+
*/
|
|
30
|
+
export declare function snakeCase(s: string, options?: LocaleOptions): string;
|
|
31
|
+
/**
|
|
32
|
+
* `dot.case`.
|
|
33
|
+
* @example
|
|
34
|
+
* dotCase('userFirstName'); // => 'user.first.name'
|
|
35
|
+
*/
|
|
36
|
+
export declare function dotCase(s: string, options?: LocaleOptions): string;
|
|
37
|
+
/**
|
|
38
|
+
* `CONSTANT_CASE`.
|
|
39
|
+
* @example
|
|
40
|
+
* constantCase('maxRetryCount'); // => 'MAX_RETRY_COUNT'
|
|
41
|
+
*/
|
|
42
|
+
export declare function constantCase(s: string, options?: LocaleOptions): string;
|
|
43
|
+
/**
|
|
44
|
+
* Common English minor words for `titleCase({ minorWords })`.
|
|
45
|
+
* @example
|
|
46
|
+
* titleCase('war and peace', { minorWords: ENGLISH_MINOR_WORDS }); // => 'War and Peace'
|
|
47
|
+
*/
|
|
48
|
+
export declare const ENGLISH_MINOR_WORDS: readonly string[];
|
|
49
|
+
export interface TitleCaseOptions extends LocaleOptions {
|
|
50
|
+
/** Words kept lowercase unless first or last (compared case-insensitively). Default none. */
|
|
51
|
+
readonly minorWords?: Iterable<string>;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `Title Case` from any identifier or phrase (words joined by spaces).
|
|
55
|
+
* @example
|
|
56
|
+
* titleCase('the_lord-of the rings', { minorWords: ENGLISH_MINOR_WORDS }); // => 'The Lord of the Rings'
|
|
57
|
+
*/
|
|
58
|
+
export declare function titleCase(s: string, options?: TitleCaseOptions): string;
|
|
59
|
+
/**
|
|
60
|
+
* `Sentence case` (first word capitalized, words joined by spaces).
|
|
61
|
+
* @example
|
|
62
|
+
* sentenceCase('userFirstName'); // => 'User first name'
|
|
63
|
+
*/
|
|
64
|
+
export declare function sentenceCase(s: string, options?: LocaleOptions): string;
|
|
65
|
+
export interface CapitalizeOptions extends LocaleOptions {
|
|
66
|
+
/** Lowercase the rest of the string. Default false. */
|
|
67
|
+
readonly lowerRest?: boolean;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Uppercases the first character (locale-aware: `{ locale: 'tr' }` maps `i` -> `İ`).
|
|
71
|
+
* @example
|
|
72
|
+
* capitalize('élan'); // => 'Élan'
|
|
73
|
+
*/
|
|
74
|
+
export declare function capitalize(s: string, options?: CapitalizeOptions): string;
|
|
75
|
+
/**
|
|
76
|
+
* Lowercases the first character.
|
|
77
|
+
* @example
|
|
78
|
+
* uncapitalize('Hello World'); // => 'hello World'
|
|
79
|
+
*/
|
|
80
|
+
export declare function uncapitalize(s: string, options?: LocaleOptions): string;
|
|
81
|
+
/**
|
|
82
|
+
* Removes Latin/Greek/Cyrillic diacritics (`é` -> `e`, `ł` -> `l`); vowel signs of other scripts are kept.
|
|
83
|
+
* @example
|
|
84
|
+
* removeDiacritics('Crème Brûlée, Łódź'); // => 'Creme Brulee, Lodz'
|
|
85
|
+
*/
|
|
86
|
+
export declare function removeDiacritics(s: string): string;
|
|
87
|
+
export interface SlugifyOptions extends LocaleOptions {
|
|
88
|
+
/** Default `-`. */
|
|
89
|
+
readonly separator?: string;
|
|
90
|
+
/** Default true. */
|
|
91
|
+
readonly lowercase?: boolean;
|
|
92
|
+
/** Keep only ASCII letters and digits. Default false (Unicode letters such as `東京` are kept). */
|
|
93
|
+
readonly ascii?: boolean;
|
|
94
|
+
/** Maximum length in code points; cuts at a separator when possible. */
|
|
95
|
+
readonly maxLength?: number;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* URL slug: NFKD, diacritics removed, locale-aware lowercasing, non-word runs to one separator.
|
|
99
|
+
* @example
|
|
100
|
+
* slugify('Crème Brûlée & Café!'); // => 'creme-brulee-cafe'
|
|
101
|
+
* slugify('İstanbul', { locale: 'tr' }); // => 'istanbul'
|
|
102
|
+
*/
|
|
103
|
+
export declare function slugify(s: string, options?: SlugifyOptions): string;
|
|
104
|
+
/**
|
|
105
|
+
* User-perceived characters (extended grapheme clusters via `Intl.Segmenter`, with a fallback).
|
|
106
|
+
* @example
|
|
107
|
+
* graphemes('👍🏽e\u0301'); // => ['👍🏽', 'e\u0301'] // 2 graphemes
|
|
108
|
+
*/
|
|
109
|
+
export declare function graphemes(s: string): string[];
|
|
110
|
+
/**
|
|
111
|
+
* Number of user-perceived characters.
|
|
112
|
+
* @example
|
|
113
|
+
* graphemeLength('👨\u200d👩\u200d👧'); // => 1
|
|
114
|
+
*/
|
|
115
|
+
export declare function graphemeLength(s: string): number;
|
|
116
|
+
/**
|
|
117
|
+
* Reverses by grapheme clusters, keeping emoji and combining marks intact.
|
|
118
|
+
* @example
|
|
119
|
+
* reverseGraphemes('ab👍🏽'); // => '👍🏽ba'
|
|
120
|
+
*/
|
|
121
|
+
export declare function reverseGraphemes(s: string): string;
|
|
122
|
+
/**
|
|
123
|
+
* Length in the given unit: `grapheme` (default), `codePoint`, or `codeUnit` (UTF-16).
|
|
124
|
+
* @example
|
|
125
|
+
* charCount('😀', { unit: 'codeUnit' }); // => 2
|
|
126
|
+
*/
|
|
127
|
+
export declare function charCount(s: string, options?: {
|
|
128
|
+
readonly unit?: 'grapheme' | 'codePoint' | 'codeUnit';
|
|
129
|
+
}): number;
|
|
130
|
+
export interface TruncateOptions {
|
|
131
|
+
/** Appended when truncated; counts toward `length`. Default `...`. */
|
|
132
|
+
readonly omission?: string;
|
|
133
|
+
/** Cut at the last whitespace before the limit when possible. Default false. */
|
|
134
|
+
readonly wordBoundary?: boolean;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Truncates to at most `length` grapheme clusters including the omission. Never splits emoji or accents.
|
|
138
|
+
* @example
|
|
139
|
+
* truncate('Hello wonderful world', 12, { wordBoundary: true }); // => 'Hello…'
|
|
140
|
+
* truncate('👍🏽👍🏽👍🏽', 2); // => '👍🏽…'
|
|
141
|
+
*/
|
|
142
|
+
export declare function truncate(s: string, length: number, options?: TruncateOptions): string;
|
|
143
|
+
/**
|
|
144
|
+
* Truncates in the middle, keeping the start and end (file names, IDs).
|
|
145
|
+
* @example
|
|
146
|
+
* truncateMiddle('annual-report-2026-final.pdf', 15); // => 'annual-…nal.pdf'
|
|
147
|
+
*/
|
|
148
|
+
export declare function truncateMiddle(s: string, length: number, options?: {
|
|
149
|
+
readonly omission?: string;
|
|
150
|
+
}): string;
|
|
151
|
+
/**
|
|
152
|
+
* Centers `s` in `width` grapheme columns with `fill`.
|
|
153
|
+
* @example
|
|
154
|
+
* center('ab', 6, '*'); // => '**ab**'
|
|
155
|
+
*/
|
|
156
|
+
export declare function center(s: string, width: number, fill?: string): string;
|
|
157
|
+
export interface MaskOptions {
|
|
158
|
+
/** Characters left visible at the start. Default 0. */
|
|
159
|
+
readonly visibleStart?: number;
|
|
160
|
+
/** Characters left visible at the end. Default 0. */
|
|
161
|
+
readonly visibleEnd?: number;
|
|
162
|
+
/** Default `*`. */
|
|
163
|
+
readonly maskChar?: string;
|
|
164
|
+
/** Characters kept as-is and not counted (for example `' -'` for formatted card numbers). */
|
|
165
|
+
readonly preserve?: string;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Masks all but the visible start/end characters (grapheme-safe). If the visible parts would
|
|
169
|
+
* reveal everything, everything is masked.
|
|
170
|
+
* @example
|
|
171
|
+
* mask('4111111111111111', { visibleEnd: 4 }); // => '••••••••••••1111'
|
|
172
|
+
* mask('4111 1111 1111 1111', { visibleEnd: 4, preserve: ' ' }); // => '•••• •••• •••• 1111'
|
|
173
|
+
*/
|
|
174
|
+
export declare function mask(s: string, options?: MaskOptions): string;
|
|
175
|
+
export interface MaskEmailOptions {
|
|
176
|
+
readonly maskChar?: string;
|
|
177
|
+
/** Visible characters at the start of the local part. Default 1. */
|
|
178
|
+
readonly visible?: number;
|
|
179
|
+
/** Also mask the domain name (the top-level domain stays). Default false. */
|
|
180
|
+
readonly maskDomain?: boolean;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Masks the local part of an email address.
|
|
184
|
+
* @example
|
|
185
|
+
* maskEmail('john.doe@example.com'); // => 'j•••••••@example.com'
|
|
186
|
+
* maskEmail('ann@example.com', { maskDomain: true }); // => 'a••@e••••••.com'
|
|
187
|
+
*/
|
|
188
|
+
export declare function maskEmail(email: string, options?: MaskEmailOptions): string;
|
|
189
|
+
/**
|
|
190
|
+
* Normalizes line endings (CRLF, CR, U+2028/9 -> LF), turns other whitespace (tabs, NBSP, thin spaces)
|
|
191
|
+
* into plain spaces, and drops BOM/zero-width spaces. Structure (runs, newlines) is kept.
|
|
192
|
+
* @example
|
|
193
|
+
* normalizeWhitespace('a\u00a0b\r\nc'); // => 'a b\nc'
|
|
194
|
+
*/
|
|
195
|
+
export declare function normalizeWhitespace(s: string): string;
|
|
196
|
+
/**
|
|
197
|
+
* Trims and collapses every whitespace run (including newlines) to one space.
|
|
198
|
+
* @example
|
|
199
|
+
* collapseWhitespace(' a \n\t b '); // => 'a b'
|
|
200
|
+
*/
|
|
201
|
+
export declare function collapseWhitespace(s: string): string;
|
|
202
|
+
export interface StripControlOptions {
|
|
203
|
+
/** Keep tab, LF and CR. Default true. */
|
|
204
|
+
readonly keepWhitespace?: boolean;
|
|
205
|
+
/** Also remove bidi embedding/override/isolate controls (Trojan Source). Default true. */
|
|
206
|
+
readonly stripBidi?: boolean;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Removes C0/C1 control characters and, by default, bidi override controls.
|
|
210
|
+
* @example
|
|
211
|
+
* stripControlChars('a\u0000b\u202ec\n'); // => 'abc\n'
|
|
212
|
+
*/
|
|
213
|
+
export declare function stripControlChars(s: string, options?: StripControlOptions): string;
|
|
214
|
+
/**
|
|
215
|
+
* Splits on LF, CRLF, CR, U+2028 and U+2029.
|
|
216
|
+
* @example
|
|
217
|
+
* splitLines('a\r\nb\nc'); // => ['a', 'b', 'c']
|
|
218
|
+
*/
|
|
219
|
+
export declare function splitLines(s: string): string[];
|
|
220
|
+
/**
|
|
221
|
+
* Prefixes each line with `indent` (a string or a number of spaces). Blank lines stay blank unless `indentEmpty`.
|
|
222
|
+
* @example
|
|
223
|
+
* indent('a\nb', 2); // => ' a\n b'
|
|
224
|
+
*/
|
|
225
|
+
export declare function indent(s: string, prefix?: string | number, options?: {
|
|
226
|
+
readonly indentEmpty?: boolean;
|
|
227
|
+
}): string;
|
|
228
|
+
/**
|
|
229
|
+
* Removes the longest common leading whitespace of non-blank lines.
|
|
230
|
+
* @example
|
|
231
|
+
* dedent(' a\n b'); // => 'a\n b'
|
|
232
|
+
*/
|
|
233
|
+
export declare function dedent(s: string): string;
|
|
234
|
+
export interface WrapTextOptions {
|
|
235
|
+
/** Break words longer than `width`. Default true. */
|
|
236
|
+
readonly breakWords?: boolean;
|
|
237
|
+
/** Line separator. Default `\n`. */
|
|
238
|
+
readonly newline?: string;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Greedy word wrap to `width` grapheme columns; existing line breaks are kept.
|
|
242
|
+
* @example
|
|
243
|
+
* wrapText('The quick brown fox', 10); // => 'The quick\nbrown fox'
|
|
244
|
+
*/
|
|
245
|
+
export declare function wrapText(s: string, width: number, options?: WrapTextOptions): string;
|
|
246
|
+
/**
|
|
247
|
+
* Word count using `Intl.Segmenter` word boundaries (works for scripts without spaces, such as Japanese).
|
|
248
|
+
* @example
|
|
249
|
+
* wordCount("Don't stop, it's 2026!"); // => 4
|
|
250
|
+
*/
|
|
251
|
+
export declare function wordCount(s: string, options?: LocaleOptions): number;
|
|
252
|
+
/**
|
|
253
|
+
* Counts occurrences of a literal substring (non-overlapping by default).
|
|
254
|
+
* @example
|
|
255
|
+
* countOccurrences('aaaa', 'aa'); // => 2
|
|
256
|
+
* countOccurrences('aaaa', 'aa', { overlapping: true }); // => 3
|
|
257
|
+
*/
|
|
258
|
+
export declare function countOccurrences(s: string, sub: string, options?: {
|
|
259
|
+
readonly overlapping?: boolean;
|
|
260
|
+
}): number;
|
|
261
|
+
/**
|
|
262
|
+
* Replaces every occurrence of a literal string; `$` patterns in `replacement` are not interpreted.
|
|
263
|
+
* @example
|
|
264
|
+
* replaceAllSafe('a.b.c', '.', '$&'); // => 'a$&b$&c'
|
|
265
|
+
*/
|
|
266
|
+
export declare function replaceAllSafe(s: string, search: string, replacement: string): string;
|
|
267
|
+
/**
|
|
268
|
+
* Text between the first `start` and the next `end`; `undefined` when either is missing.
|
|
269
|
+
* @example
|
|
270
|
+
* between('key=[value]', '[', ']'); // => 'value'
|
|
271
|
+
*/
|
|
272
|
+
export declare function between(s: string, start: string, end: string): string | undefined;
|
|
273
|
+
/**
|
|
274
|
+
* True when `s` starts with any prefix.
|
|
275
|
+
* @example
|
|
276
|
+
* startsWithAny('https://x', ['http://', 'https://']); // => true
|
|
277
|
+
*/
|
|
278
|
+
export declare function startsWithAny(s: string, prefixes: Iterable<string>): boolean;
|
|
279
|
+
/**
|
|
280
|
+
* True when `s` ends with any suffix.
|
|
281
|
+
* @example
|
|
282
|
+
* endsWithAny('photo.JPG'.toLowerCase(), ['.jpg', '.png']); // => true
|
|
283
|
+
*/
|
|
284
|
+
export declare function endsWithAny(s: string, suffixes: Iterable<string>): boolean;
|
|
285
|
+
export interface IgnoreCaseOptions extends LocaleOptions {
|
|
286
|
+
/** Also ignore accents (`é` = `e`). Default false. */
|
|
287
|
+
readonly ignoreAccents?: boolean;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Case-insensitive (optionally accent-insensitive) substring test with locale-aware case folding.
|
|
291
|
+
* @example
|
|
292
|
+
* containsIgnoreCase('Crème Brûlée', 'BRULEE', { ignoreAccents: true }); // => true
|
|
293
|
+
*/
|
|
294
|
+
export declare function containsIgnoreCase(haystack: string, needle: string, options?: IgnoreCaseOptions): boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Case-insensitive equality via `Intl.Collator` (sensitivity `accent`, or `base` with `ignoreAccents`).
|
|
297
|
+
* @example
|
|
298
|
+
* equalsIgnoreCase('Straße', 'STRASSE', { locale: 'de' }); // true where the collator treats ß as ss
|
|
299
|
+
*/
|
|
300
|
+
export declare function equalsIgnoreCase(a: string, b: string, options?: IgnoreCaseOptions): boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Case-insensitive locale comparison (-1, 0, 1) for sorting.
|
|
303
|
+
* @example
|
|
304
|
+
* ['b', 'A', 'a'].sort((x, y) => compareIgnoreCase(x, y)); // => ['A', 'a', 'b']
|
|
305
|
+
*/
|
|
306
|
+
export declare function compareIgnoreCase(a: string, b: string, options?: IgnoreCaseOptions): -1 | 0 | 1;
|
|
307
|
+
/**
|
|
308
|
+
* True for one or more Unicode letters (combining marks allowed after a letter).
|
|
309
|
+
* @example
|
|
310
|
+
* isAlpha('Ñandú'); // => true
|
|
311
|
+
*/
|
|
312
|
+
export declare function isAlpha(s: string): boolean;
|
|
313
|
+
/**
|
|
314
|
+
* True for one or more Unicode decimal digits (`\p{Nd}`, including non-Latin digits such as `٣`).
|
|
315
|
+
* @example
|
|
316
|
+
* isNumeric('0123'); // => true
|
|
317
|
+
* isNumeric('1.5'); // => false
|
|
318
|
+
*/
|
|
319
|
+
export declare function isNumeric(s: string): boolean;
|
|
320
|
+
/**
|
|
321
|
+
* True for one or more Unicode letters or decimal digits.
|
|
322
|
+
* @example
|
|
323
|
+
* isAlphanumeric('abc123'); // => true
|
|
324
|
+
*/
|
|
325
|
+
export declare function isAlphanumeric(s: string): boolean;
|
|
326
|
+
/**
|
|
327
|
+
* Code points of `s`.
|
|
328
|
+
* @example
|
|
329
|
+
* toCodePoints('a😀'); // => [97, 128512]
|
|
330
|
+
*/
|
|
331
|
+
export declare function toCodePoints(s: string): number[];
|
|
332
|
+
/**
|
|
333
|
+
* UTF-8 byte length without allocating (lone surrogates count as U+FFFD, 3 bytes).
|
|
334
|
+
* @example
|
|
335
|
+
* byteLengthUtf8('€'); // => 3
|
|
336
|
+
*/
|
|
337
|
+
export declare function byteLengthUtf8(s: string): number;
|
|
338
|
+
/**
|
|
339
|
+
* Escapes `& < > " '` for HTML text and attribute values. Not a sanitizer.
|
|
340
|
+
* @example
|
|
341
|
+
* escapeHtml('<a href="x">Tom & Jerry\'s</a>'); // => '<a href="x">Tom & Jerry's</a>'
|
|
342
|
+
*/
|
|
343
|
+
export declare function escapeHtml(s: string): string;
|
|
344
|
+
/**
|
|
345
|
+
* Decodes `& < > " ' ` and numeric references (`'`, `'`).
|
|
346
|
+
* Invalid code points become U+FFFD.
|
|
347
|
+
* @example
|
|
348
|
+
* unescapeHtml('Tom & Jerry's 😀'); // => "Tom & Jerry's 😀"
|
|
349
|
+
*/
|
|
350
|
+
export declare function unescapeHtml(s: string): string;
|
|
351
|
+
/**
|
|
352
|
+
* Escapes RegExp syntax characters so `s` matches literally (valid with and without the `u` flag).
|
|
353
|
+
* @example
|
|
354
|
+
* new RegExp(escapeRegExp('1+1=2?')).test('1+1=2?'); // => true
|
|
355
|
+
*/
|
|
356
|
+
export declare function escapeRegExp(s: string): string;
|
|
357
|
+
export interface TemplateOptions {
|
|
358
|
+
/** Missing or non-primitive values: `keep` the placeholder (default), use `empty` string, or throw (`error`). */
|
|
359
|
+
readonly missing?: 'keep' | 'empty' | 'error';
|
|
360
|
+
/** Applied to each substituted value (for example `escapeHtml`). */
|
|
361
|
+
readonly escape?: (value: string) => string;
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* Safe `{name}` / `{a.b}` interpolation: no code evaluation, own properties only, unsafe keys
|
|
365
|
+
* (`__proto__`, `constructor`, `prototype`) never resolve. `{{` and `}}` produce literal braces.
|
|
366
|
+
* Primitives are stringified, dates use ISO 8601; objects count as missing.
|
|
367
|
+
* @example
|
|
368
|
+
* template('Hello {user.name}, you have {count} tasks', { user: { name: 'Ann' }, count: 3 }); // => 'Hello Ann, you have 3 tasks'
|
|
369
|
+
*/
|
|
370
|
+
export declare function template(str: string, values: object, options?: TemplateOptions): string;
|
|
371
|
+
export interface DistanceOptions {
|
|
372
|
+
/** Stop early and return `maxDistance + 1` once the distance must exceed it. */
|
|
373
|
+
readonly maxDistance?: number;
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* Levenshtein distance over code points: O(n|m) time, O(min(n, m)) memory, optional early exit.
|
|
377
|
+
* @example
|
|
378
|
+
* levenshtein('kitten', 'sitting'); // => 3
|
|
379
|
+
* levenshtein('kitten', 'sitting', { maxDistance: 1 }); // => 2 // exceeded
|
|
380
|
+
*/
|
|
381
|
+
export declare function levenshtein(a: string, b: string, options?: DistanceOptions): number;
|
|
382
|
+
/**
|
|
383
|
+
* Damerau-Levenshtein (optimal string alignment): adjacent transpositions cost 1. O(min(n, m)) memory.
|
|
384
|
+
* @example
|
|
385
|
+
* damerauLevenshtein('ca', 'ac'); // => 1
|
|
386
|
+
*/
|
|
387
|
+
export declare function damerauLevenshtein(a: string, b: string, options?: DistanceOptions): number;
|
|
388
|
+
/**
|
|
389
|
+
* Normalized similarity 0-1 (1 - Levenshtein / longer length); two empty strings are 1.
|
|
390
|
+
* @example
|
|
391
|
+
* similarity('color', 'colour'); // => ≈ 0.833
|
|
392
|
+
*/
|
|
393
|
+
export declare function similarity(a: string, b: string, options?: IgnoreCaseOptions & {
|
|
394
|
+
readonly ignoreCase?: boolean;
|
|
395
|
+
}): number;
|
|
396
|
+
/** Half-open `[start, end)` UTF-16 range in the original text. */
|
|
397
|
+
export type TextRange = readonly [start: number, end: number];
|
|
398
|
+
export interface FuzzyMatch<T> {
|
|
399
|
+
readonly item: T;
|
|
400
|
+
/** Index of `item` in the input. */
|
|
401
|
+
readonly index: number;
|
|
402
|
+
/** 0-1: exact 1, prefix ~ 0.9, word-start ~ 0.8, substring ~ 0.7, scattered subsequence <= 0.6. */
|
|
403
|
+
readonly score: number;
|
|
404
|
+
/** Index into `keys` of the best-matching key (0 for string candidates). */
|
|
405
|
+
readonly key: number;
|
|
406
|
+
/** The matched text. */
|
|
407
|
+
readonly text: string;
|
|
408
|
+
/** Matched ranges in `text`, for `highlight`. */
|
|
409
|
+
readonly ranges: readonly TextRange[];
|
|
410
|
+
}
|
|
411
|
+
export type FuzzyKey<T> = ((item: T) => string | null | undefined) | {
|
|
412
|
+
[K in keyof T]: T[K] extends string | null | undefined ? K : never;
|
|
413
|
+
}[keyof T];
|
|
414
|
+
export interface FuzzyOptions<T> extends LocaleOptions {
|
|
415
|
+
/** Maximum results. Default unlimited. */
|
|
416
|
+
readonly limit?: number;
|
|
417
|
+
/** Minimum score (0-1). Default 0 (any match). */
|
|
418
|
+
readonly threshold?: number;
|
|
419
|
+
/** Text accessors for non-string candidates: property names or functions. */
|
|
420
|
+
readonly keys?: readonly FuzzyKey<T>[];
|
|
421
|
+
/** Ignore accents. Default true. */
|
|
422
|
+
readonly ignoreAccents?: boolean;
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Ranked fuzzy search: case- and accent-insensitive substring and subsequence matching with
|
|
426
|
+
* word-start and contiguity bonuses. Results carry `ranges` for accessible highlighting.
|
|
427
|
+
* Ties keep shorter texts first, then input order. An empty query returns every candidate with score 1.
|
|
428
|
+
* @example
|
|
429
|
+
* const [best] = fuzzyMatch('jsmi', ['John Smith', 'Jane Doe']);
|
|
430
|
+
* best?.item; // => 'John Smith'
|
|
431
|
+
* best?.ranges; // => [[0, 1], [5, 8]]
|
|
432
|
+
* const people = [{ name: 'Joanna Kay', email: 'jkay@x.io' }, { name: 'Ben Ross', email: 'ann.ross@x.io' }, { name: 'Cy Diaz', email: 'cy@x.io' }];
|
|
433
|
+
* fuzzyMatch('ann', people, { keys: ['name', (p) => p.email], limit: 5 }).map((m) => m.item.name); // => ['Ben Ross', 'Joanna Kay']
|
|
434
|
+
*/
|
|
435
|
+
export declare function fuzzyMatch<T>(query: string, candidates: readonly T[], options?: FuzzyOptions<T>): FuzzyMatch<T>[];
|
|
436
|
+
/** A piece of text and whether it matched, for rendering `<mark>` via `textContent` (no HTML). */
|
|
437
|
+
export interface HighlightSegment {
|
|
438
|
+
readonly text: string;
|
|
439
|
+
readonly match: boolean;
|
|
440
|
+
}
|
|
441
|
+
export interface HighlightOptions extends LocaleOptions {
|
|
442
|
+
/** Ignore accents when matching a query. Default true. */
|
|
443
|
+
readonly ignoreAccents?: boolean;
|
|
444
|
+
/** Highlight each whitespace-separated term of the query separately. Default false. */
|
|
445
|
+
readonly words?: boolean;
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Splits `text` into matched and unmatched segments for a query (case/accent-insensitive) or for
|
|
449
|
+
* explicit ranges (from `fuzzyMatch`). Render matches with `<mark>` using `textContent`.
|
|
450
|
+
* @example
|
|
451
|
+
* highlight('Crème brûlée', 'brulee'); // => [{ text: 'Crème ', match: false }, { text: 'brûlée', match: true }]
|
|
452
|
+
*/
|
|
453
|
+
export declare function highlight(text: string, query: string | readonly TextRange[], options?: HighlightOptions): HighlightSegment[];
|
|
454
|
+
/** Plural forms keyed by `Intl.PluralRules` category; `other` is required. */
|
|
455
|
+
export interface PluralForms {
|
|
456
|
+
readonly zero?: string;
|
|
457
|
+
readonly one?: string;
|
|
458
|
+
readonly two?: string;
|
|
459
|
+
readonly few?: string;
|
|
460
|
+
readonly many?: string;
|
|
461
|
+
readonly other: string;
|
|
462
|
+
}
|
|
463
|
+
/**
|
|
464
|
+
* Picks the plural form for `count` with `Intl.PluralRules` and replaces `{count}` with the
|
|
465
|
+
* locale-formatted number. An explicit `zero` form wins for 0 in every locale.
|
|
466
|
+
* @example
|
|
467
|
+
* pluralize(1, { one: '{count} file', other: '{count} files' }); // => '1 file'
|
|
468
|
+
* pluralize(3, { one: '{count} plik', few: '{count} pliki', many: '{count} plików', other: '{count} pliku' }, { locale: 'pl' }); // => '3 pliki'
|
|
469
|
+
*/
|
|
470
|
+
export declare function pluralize(count: number, forms: PluralForms, options?: LocaleOptions & {
|
|
471
|
+
readonly type?: Intl.PluralRuleType;
|
|
472
|
+
}): string;
|
|
473
|
+
export interface FormatListOptions extends LocaleOptions {
|
|
474
|
+
/** `conjunction` (and, default), `disjunction` (or), or `unit`. */
|
|
475
|
+
readonly type?: Intl.ListFormatType;
|
|
476
|
+
readonly style?: Intl.ListFormatStyle;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Locale-aware list with `Intl.ListFormat`.
|
|
480
|
+
* @example
|
|
481
|
+
* formatList(['red', 'green', 'blue']); // => 'red, green, and blue' // en
|
|
482
|
+
* formatList(['tea', 'coffee'], { type: 'disjunction' }); // => 'tea or coffee'
|
|
483
|
+
*/
|
|
484
|
+
export declare function formatList(items: Iterable<string>, options?: FormatListOptions): string;
|
|
485
|
+
/**
|
|
486
|
+
* Initials from a name (grapheme-safe, locale-aware uppercase). With more words than `max`, keeps
|
|
487
|
+
* the first `max - 1` and the last.
|
|
488
|
+
* @example
|
|
489
|
+
* initials('John Ronald Reuel Tolkien'); // => 'JT'
|
|
490
|
+
* initials('élodie durand'); // => 'ÉD'
|
|
491
|
+
*/
|
|
492
|
+
export declare function initials(name: string, options?: LocaleOptions & {
|
|
493
|
+
readonly max?: number;
|
|
494
|
+
}): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
import{ValidationError as $}from"../error/index.js";import{hasOwn as D,isUnsafeKey as U}from"../internal/keys.js";import{cached as C,fold as A,foldWithMap as R,graphemeArray as m,iterGraphemes as j,localeKey as L,lower as x,stripDiacritics as v,upper as M}from"./internal.js";import{splitWords as K}from"./words.js";import{splitWords as ue}from"./words.js";const G=/['\u2019]/gu;function w(t){return K(t).map(n=>n.replace(G,""))}function S(t,n){const e=String.fromCodePoint(t.codePointAt(0)??0);return M(e,n)+x(t.slice(e.length),n)}function pt(t,n={}){return w(t).map((e,r)=>r===0?x(e,n.locale):S(e,n.locale)).join("")}function dt(t,n={}){return w(t).map(e=>S(e,n.locale)).join("")}function T(t,n,e){return w(t).map(r=>x(r,e)).join(n)}function ht(t,n={}){return T(t,"-",n.locale)}function mt(t,n={}){return T(t,"_",n.locale)}function xt(t,n={}){return T(t,".",n.locale)}function yt(t,n={}){return w(t).map(e=>M(e,n.locale)).join("_")}const bt=["a","an","and","as","at","but","by","for","from","in","into","nor","of","on","or","over","per","the","to","up","via","vs","with"];function Ot(t,n={}){const{locale:e}=n,r=new Set;if(n.minorWords)for(const i of n.minorWords)r.add(x(i,e));const o=w(t);return o.map((i,s)=>{const l=x(i,e);return s>0&&s<o.length-1&&r.has(l)?l:S(i,e)}).join(" ")}function At(t,n={}){return w(t).map((e,r)=>r===0?S(e,n.locale):x(e,n.locale)).join(" ")}function wt(t,n={}){if(t==="")return t;const e=String.fromCodePoint(t.codePointAt(0)??0),r=t.slice(e.length);return M(e,n.locale)+(n.lowerRest===!0?x(r,n.locale):r)}function Ct(t,n={}){if(t==="")return t;const e=String.fromCodePoint(t.codePointAt(0)??0);return x(e,n.locale)+t.slice(e.length)}function Lt(t){return v(t)}const B={\u00DF:"ss","\u1E9E":"SS",\u00E6:"ae",\u00C6:"AE",\u0153:"oe",\u0152:"OE",\u00FE:"th",\u00DE:"TH",\u00F0:"d",\u00D0:"D",\u0131:"i"},V=/[\p{L}\p{N}]/u,X=/\p{M}/u;function Mt(t,n={}){const{separator:e="-",lowercase:r=!0,ascii:o=!1,maxLength:i,locale:s}=n;let l=r?x(t,s):t;l=Array.from(v(l,"NFKD"),u=>B[u]??u).join(""),r&&(l=x(l,s));let a=[],c=!1,f=!1;for(const u of l){if(u==="'"||u==="\u2019")continue;(V.test(u)||f&&X.test(u))&&(!o||u.charCodeAt(0)<128)?(c&&a.length&&a.push(e),c=!1,a.push(u),f=!0):(c=!0,f=!1)}if(i!==void 0&&i>=0){const u=Array.from(a.join(""));if(u.length>i){let g=u.slice(0,i).join("");const p=e?g.lastIndexOf(e):-1;for(!(e!==""&&u.slice(i).join("").startsWith(e))&&p>g.length/2&&(g=g.slice(0,p));e!==""&&g.endsWith(e);)g=g.slice(0,-e.length);a=[g]}}return a.join("")}function St(t){return m(t)}function z(t){let n=0;for(const e=j(t);e.next().done!==!0;)n++;return n}function It(t){return m(t).reverse().join("")}function W(t,n={}){const e=n.unit??"grapheme";if(e==="codeUnit")return t.length;if(e==="codePoint"){let r=0;for(const o=t[Symbol.iterator]();o.next().done!==!0;)r++;return r}return z(t)}const k=t=>/^\s+$/u.test(t),J=new Set([",",";",":","-","\u2013","\u2014"]);function Tt(t,n,e={}){const{omission:r="\u2026",wordBoundary:o=!1}=e,i=Math.max(0,Math.floor(n)),s=m(t,i+1);if(s.length<=i)return t;const l=m(r);if(l.length>=i)return l.slice(0,i).join("");let a=s.slice(0,i-l.length);if(o&&!k(s[a.length]??" ")){let c=a.length-1;for(;c>=0&&!k(a[c]??"");)c--;c>0&&(a=a.slice(0,c))}for(;a.length&&(k(a[a.length-1]??"")||J.has(a[a.length-1]??""));)a.pop();return a.join("")+r}function kt(t,n,e={}){const r=e.omission??"\u2026",o=Math.max(0,Math.floor(n)),i=m(t);if(i.length<=o)return t;const s=m(r);if(s.length>=o)return s.slice(0,o).join("");const l=o-s.length,a=Math.ceil(l/2),c=l-a;return i.slice(0,a).join("")+r+(c>0?i.slice(i.length-c).join(""):"")}function Rt(t,n,e=" "){const r=z(t),o=m(e);if(r>=n||o.length===0)return t;const i=a=>Array.from({length:a},(c,f)=>o[f%o.length]??" ").join(""),s=n-r,l=Math.floor(s/2);return i(l)+t+i(s-l)}function I(t,n={}){const{visibleStart:e=0,visibleEnd:r=0,maskChar:o="\u2022",preserve:i=""}=n,s=m(t),l=new Set(m(i)),a=[];s.forEach((g,p)=>{l.has(g)||a.push(p)});const c=Math.max(0,Math.floor(e)),f=Math.max(0,Math.floor(r)),u=new Set;if(c+f<a.length){for(let g=0;g<c;g++)u.add(a[g]??-1);for(let g=a.length-f;g<a.length;g++)u.add(a[g]??-1)}return s.map((g,p)=>l.has(g)||u.has(p)?g:o).join("")}function jt(t,n={}){const{maskChar:e="\u2022",visible:r=1,maskDomain:o=!1}=n,i=t.lastIndexOf("@");if(i<=0)return I(t,{maskChar:e});const s=I(t.slice(0,i),{visibleStart:r,maskChar:e});let l=t.slice(i+1);if(o){const a=l.lastIndexOf(".");l=a>0?I(l.slice(0,a),{visibleStart:1,maskChar:e})+l.slice(a):I(l,{visibleStart:1,maskChar:e})}return`${s}@${l}`}function vt(t){return t.replace(/\r\n?|[\u2028\u2029]/gu,`
|
|
3
|
+
`).replace(/[\u200b\ufeff]/gu,"").replace(/[^\S\n]/gu," ")}function zt(t){return t.trim().replace(/\s+/gu," ")}function Wt(t,n={}){const e=n.keepWhitespace??!0,r=n.stripBidi??!0;let o="";for(const i of t){const s=i.charCodeAt(0);(s<32||s>=127&&s<=159)&&!(e&&(s===9||s===10||s===13))||r&&(s>=8234&&s<=8238||s>=8294&&s<=8297)||(o+=i)}return o}function Q(t){return t.split(/\r\n|[\n\r\u2028\u2029]/u)}function Et(t,n=2,e={}){const r=typeof n=="number"?" ".repeat(Math.max(0,Math.floor(n))):n;return t.split(`
|
|
4
|
+
`).map(o=>o.trim()===""&&e.indentEmpty!==!0?o:r+o).join(`
|
|
5
|
+
`)}function Nt(t){const n=t.split(`
|
|
6
|
+
`);let e;for(const o of n){if(o.trim()==="")continue;let i=0;for(;i<o.length&&(o.charAt(i)===" "||o.charAt(i)===" ");)i++;const s=o.slice(0,i);if(e===void 0)e=s;else{let l=0;for(;l<e.length&&l<s.length&&e.charAt(l)===s.charAt(l);)l++;e=e.slice(0,l)}if(e==="")break}if(!e)return t;const r=e;return n.map(o=>o.startsWith(r)?o.slice(r.length):o.trimStart()).join(`
|
|
7
|
+
`)}function Ft(t,n,e={}){const{breakWords:r=!0,newline:o=`
|
|
8
|
+
`}=e,i=Math.max(1,Math.floor(n)),s=[];for(const l of Q(t)){const a=l.split(/\s+/u).filter(g=>g!=="");if(!a.length){s.push("");continue}let c=[],f=0;const u=()=>{s.push(c.join("")),c=[],f=0};for(const g of a){let p=m(g);if(f>0&&f+1+p.length>i&&u(),r)for(;p.length>i-(f>0?f+1:0)&&p.length>i;)f>0&&u(),s.push(p.slice(0,i).join("")),p=p.slice(i);p.length&&(f>0&&(c.push(" "),f++),c.push(p.join("")),f+=p.length)}f>0&&u()}return s.join(o)}const Y=new Map;function Pt(t,n={}){if(typeof Intl.Segmenter=="function"){const e=C(Y,L(n.locale),()=>new Intl.Segmenter(n.locale,{granularity:"word"}));let r=0;for(const o of e.segment(t))o.isWordLike===!0&&r++;return r}return t.match(/[\p{L}\p{N}]+(?:['\u2019][\p{L}\p{N}]+)*/gu)?.length??0}function _t(t,n,e={}){if(n==="")return 0;const r=e.overlapping===!0?1:n.length;let o=0;for(let i=t.indexOf(n);i>=0;i=t.indexOf(n,i+r))o++;return o}function Ht(t,n,e){return n===""?t:t.split(n).join(e)}function $t(t,n,e){const r=t.indexOf(n);if(r<0)return;const o=r+n.length,i=t.indexOf(e,o);return i<0?void 0:t.slice(o,i)}function Dt(t,n){for(const e of n)if(t.startsWith(e))return!0;return!1}function Ut(t,n){for(const e of n)if(t.endsWith(e))return!0;return!1}function Kt(t,n,e={}){const r=e.ignoreAccents===!0;return A(t.normalize("NFC"),e.locale,r).includes(A(n.normalize("NFC"),e.locale,r))}const Z=new Map;function E(t){const n=t.ignoreAccents===!0?"base":"accent";return C(Z,`${L(t.locale)}|${n}`,()=>new Intl.Collator(t.locale,{sensitivity:n}))}function Gt(t,n,e={}){return E(e).compare(t,n)===0}function Bt(t,n,e={}){const r=E(e).compare(t,n);return r<0?-1:r>0?1:0}function Vt(t){return/^(?:\p{L}\p{M}*)+$/u.test(t)}function Xt(t){return/^\p{Nd}+$/u.test(t)}function Jt(t){return/^(?:[\p{L}\p{Nd}]\p{M}*)+$/u.test(t)}function N(t){return Array.from(t,n=>n.codePointAt(0)??0)}function Qt(t){let n=0;for(let e=0;e<t.length;e++){const r=t.charCodeAt(e);r<128?n+=1:r<2048?n+=2:r>=55296&&r<=56319&&e+1<t.length&&(t.charCodeAt(e+1)&64512)===56320?(n+=4,e++):n+=3}return n}const q={"&":"&","<":"<",">":">",'"':""","'":"'"};function Yt(t){return t.replace(/[&<>"']/g,n=>q[n]??n)}const tt={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:"\xA0"};function Zt(t){return t.replace(/&(?:#(\d{1,7})|#x([\da-f]{1,6})|(amp|lt|gt|quot|apos|nbsp));/gi,(n,e,r,o)=>{if(o!==void 0)return tt[o.toLowerCase()]??n;const i=e!==void 0?Number.parseInt(e,10):Number.parseInt(r??"",16);return i===0||i>1114111||i>=55296&&i<=57343?"\uFFFD":String.fromCodePoint(i)})}function qt(t){return t.replace(/[$()*+./?[\\\]^{|}]/g,"\\$&")}function te(t,n,e={}){const{missing:r="keep",escape:o}=e;return t.replace(/\{\{|\}\}|\{\s*([\w$]+(?:\.[\w$]+)*)\s*\}/g,(i,s)=>{if(s===void 0)return i.charAt(0);let l=n;for(const c of s.split(".")){if(U(c)||typeof l!="object"||l===null||!D(l,c)){l=void 0;break}l=l[c]}let a;if(typeof l=="string"?a=l:typeof l=="number"||typeof l=="bigint"||typeof l=="boolean"?a=String(l):l instanceof Date&&!Number.isNaN(l.getTime())&&(a=l.toISOString()),a===void 0){if(r==="error")throw new $("HLP_STRING_TEMPLATE_MISSING","A template placeholder has no value.",{details:{key:s}});return r==="empty"?"":i}return o?o(a):a})}function F(t,n){let e=N(t),r=N(n),o=0;for(;o<e.length&&o<r.length&&e[o]===r[o];)o++;let i=e.length,s=r.length;for(;i>o&&s>o&&e[i-1]===r[s-1];)i--,s--;return e=e.slice(o,i),r=r.slice(o,s),e.length<r.length?[r,e]:[e,r]}function et(t,n,e={}){const r=e.maxDistance??1/0,[o,i]=F(t,n);if(o.length-i.length>r)return r+1;if(i.length===0)return o.length>r?r+1:o.length;const s=new Uint32Array(i.length+1);for(let a=0;a<=i.length;a++)s[a]=a;for(let a=1;a<=o.length;a++){let c=s[0]??0;s[0]=a;let f=a;const u=o[a-1];for(let g=1;g<=i.length;g++){const p=s[g]??0,d=u===i[g-1]?0:1,h=Math.min(p+1,(s[g-1]??0)+1,c+d);s[g]=h,c=p,h<f&&(f=h)}if(f>r)return r+1}const l=s[i.length]??0;return l>r?r+1:l}function ee(t,n,e={}){const r=e.maxDistance??1/0,[o,i]=F(t,n);if(o.length-i.length>r)return r+1;if(i.length===0)return o.length>r?r+1:o.length;const s=i.length+1;let l=new Uint32Array(s),a=new Uint32Array(s),c=new Uint32Array(s);for(let u=0;u<s;u++)a[u]=u;for(let u=1;u<=o.length;u++){c[0]=u;let g=u;for(let p=1;p<s;p++){const d=o[u-1]===i[p-1]?0:1;let h=Math.min((a[p]??0)+1,(c[p-1]??0)+1,(a[p-1]??0)+d);u>1&&p>1&&o[u-1]===i[p-2]&&o[u-2]===i[p-1]&&(h=Math.min(h,(l[p-2]??0)+1)),c[p]=h,h<g&&(g=h)}if(g>r)return r+1;[l,a,c]=[a,c,l]}const f=a[s-1]??0;return f>r?r+1:f}function ne(t,n,e={}){let r=t,o=n;(e.ignoreCase===!0||e.ignoreAccents===!0)&&(r=A(r,e.locale,e.ignoreAccents===!0),o=A(o,e.locale,e.ignoreAccents===!0));const i=Math.max(W(r,{unit:"codePoint"}),W(o,{unit:"codePoint"}));return i===0?1:1-et(r,o)/i}const P=/[\p{L}\p{N}]/u,nt=/\p{Lu}/u,rt=/\p{Ll}/u;function _(t,n){if(n<=0)return!0;const e=t.charAt(n-1),r=t.charAt(n);return P.test(e)?nt.test(r)&&rt.test(e):!0}function H(t,n){const e=[];for(const r of t){const o=n.starts[r]??0,i=n.ends[r]??o,s=e[e.length-1];s&&o<=s[1]?s[1]=Math.max(s[1],i):e.push([o,i])}return e}const ot=64;function it(t,n,e,r){const o=R(n,e,r),i=o.text,s=t.length;if(s===0)return{score:1,ranges:[]};const l=i.indexOf(t);if(l>=0){const f=o.starts[l]??0,u=i===t?1:l===0?.9:_(n,f)?.8:.7;return{score:u===1?1:u-.1*(1-s/i.length),ranges:H(Array.from({length:s},(p,d)=>l+d),o)}}let a,c=0;for(let f=i.indexOf(t.charAt(0));f>=0&&c<ot;f=i.indexOf(t.charAt(0),f+1),c++){const u=[f];let g=f+1;for(let y=1;y<s;y++){const O=i.indexOf(t.charAt(y),g);if(O<0)break;u.push(O),g=O+1}if(u.length<s)break;let p=0,d=0;for(let y=0;y<s;y++){const O=u[y]??0;y>0&&O===(u[y-1]??0)+1&&p++,_(n,o.starts[O]??0)&&d++}const h=(u[s-1]??0)-f+1,b=.1+.25*(s/h)+.15*(s>1?p/(s-1):1)+.1*(d/s);(!a||b>a.score)&&(a={score:b,positions:u})}return a?{score:a.score,ranges:H(a.positions,o)}:void 0}function re(t,n,e={}){const{limit:r=1/0,threshold:o=0,keys:i,locale:s}=e,l=e.ignoreAccents??!0,a=A(t.trim().normalize("NFC"),s,l),c=[];return n.forEach((f,u)=>{const g=[];if(i?.length)for(const d of i){const h=typeof d=="function"?d(f):f[d];g.push(typeof h=="string"?h:void 0)}else g.push(typeof f=="string"?f:void 0);let p;g.forEach((d,h)=>{if(d===void 0)return;const b=it(a,d,s,l);b&&b.score>=o&&(!p||b.score>p.score)&&(p={item:f,index:u,score:b.score,key:h,text:d,ranges:b.ranges})}),p&&c.push(p)}),c.sort((f,u)=>u.score-f.score||f.text.length-u.text.length||f.index-u.index),Number.isFinite(r)?c.slice(0,Math.max(0,r)):c}function oe(t,n,e={}){let r;if(typeof n=="string"){const s=e.ignoreAccents??!0,l=R(t,e.locale,s),a=(e.words===!0?n.split(/\s+/u):[n.trim()]).map(c=>A(c.normalize("NFC"),e.locale,s)).filter(c=>c!=="");r=[];for(const c of a)for(let f=l.text.indexOf(c);f>=0;f=l.text.indexOf(c,f+c.length))r.push([l.starts[f]??0,l.ends[f+c.length-1]??0])}else r=n.map(([s,l])=>[Math.max(0,Math.min(s,t.length)),Math.max(0,Math.min(l,t.length))]);r=r.filter(([s,l])=>l>s).sort((s,l)=>s[0]-l[0]);const o=[];let i=0;for(const[s,l]of r){if(l<=i)continue;const a=Math.max(s,i);a>i&&o.push({text:t.slice(i,a),match:!1});const c=o[o.length-1];c?.match===!0&&a===i?o[o.length-1]={text:c.text+t.slice(a,l),match:!0}:o.push({text:t.slice(a,l),match:!0}),i=l}return i<t.length&&o.push({text:t.slice(i),match:!1}),o}const st=new Map,lt=new Map;function ie(t,n,e={}){const{locale:r,type:o="cardinal"}=e,i=`${L(r)}|${o}`;let s;if(t===0&&n.zero!==void 0)s=n.zero;else{const a=C(st,i,()=>new Intl.PluralRules(r,{type:o})).select(t);s=n[a]??n.other}if(!s.includes("{count}"))return s;const l=C(lt,L(r),()=>new Intl.NumberFormat(r)).format(t);return s.replaceAll("{count}",l)}const at=new Map;function se(t,n={}){const{locale:e,type:r="conjunction",style:o="long"}=n;return C(at,`${L(e)}|${r}|${o}`,()=>new Intl.ListFormat(e,{type:r,style:o})).format(t)}function le(t,n={}){const e=Math.max(1,Math.floor(n.max??2)),r=[];for(const o of t.trim().split(/\s+/u))for(const i of j(o))if(P.test(i)){r.push(M(i,n.locale));break}return r.length<=e?r.join(""):[...r.slice(0,e-1),r[r.length-1]??""].join("")}export{bt as ENGLISH_MINOR_WORDS,$t as between,Qt as byteLengthUtf8,pt as camelCase,wt as capitalize,Rt as center,W as charCount,zt as collapseWhitespace,Bt as compareIgnoreCase,yt as constantCase,Kt as containsIgnoreCase,_t as countOccurrences,ee as damerauLevenshtein,Nt as dedent,xt as dotCase,Ut as endsWithAny,Gt as equalsIgnoreCase,Yt as escapeHtml,qt as escapeRegExp,se as formatList,re as fuzzyMatch,z as graphemeLength,St as graphemes,oe as highlight,Et as indent,le as initials,Vt as isAlpha,Jt as isAlphanumeric,Xt as isNumeric,ht as kebabCase,et as levenshtein,I as mask,jt as maskEmail,vt as normalizeWhitespace,dt as pascalCase,ie as pluralize,Lt as removeDiacritics,Ht as replaceAllSafe,It as reverseGraphemes,At as sentenceCase,ne as similarity,Mt as slugify,mt as snakeCase,Q as splitLines,ue as splitWords,Dt as startsWithAny,Wt as stripControlChars,te as template,Ot as titleCase,N as toCodePoints,Tt as truncate,kt as truncateMiddle,Ct as uncapitalize,Zt as unescapeHtml,Pt as wordCount,Ft as wrapText};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** Internal string machinery: Intl caches, grapheme iteration with fallback, accent/case folding. */
|
|
2
|
+
/** Bounded cache for Intl objects keyed by locale and options. */
|
|
3
|
+
export declare function cached<T>(map: Map<string, T>, key: string, create: () => T): T;
|
|
4
|
+
/** Stable cache key for a locales argument. */
|
|
5
|
+
export declare function localeKey(locale: Intl.LocalesArgument): string;
|
|
6
|
+
/** Locale-aware lowercase; locale-independent when `locale` is undefined (identifiers must not depend on the host locale). */
|
|
7
|
+
export declare const lower: (s: string, locale: Intl.LocalesArgument) => string;
|
|
8
|
+
/** Locale-aware uppercase; locale-independent when `locale` is undefined. */
|
|
9
|
+
export declare const upper: (s: string, locale: Intl.LocalesArgument) => string;
|
|
10
|
+
/** Approximate extended grapheme clusters (UAX #29 subset) for runtimes without `Intl.Segmenter`. */
|
|
11
|
+
export declare function graphemesFallback(s: string): Generator<string>;
|
|
12
|
+
/** Lazily iterates grapheme clusters. */
|
|
13
|
+
export declare function iterGraphemes(s: string): Generator<string>;
|
|
14
|
+
/** Grapheme clusters as an array; stops after `limit` clusters when given. */
|
|
15
|
+
export declare function graphemeArray(s: string, limit?: number): string[];
|
|
16
|
+
/** Combining diacritical marks (Latin, Greek, Cyrillic); marks of other scripts are letters' vowel signs and stay. */
|
|
17
|
+
export declare const DIACRITICS_RE: RegExp;
|
|
18
|
+
/** Letters with strokes that do not decompose under NFD. */
|
|
19
|
+
export declare const STROKE_MAP: Readonly<Record<string, string>>;
|
|
20
|
+
export declare const STROKE_RE: RegExp;
|
|
21
|
+
export declare function stripDiacritics(s: string, form?: 'NFD' | 'NFKD'): string;
|
|
22
|
+
export interface Folded {
|
|
23
|
+
/** Folded text (lowercase, optionally without accents). */
|
|
24
|
+
readonly text: string;
|
|
25
|
+
/** For each folded code unit: start index in the original string. */
|
|
26
|
+
readonly starts: readonly number[];
|
|
27
|
+
/** For each folded code unit: end index (exclusive) in the original string. */
|
|
28
|
+
readonly ends: readonly number[];
|
|
29
|
+
}
|
|
30
|
+
/** Case- and optionally accent-folds `s`, keeping a map back to original indices (for highlighting). */
|
|
31
|
+
export declare function foldWithMap(s: string, locale: Intl.LocalesArgument, stripAccents: boolean): Folded;
|
|
32
|
+
/** Case- and optionally accent-folds `s` (no index map). */
|
|
33
|
+
export declare function fold(s: string, locale: Intl.LocalesArgument, stripAccents: boolean): string;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
const E=32;function R(e,t,n){let r=e.get(t);return r===void 0&&(e.size>=32&&e.clear(),r=n(),e.set(t,r)),r}function S(e){return e===void 0?"":typeof e=="string"?e:e instanceof Intl.Locale?e.toString():e.map(t=>typeof t=="string"?t:t.toString()).join(",")}const a=(e,t)=>t===void 0?e.toLowerCase():e.toLocaleLowerCase(t),T=(e,t)=>t===void 0?e.toUpperCase():e.toLocaleUpperCase(t);let l;const x=typeof Intl.Segmenter=="function",p=/[\p{Grapheme_Extend}\p{Mc}]/u,h=new Set([2381,2509,2765,2893,3149,3405]),m=/\p{L}/u,g=e=>e>=127462&&e<=127487,b=e=>e>=127995&&e<=127999||e>=917536&&e<=917631||e>=65024&&e<=65039||e===8205;function*y(e){let t="",n=-1,r=0;for(const u of e){const o=u.codePointAt(0)??0;!(t!==""&&(n===13&&o===10||p.test(u)||b(o)||n===8205||h.has(n)&&m.test(u)||g(o)&&g(n)&&r%2===1))&&t!==""&&(yield t,t="",r=0),t+=u,r=g(o)?r+1:0,n=o}t!==""&&(yield t)}function*A(e){if(!x){yield*y(e);return}l??=new Intl.Segmenter(void 0,{granularity:"grapheme"});for(const t of l.segment(e))yield t.segment}function _(e,t=1/0){const n=[];if(t<=0)return n;for(const r of A(e))if(n.push(r),n.length>=t)break;return n}const I=/[\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f]/gu,L={\u00F8:"o",\u00D8:"O",\u0142:"l",\u0141:"L",\u0111:"d",\u0110:"D",\u0127:"h",\u0126:"H",\u0167:"t",\u0166:"T",\u0180:"b",\u0268:"i",\u0289:"u"},C=/[\u00f8\u00d8\u0142\u0141\u0111\u0110\u0127\u0126\u0167\u0166\u0180\u0268\u0289]/gu;function c(e,t="NFD"){return e.normalize(t).replace(I,"").normalize("NFC").replace(C,n=>L[n]??n)}function F(e,t,n){let r="";const u=[],o=[];let i=0;for(const f of e){let s=a(f,t);n&&(s=c(s)),s===""&&o.length&&(o[o.length-1]=i+f.length);for(let d=s.length;d>0;d--)u.push(i),o.push(i+f.length);r+=s,i+=f.length}return{text:r,starts:u,ends:o}}function M(e,t,n){const r=a(e,t);return n?c(r):r}export{I as DIACRITICS_RE,L as STROKE_MAP,C as STROKE_RE,R as cached,M as fold,F as foldWithMap,_ as graphemeArray,y as graphemesFallback,A as iterGraphemes,S as localeKey,a as lower,c as stripDiacritics,T as upper};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Unicode-aware word splitting for case conversion. */
|
|
2
|
+
export interface SplitWordsOptions {
|
|
3
|
+
/** Split between letters and digits (`item2Id` -> `item`, `2`, `Id`). Default false: digits stay with the preceding word. */
|
|
4
|
+
readonly splitDigits?: boolean;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Splits identifiers and phrases into words: separators, lower->upper humps, acronym boundaries
|
|
8
|
+
* (`XMLHttpRequest` -> `XML`, `Http`, `Request`), optionally digits. Combining marks stay with
|
|
9
|
+
* their letter; apostrophes inside words are kept (`don't`).
|
|
10
|
+
* @example
|
|
11
|
+
* splitWords('XMLHttpRequest'); // => ['XML', 'Http', 'Request']
|
|
12
|
+
* splitWords('öffne_DieTür-2x'); // => ['öffne', 'Die', 'Tür', '2x']
|
|
13
|
+
*/
|
|
14
|
+
export declare function splitWords(input: string, options?: SplitWordsOptions): string[];
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! AbsoluteUI @absoluteui/helpers v0.13.2 | (c) Kasadara Technology Solutions Pvt Ltd | Apache-2.0 | https://aui.kasadara.com/license/ */
|
|
2
|
+
const d=/[\p{Lu}\p{Lt}]/u,c=/\p{Ll}/u,g=/\p{L}/u,D=/\p{N}/u,U=/\p{M}/u;var k=(t=>(t[t.Upper=0]="Upper",t[t.Lower=1]="Lower",t[t.Other=2]="Other",t[t.Digit=3]="Digit",t[t.Mark=4]="Mark",t[t.Apostrophe=5]="Apostrophe",t[t.Sep=6]="Sep",t))(k||{});function E(n){return d.test(n)?0:c.test(n)?1:g.test(n)?2:D.test(n)?3:U.test(n)?4:n==="'"||n==="\u2019"?5:6}function R(n,K={}){const h=K.splitDigits===!0,f=[];let e=[];const o=()=>{e.length&&f.push(e.map(t=>t.text).join("")),e=[]},p=Array.from(n);for(let t=0;t<p.length;t++){const u=p[t]??"",i=E(u);if(i===6){o();continue}const s=e[e.length-1];if(i===4){s&&(s.text+=u);continue}if(i===5){const r=p[t+1];s&&s.k!==3&&r!==void 0&&g.test(r)?s.text+=u:o();continue}if(s){const r=s.k,L=i===0||i===1||i===2,a=r===0||r===1||r===2;if(i===0&&(r===1||r===2||r===3&&c.test(p[t+1]??"")))o();else if(i===1&&r===0&&e.length>=2&&e[e.length-2]?.k===0){const l=e.pop();o(),l&&e.push(l)}else h&&(i===3&&a||L&&r===3)&&o()}e.push({text:u,k:i})}return o(),f}export{R as splitWords};
|