@oxog/strkit 1.0.0
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 +21 -0
- package/README.md +266 -0
- package/dist/chunk-NYBEYU46.mjs +12 -0
- package/dist/chunk-NYBEYU46.mjs.map +1 -0
- package/dist/chunk-QYEYUUS2.cjs +12 -0
- package/dist/chunk-QYEYUUS2.cjs.map +1 -0
- package/dist/extend.cjs +2 -0
- package/dist/extend.cjs.map +1 -0
- package/dist/extend.d.cts +130 -0
- package/dist/extend.d.ts +130 -0
- package/dist/extend.mjs +2 -0
- package/dist/extend.mjs.map +1 -0
- package/dist/index.cjs +12 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1148 -0
- package/dist/index.d.ts +1148 -0
- package/dist/index.mjs +12 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types-B8r-f173.d.cts +228 -0
- package/dist/types-B8r-f173.d.ts +228 -0
- package/package.json +101 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,1148 @@
|
|
|
1
|
+
import { T as TruncateOptions, S as SlugifyOptions, a as TemplateOptions, A as AnalysisOptions, F as FrequencyResult, b as StrKitOptions, c as SearchOptions, d as SimilarityOptions, D as DiffResult, e as DiffOptions, M as MaskOptions, C as CurrencyOptions, f as MatchResult, g as StrKitLocale, h as StrKitPlugin } from './types-B8r-f173.js';
|
|
2
|
+
export { P as PatchHunk, i as PatchResult, k as StrKitConfig, j as StrKitKernel } from './types-B8r-f173.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* StrKit Chain Interface
|
|
6
|
+
* Provides a fluent, immutable API for string manipulation
|
|
7
|
+
*/
|
|
8
|
+
interface StrKitChain {
|
|
9
|
+
readonly length: number;
|
|
10
|
+
readonly s: string;
|
|
11
|
+
readonly value: string;
|
|
12
|
+
getValue(): string;
|
|
13
|
+
toString(): string;
|
|
14
|
+
clone(): StrKitChain;
|
|
15
|
+
camelCase(): StrKitChain;
|
|
16
|
+
kebabCase(): StrKitChain;
|
|
17
|
+
snakeCase(): StrKitChain;
|
|
18
|
+
pascalCase(): StrKitChain;
|
|
19
|
+
titleCase(): StrKitChain;
|
|
20
|
+
sentenceCase(): StrKitChain;
|
|
21
|
+
constantCase(): StrKitChain;
|
|
22
|
+
dotCase(): StrKitChain;
|
|
23
|
+
pathCase(): StrKitChain;
|
|
24
|
+
headerCase(): StrKitChain;
|
|
25
|
+
swapCase(): StrKitChain;
|
|
26
|
+
upper(): StrKitChain;
|
|
27
|
+
lower(): StrKitChain;
|
|
28
|
+
capitalize(): StrKitChain;
|
|
29
|
+
decapitalize(): StrKitChain;
|
|
30
|
+
trim(chars?: string): StrKitChain;
|
|
31
|
+
trimStart(chars?: string): StrKitChain;
|
|
32
|
+
trimEnd(chars?: string): StrKitChain;
|
|
33
|
+
pad(length: number, char?: string): StrKitChain;
|
|
34
|
+
padStart(length: number, char?: string): StrKitChain;
|
|
35
|
+
padEnd(length: number, char?: string): StrKitChain;
|
|
36
|
+
repeat(count: number): StrKitChain;
|
|
37
|
+
reverse(): StrKitChain;
|
|
38
|
+
truncate(length: number, options?: TruncateOptions): StrKitChain;
|
|
39
|
+
wrap(wrapper: string, end?: string): StrKitChain;
|
|
40
|
+
unwrap(wrapper: string, end?: string): StrKitChain;
|
|
41
|
+
insert(index: number, str: string): StrKitChain;
|
|
42
|
+
remove(start: number, count: number): StrKitChain;
|
|
43
|
+
replace(search: string | RegExp, replacement: string): StrKitChain;
|
|
44
|
+
replaceAll(search: string | RegExp, replacement: string): StrKitChain;
|
|
45
|
+
between(start: string, end: string): StrKitChain;
|
|
46
|
+
before(search: string): StrKitChain;
|
|
47
|
+
after(search: string): StrKitChain;
|
|
48
|
+
beforeLast(search: string): StrKitChain;
|
|
49
|
+
afterLast(search: string): StrKitChain;
|
|
50
|
+
append(...strings: string[]): StrKitChain;
|
|
51
|
+
prepend(...strings: string[]): StrKitChain;
|
|
52
|
+
surround(wrapper: string): StrKitChain;
|
|
53
|
+
collapseWhitespace(): StrKitChain;
|
|
54
|
+
escape(): StrKitChain;
|
|
55
|
+
unescape(): StrKitChain;
|
|
56
|
+
escapeHtml(): StrKitChain;
|
|
57
|
+
unescapeHtml(): StrKitChain;
|
|
58
|
+
escapeRegex(): StrKitChain;
|
|
59
|
+
slugify(options?: SlugifyOptions): StrKitChain;
|
|
60
|
+
filename(): StrKitChain;
|
|
61
|
+
stripHtml(): StrKitChain;
|
|
62
|
+
stripTags(allowed?: string[]): StrKitChain;
|
|
63
|
+
clean(): StrKitChain;
|
|
64
|
+
normalize(): StrKitChain;
|
|
65
|
+
latinise(): StrKitChain;
|
|
66
|
+
transliterate(locale?: string): StrKitChain;
|
|
67
|
+
template(data: Record<string, unknown>, options?: TemplateOptions): StrKitChain;
|
|
68
|
+
sprintf(...args: unknown[]): StrKitChain;
|
|
69
|
+
mask(pattern: string): StrKitChain;
|
|
70
|
+
unmask(pattern: string): StrKitChain;
|
|
71
|
+
isEmail(): boolean;
|
|
72
|
+
isUrl(): boolean;
|
|
73
|
+
isUuid(version?: 1 | 3 | 4 | 5): boolean;
|
|
74
|
+
isIp(): boolean;
|
|
75
|
+
isIpv4(): boolean;
|
|
76
|
+
isIpv6(): boolean;
|
|
77
|
+
isPhone(): boolean;
|
|
78
|
+
isCreditCard(): boolean;
|
|
79
|
+
isEmpty(): boolean;
|
|
80
|
+
isBlank(): boolean;
|
|
81
|
+
isAlpha(): boolean;
|
|
82
|
+
isNumeric(): boolean;
|
|
83
|
+
isAlphanumeric(): boolean;
|
|
84
|
+
isHex(): boolean;
|
|
85
|
+
isBase64(): boolean;
|
|
86
|
+
isJson(): boolean;
|
|
87
|
+
isUpperCase(): boolean;
|
|
88
|
+
isLowerCase(): boolean;
|
|
89
|
+
wordCount(): number;
|
|
90
|
+
charCount(options?: AnalysisOptions): number;
|
|
91
|
+
lineCount(): number;
|
|
92
|
+
sentenceCount(): number;
|
|
93
|
+
paragraphCount(): number;
|
|
94
|
+
byteSize(): number;
|
|
95
|
+
entropy(): number;
|
|
96
|
+
frequency(options?: {
|
|
97
|
+
type?: 'char' | 'word';
|
|
98
|
+
}): FrequencyResult;
|
|
99
|
+
readingTime(options?: {
|
|
100
|
+
wordsPerMinute?: number;
|
|
101
|
+
}): number;
|
|
102
|
+
speakingTime(options?: {
|
|
103
|
+
wordsPerMinute?: number;
|
|
104
|
+
}): number;
|
|
105
|
+
contains(search: string, options?: StrKitOptions): boolean;
|
|
106
|
+
startsWith(search: string): boolean;
|
|
107
|
+
endsWith(search: string): boolean;
|
|
108
|
+
indexOf(search: string, options?: SearchOptions): number;
|
|
109
|
+
lastIndexOf(search: string): number;
|
|
110
|
+
countOccurrences(search: string): number;
|
|
111
|
+
positions(search: string): number[];
|
|
112
|
+
match(pattern: RegExp): string | null;
|
|
113
|
+
matchAll(pattern: RegExp): string[];
|
|
114
|
+
levenshtein(other: string): number;
|
|
115
|
+
levenshteinRatio(other: string): number;
|
|
116
|
+
dice(other: string): number;
|
|
117
|
+
jaroWinkler(other: string): number;
|
|
118
|
+
hamming(other: string): number;
|
|
119
|
+
cosine(other: string): number;
|
|
120
|
+
similarity(other: string, options?: SimilarityOptions): number;
|
|
121
|
+
diffChars(other: string): DiffResult[];
|
|
122
|
+
diffWords(other: string): DiffResult[];
|
|
123
|
+
diffLines(other: string): DiffResult[];
|
|
124
|
+
diff(other: string, options?: DiffOptions): DiffResult[];
|
|
125
|
+
plural(count?: number, showCount?: boolean): StrKitChain;
|
|
126
|
+
singular(): StrKitChain;
|
|
127
|
+
isPlural(): boolean;
|
|
128
|
+
isSingular(): boolean;
|
|
129
|
+
lines(): string[];
|
|
130
|
+
words(): string[];
|
|
131
|
+
chars(): string[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Create a new StrKit chain
|
|
135
|
+
* @param value - The string to wrap
|
|
136
|
+
* @returns A chainable string wrapper
|
|
137
|
+
*/
|
|
138
|
+
declare function S(value: string): StrKitChain;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Case Conversion Plugin
|
|
142
|
+
* Provides methods for converting strings between different case formats
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Convert string to camelCase
|
|
147
|
+
* @example camelCase('hello world') // 'helloWorld'
|
|
148
|
+
* @example camelCase('hello-world') // 'helloWorld'
|
|
149
|
+
*/
|
|
150
|
+
declare function camelCase(input: string, options?: StrKitOptions): string;
|
|
151
|
+
/**
|
|
152
|
+
* Convert string to kebab-case
|
|
153
|
+
* @example kebabCase('helloWorld') // 'hello-world'
|
|
154
|
+
* @example kebabCase('Hello World') // 'hello-world'
|
|
155
|
+
*/
|
|
156
|
+
declare function kebabCase(input: string, options?: StrKitOptions): string;
|
|
157
|
+
/**
|
|
158
|
+
* Convert string to snake_case
|
|
159
|
+
* @example snakeCase('helloWorld') // 'hello_world'
|
|
160
|
+
* @example snakeCase('Hello World') // 'hello_world'
|
|
161
|
+
*/
|
|
162
|
+
declare function snakeCase(input: string, options?: StrKitOptions): string;
|
|
163
|
+
/**
|
|
164
|
+
* Convert string to PascalCase
|
|
165
|
+
* @example pascalCase('hello world') // 'HelloWorld'
|
|
166
|
+
* @example pascalCase('hello-world') // 'HelloWorld'
|
|
167
|
+
*/
|
|
168
|
+
declare function pascalCase(input: string, options?: StrKitOptions): string;
|
|
169
|
+
/**
|
|
170
|
+
* Convert string to Title Case
|
|
171
|
+
* @example titleCase('hello world') // 'Hello World'
|
|
172
|
+
* @example titleCase('hello-world') // 'Hello World'
|
|
173
|
+
*/
|
|
174
|
+
declare function titleCase(input: string, options?: StrKitOptions): string;
|
|
175
|
+
/**
|
|
176
|
+
* Convert string to Sentence case
|
|
177
|
+
* @example sentenceCase('hello world') // 'Hello world'
|
|
178
|
+
* @example sentenceCase('HELLO WORLD') // 'Hello world'
|
|
179
|
+
*/
|
|
180
|
+
declare function sentenceCase(input: string, options?: StrKitOptions): string;
|
|
181
|
+
/**
|
|
182
|
+
* Convert string to CONSTANT_CASE
|
|
183
|
+
* @example constantCase('hello world') // 'HELLO_WORLD'
|
|
184
|
+
* @example constantCase('helloWorld') // 'HELLO_WORLD'
|
|
185
|
+
*/
|
|
186
|
+
declare function constantCase(input: string, options?: StrKitOptions): string;
|
|
187
|
+
/**
|
|
188
|
+
* Convert string to dot.case
|
|
189
|
+
* @example dotCase('hello world') // 'hello.world'
|
|
190
|
+
* @example dotCase('helloWorld') // 'hello.world'
|
|
191
|
+
*/
|
|
192
|
+
declare function dotCase(input: string, options?: StrKitOptions): string;
|
|
193
|
+
/**
|
|
194
|
+
* Convert string to path/case
|
|
195
|
+
* @example pathCase('hello world') // 'hello/world'
|
|
196
|
+
* @example pathCase('helloWorld') // 'hello/world'
|
|
197
|
+
*/
|
|
198
|
+
declare function pathCase(input: string, options?: StrKitOptions): string;
|
|
199
|
+
/**
|
|
200
|
+
* Convert string to Header-Case
|
|
201
|
+
* @example headerCase('hello world') // 'Hello-World'
|
|
202
|
+
* @example headerCase('helloWorld') // 'Hello-World'
|
|
203
|
+
*/
|
|
204
|
+
declare function headerCase(input: string, options?: StrKitOptions): string;
|
|
205
|
+
/**
|
|
206
|
+
* Swap case of each character
|
|
207
|
+
* @example swapCase('Hello World') // 'hELLO wORLD'
|
|
208
|
+
*/
|
|
209
|
+
declare function swapCase(input: string, options?: StrKitOptions): string;
|
|
210
|
+
/**
|
|
211
|
+
* Convert string to UPPERCASE
|
|
212
|
+
* @example toUpper('hello') // 'HELLO'
|
|
213
|
+
*/
|
|
214
|
+
declare function toUpper(input: string, options?: StrKitOptions): string;
|
|
215
|
+
/**
|
|
216
|
+
* Convert string to lowercase
|
|
217
|
+
* @example toLower('HELLO') // 'hello'
|
|
218
|
+
*/
|
|
219
|
+
declare function toLower(input: string, options?: StrKitOptions): string;
|
|
220
|
+
/**
|
|
221
|
+
* Capitalize first letter
|
|
222
|
+
* @example capitalize('hello') // 'Hello'
|
|
223
|
+
*/
|
|
224
|
+
declare function capitalize(input: string, options?: StrKitOptions): string;
|
|
225
|
+
/**
|
|
226
|
+
* Lowercase first letter
|
|
227
|
+
* @example decapitalize('Hello') // 'hello'
|
|
228
|
+
*/
|
|
229
|
+
declare function decapitalize(input: string, options?: StrKitOptions): string;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* Manipulation Plugin
|
|
233
|
+
* Provides methods for string manipulation operations
|
|
234
|
+
*/
|
|
235
|
+
|
|
236
|
+
/**
|
|
237
|
+
* Trim whitespace or specified characters from both ends
|
|
238
|
+
* @example trim(' hello ') // 'hello'
|
|
239
|
+
* @example trim('##hello##', '#') // 'hello'
|
|
240
|
+
*/
|
|
241
|
+
declare function trim(input: string, chars?: string): string;
|
|
242
|
+
/**
|
|
243
|
+
* Trim whitespace or specified characters from start
|
|
244
|
+
* @example trimStart(' hello') // 'hello'
|
|
245
|
+
*/
|
|
246
|
+
declare function trimStart(input: string, chars?: string): string;
|
|
247
|
+
/**
|
|
248
|
+
* Trim whitespace or specified characters from end
|
|
249
|
+
* @example trimEnd('hello ') // 'hello'
|
|
250
|
+
*/
|
|
251
|
+
declare function trimEnd(input: string, chars?: string): string;
|
|
252
|
+
/**
|
|
253
|
+
* Pad string on both sides to reach target length
|
|
254
|
+
* @example pad('hello', 11, '-') // '---hello---'
|
|
255
|
+
*/
|
|
256
|
+
declare function pad(input: string, length: number, char?: string): string;
|
|
257
|
+
/**
|
|
258
|
+
* Pad string on start to reach target length
|
|
259
|
+
* @example padStart('5', 3, '0') // '005'
|
|
260
|
+
*/
|
|
261
|
+
declare function padStart(input: string, length: number, char?: string): string;
|
|
262
|
+
/**
|
|
263
|
+
* Pad string on end to reach target length
|
|
264
|
+
* @example padEnd('5', 3, '0') // '500'
|
|
265
|
+
*/
|
|
266
|
+
declare function padEnd(input: string, length: number, char?: string): string;
|
|
267
|
+
/**
|
|
268
|
+
* Repeat string n times
|
|
269
|
+
* @example repeat('ab', 3) // 'ababab'
|
|
270
|
+
*/
|
|
271
|
+
declare function repeat(input: string, count: number): string;
|
|
272
|
+
/**
|
|
273
|
+
* Reverse string (Unicode-aware)
|
|
274
|
+
* @example reverse('hello') // 'olleh'
|
|
275
|
+
*/
|
|
276
|
+
declare function reverse(input: string): string;
|
|
277
|
+
/**
|
|
278
|
+
* Truncate string with ellipsis
|
|
279
|
+
* @example truncate('hello world', 8) // 'hello...'
|
|
280
|
+
* @example truncate('hello world', 8, { position: 'middle' }) // 'hel...ld'
|
|
281
|
+
*/
|
|
282
|
+
declare function truncate(input: string, length: number, options?: TruncateOptions): string;
|
|
283
|
+
/**
|
|
284
|
+
* Wrap string with characters
|
|
285
|
+
* @example wrap('hello', '"') // '"hello"'
|
|
286
|
+
* @example wrap('hello', '[', ']') // '[hello]'
|
|
287
|
+
*/
|
|
288
|
+
declare function wrap(input: string, wrapper: string, end?: string): string;
|
|
289
|
+
/**
|
|
290
|
+
* Remove wrapping characters
|
|
291
|
+
* @example unwrap('"hello"', '"') // 'hello'
|
|
292
|
+
* @example unwrap('[hello]', '[', ']') // 'hello'
|
|
293
|
+
*/
|
|
294
|
+
declare function unwrap(input: string, wrapper: string, end?: string): string;
|
|
295
|
+
/**
|
|
296
|
+
* Splice string (like Array.splice)
|
|
297
|
+
* @example splice('hello', 2, 2, 'XY') // 'heXYo'
|
|
298
|
+
*/
|
|
299
|
+
declare function splice(input: string, start: number, deleteCount: number, insert?: string): string;
|
|
300
|
+
/**
|
|
301
|
+
* Insert string at position
|
|
302
|
+
* @example insert('hello', 2, 'XY') // 'heXYllo'
|
|
303
|
+
*/
|
|
304
|
+
declare function insert(input: string, index: number, str: string): string;
|
|
305
|
+
/**
|
|
306
|
+
* Remove characters from string
|
|
307
|
+
* @example remove('hello', 1, 3) // 'ho'
|
|
308
|
+
*/
|
|
309
|
+
declare function remove(input: string, start: number, count: number): string;
|
|
310
|
+
/**
|
|
311
|
+
* Replace first occurrence
|
|
312
|
+
* @example replace('hello', 'l', 'L') // 'heLlo'
|
|
313
|
+
*/
|
|
314
|
+
declare function replace(input: string, search: string | RegExp, replacement: string): string;
|
|
315
|
+
/**
|
|
316
|
+
* Replace all occurrences
|
|
317
|
+
* @example replaceAll('hello', 'l', 'L') // 'heLLo'
|
|
318
|
+
*/
|
|
319
|
+
declare function replaceAll(input: string, search: string | RegExp, replacement: string): string;
|
|
320
|
+
/**
|
|
321
|
+
* Get string between delimiters
|
|
322
|
+
* @example between('<tag>', '<', '>') // 'tag'
|
|
323
|
+
*/
|
|
324
|
+
declare function between(input: string, start: string, end: string): string;
|
|
325
|
+
/**
|
|
326
|
+
* Get string before first occurrence
|
|
327
|
+
* @example before('hello@world', '@') // 'hello'
|
|
328
|
+
*/
|
|
329
|
+
declare function before(input: string, search: string): string;
|
|
330
|
+
/**
|
|
331
|
+
* Get string after first occurrence
|
|
332
|
+
* @example after('hello@world', '@') // 'world'
|
|
333
|
+
*/
|
|
334
|
+
declare function after(input: string, search: string): string;
|
|
335
|
+
/**
|
|
336
|
+
* Get string before last occurrence
|
|
337
|
+
* @example beforeLast('hello@world@test', '@') // 'hello@world'
|
|
338
|
+
*/
|
|
339
|
+
declare function beforeLast(input: string, search: string): string;
|
|
340
|
+
/**
|
|
341
|
+
* Get string after last occurrence
|
|
342
|
+
* @example afterLast('hello@world@test', '@') // 'test'
|
|
343
|
+
*/
|
|
344
|
+
declare function afterLast(input: string, search: string): string;
|
|
345
|
+
/**
|
|
346
|
+
* Append strings
|
|
347
|
+
* @example append('hello', ' ', 'world') // 'hello world'
|
|
348
|
+
*/
|
|
349
|
+
declare function append(input: string, ...strings: string[]): string;
|
|
350
|
+
/**
|
|
351
|
+
* Prepend strings
|
|
352
|
+
* @example prepend('world', 'hello', ' ') // 'hello world'
|
|
353
|
+
*/
|
|
354
|
+
declare function prepend(input: string, ...strings: string[]): string;
|
|
355
|
+
/**
|
|
356
|
+
* Surround string with another string
|
|
357
|
+
* @example surround('hello', '***') // '***hello***'
|
|
358
|
+
*/
|
|
359
|
+
declare function surround(input: string, wrapper: string): string;
|
|
360
|
+
/**
|
|
361
|
+
* Collapse multiple whitespace into single spaces
|
|
362
|
+
* @example collapseWhitespace('hello world\n\ntest') // 'hello world test'
|
|
363
|
+
*/
|
|
364
|
+
declare function collapseWhitespace(input: string): string;
|
|
365
|
+
/**
|
|
366
|
+
* Split string into lines
|
|
367
|
+
* @example lines('a\nb\nc') // ['a', 'b', 'c']
|
|
368
|
+
*/
|
|
369
|
+
declare function lines(input: string): string[];
|
|
370
|
+
/**
|
|
371
|
+
* Split string into words
|
|
372
|
+
* @example words('hello world') // ['hello', 'world']
|
|
373
|
+
*/
|
|
374
|
+
declare function words(input: string): string[];
|
|
375
|
+
/**
|
|
376
|
+
* Split string into characters (Unicode-aware)
|
|
377
|
+
* @example chars('hello') // ['h', 'e', 'l', 'l', 'o']
|
|
378
|
+
*/
|
|
379
|
+
declare function chars(input: string): string[];
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Validation Plugin
|
|
383
|
+
* Provides methods for validating string formats
|
|
384
|
+
*/
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* Validate email address (RFC 5322 simplified)
|
|
388
|
+
* @example isEmail('test@example.com') // true
|
|
389
|
+
*/
|
|
390
|
+
declare function isEmail(input: string): boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Validate URL
|
|
393
|
+
* @example isUrl('https://example.com') // true
|
|
394
|
+
*/
|
|
395
|
+
declare function isUrl(input: string): boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Validate UUID (any version or specific version)
|
|
398
|
+
* @example isUuid('550e8400-e29b-41d4-a716-446655440000') // true
|
|
399
|
+
* @example isUuid('550e8400-e29b-41d4-a716-446655440000', 4) // true
|
|
400
|
+
*/
|
|
401
|
+
declare function isUuid(input: string, version?: 1 | 3 | 4 | 5): boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Validate IP address (v4 or v6)
|
|
404
|
+
* @example isIp('192.168.1.1') // true
|
|
405
|
+
* @example isIp('::1') // true
|
|
406
|
+
*/
|
|
407
|
+
declare function isIp(input: string): boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Validate IPv4 address
|
|
410
|
+
* @example isIpv4('192.168.1.1') // true
|
|
411
|
+
*/
|
|
412
|
+
declare function isIpv4(input: string): boolean;
|
|
413
|
+
/**
|
|
414
|
+
* Validate IPv6 address
|
|
415
|
+
* @example isIpv6('::1') // true
|
|
416
|
+
* @example isIpv6('2001:0db8:85a3:0000:0000:8a2e:0370:7334') // true
|
|
417
|
+
*/
|
|
418
|
+
declare function isIpv6(input: string): boolean;
|
|
419
|
+
/**
|
|
420
|
+
* Validate phone number (international format)
|
|
421
|
+
* @example isPhone('+1-555-555-5555') // true
|
|
422
|
+
*/
|
|
423
|
+
declare function isPhone(input: string): boolean;
|
|
424
|
+
/**
|
|
425
|
+
* Validate credit card number (Luhn algorithm)
|
|
426
|
+
* @example isCreditCard('4111111111111111') // true
|
|
427
|
+
*/
|
|
428
|
+
declare function isCreditCard(input: string): boolean;
|
|
429
|
+
/**
|
|
430
|
+
* Check if string is empty
|
|
431
|
+
* @example isEmpty('') // true
|
|
432
|
+
* @example isEmpty('hello') // false
|
|
433
|
+
*/
|
|
434
|
+
declare function isEmpty(input: string): boolean;
|
|
435
|
+
/**
|
|
436
|
+
* Check if string is blank (empty or whitespace only)
|
|
437
|
+
* @example isBlank(' ') // true
|
|
438
|
+
* @example isBlank('hello') // false
|
|
439
|
+
*/
|
|
440
|
+
declare function isBlank(input: string): boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Check if string contains only alphabetic characters
|
|
443
|
+
* @example isAlpha('hello') // true
|
|
444
|
+
* @example isAlpha('hello123') // false
|
|
445
|
+
*/
|
|
446
|
+
declare function isAlpha(input: string): boolean;
|
|
447
|
+
/**
|
|
448
|
+
* Check if string contains only numeric characters
|
|
449
|
+
* @example isNumeric('12345') // true
|
|
450
|
+
* @example isNumeric('12.34') // false
|
|
451
|
+
*/
|
|
452
|
+
declare function isNumeric(input: string): boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Check if string contains only alphanumeric characters
|
|
455
|
+
* @example isAlphanumeric('hello123') // true
|
|
456
|
+
* @example isAlphanumeric('hello-123') // false
|
|
457
|
+
*/
|
|
458
|
+
declare function isAlphanumeric(input: string): boolean;
|
|
459
|
+
/**
|
|
460
|
+
* Check if string is valid hexadecimal
|
|
461
|
+
* @example isHex('ff00ff') // true
|
|
462
|
+
* @example isHex('0xFF00FF') // true
|
|
463
|
+
*/
|
|
464
|
+
declare function isHex(input: string): boolean;
|
|
465
|
+
/**
|
|
466
|
+
* Check if string is valid base64
|
|
467
|
+
* @example isBase64('aGVsbG8=') // true
|
|
468
|
+
*/
|
|
469
|
+
declare function isBase64(input: string): boolean;
|
|
470
|
+
/**
|
|
471
|
+
* Check if string is valid JSON
|
|
472
|
+
* @example isJson('{"key":"value"}') // true
|
|
473
|
+
*/
|
|
474
|
+
declare function isJson(input: string): boolean;
|
|
475
|
+
/**
|
|
476
|
+
* Check if string is all uppercase
|
|
477
|
+
* @example isUpperCase('HELLO') // true
|
|
478
|
+
* @example isUpperCase('Hello') // false
|
|
479
|
+
*/
|
|
480
|
+
declare function isUpperCase(input: string): boolean;
|
|
481
|
+
/**
|
|
482
|
+
* Check if string is all lowercase
|
|
483
|
+
* @example isLowerCase('hello') // true
|
|
484
|
+
* @example isLowerCase('Hello') // false
|
|
485
|
+
*/
|
|
486
|
+
declare function isLowerCase(input: string): boolean;
|
|
487
|
+
/**
|
|
488
|
+
* Check if string contains a substring
|
|
489
|
+
* @example contains('hello world', 'world') // true
|
|
490
|
+
*/
|
|
491
|
+
declare function contains$1(input: string, search: string, options?: StrKitOptions): boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Check if string starts with a substring
|
|
494
|
+
* @example startsWith('hello world', 'hello') // true
|
|
495
|
+
*/
|
|
496
|
+
declare function startsWith$1(input: string, search: string): boolean;
|
|
497
|
+
/**
|
|
498
|
+
* Check if string ends with a substring
|
|
499
|
+
* @example endsWith('hello world', 'world') // true
|
|
500
|
+
*/
|
|
501
|
+
declare function endsWith$1(input: string, search: string): boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Check if strings are equal
|
|
504
|
+
* @example equals('hello', 'hello') // true
|
|
505
|
+
* @example equals('Hello', 'hello', { caseSensitive: false }) // true
|
|
506
|
+
*/
|
|
507
|
+
declare function equals(input: string, other: string, options?: StrKitOptions): boolean;
|
|
508
|
+
/**
|
|
509
|
+
* Check if string matches a regex pattern
|
|
510
|
+
* @example matches('hello123', /^[a-z]+\d+$/) // true
|
|
511
|
+
*/
|
|
512
|
+
declare function matches(input: string, pattern: RegExp): boolean;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Sanitization Plugin
|
|
516
|
+
* Provides methods for sanitizing and cleaning strings
|
|
517
|
+
*/
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Escape special characters for string literals
|
|
521
|
+
* @example escape('Hello "World"') // 'Hello \\"World\\"'
|
|
522
|
+
*/
|
|
523
|
+
declare function escape(input: string): string;
|
|
524
|
+
/**
|
|
525
|
+
* Unescape special characters
|
|
526
|
+
* @example unescape('Hello \\"World\\"') // 'Hello "World"'
|
|
527
|
+
*/
|
|
528
|
+
declare function unescape(input: string): string;
|
|
529
|
+
/**
|
|
530
|
+
* Escape HTML entities
|
|
531
|
+
* @example escapeHtml('<script>alert("xss")</script>') // '<script>alert("xss")</script>'
|
|
532
|
+
*/
|
|
533
|
+
declare function escapeHtml(input: string): string;
|
|
534
|
+
/**
|
|
535
|
+
* Unescape HTML entities
|
|
536
|
+
* @example unescapeHtml('<div>') // '<div>'
|
|
537
|
+
*/
|
|
538
|
+
declare function unescapeHtml(input: string): string;
|
|
539
|
+
/**
|
|
540
|
+
* Escape regex special characters
|
|
541
|
+
* @example escapeRegex('a.b*c?') // 'a\\.b\\*c\\?'
|
|
542
|
+
*/
|
|
543
|
+
declare function escapeRegex(input: string): string;
|
|
544
|
+
/**
|
|
545
|
+
* Create URL-safe slug
|
|
546
|
+
* @example slugify('Hello World!') // 'hello-world'
|
|
547
|
+
* @example slugify('Héllo Wörld!') // 'hello-world'
|
|
548
|
+
*/
|
|
549
|
+
declare function slugify(input: string, options?: SlugifyOptions): string;
|
|
550
|
+
/**
|
|
551
|
+
* Sanitize filename (remove unsafe characters)
|
|
552
|
+
* @example sanitizeFilename('file<>:"/\\|?*.txt') // 'file.txt'
|
|
553
|
+
*/
|
|
554
|
+
declare function sanitizeFilename(input: string): string;
|
|
555
|
+
/**
|
|
556
|
+
* Remove all HTML tags
|
|
557
|
+
* @example stripHtml('<p>Hello <b>World</b></p>') // 'Hello World'
|
|
558
|
+
*/
|
|
559
|
+
declare function stripHtml(input: string): string;
|
|
560
|
+
/**
|
|
561
|
+
* Remove HTML tags except allowed ones
|
|
562
|
+
* @example stripTags('<p>Hello <b>World</b></p>', ['p']) // '<p>Hello World</p>'
|
|
563
|
+
*/
|
|
564
|
+
declare function stripTags(input: string, allowed?: string[]): string;
|
|
565
|
+
/**
|
|
566
|
+
* Clean string (normalize whitespace)
|
|
567
|
+
* @example clean('hello world\n\n\ntest') // 'hello world test'
|
|
568
|
+
*/
|
|
569
|
+
declare function clean(input: string): string;
|
|
570
|
+
/**
|
|
571
|
+
* Unicode normalization (NFC form)
|
|
572
|
+
* @example normalize('café') // 'café' (composed form)
|
|
573
|
+
*/
|
|
574
|
+
declare function normalize(input: string): string;
|
|
575
|
+
/**
|
|
576
|
+
* Convert accented characters to ASCII equivalents
|
|
577
|
+
* @example latinise('Héllo Wörld') // 'Hello World'
|
|
578
|
+
* @example latinise('Cześć') // 'Czesc'
|
|
579
|
+
*/
|
|
580
|
+
declare function latinise(input: string): string;
|
|
581
|
+
/**
|
|
582
|
+
* Transliterate to Latin characters using locale-specific rules
|
|
583
|
+
* @example transliterate('Привет', 'ru') // 'Privet'
|
|
584
|
+
*/
|
|
585
|
+
declare function transliterate(input: string, locale?: string): string;
|
|
586
|
+
|
|
587
|
+
/**
|
|
588
|
+
* Formatting Plugin
|
|
589
|
+
* Provides methods for formatting strings
|
|
590
|
+
*/
|
|
591
|
+
|
|
592
|
+
/**
|
|
593
|
+
* Template interpolation with nested property support
|
|
594
|
+
* @example template('Hello, {{name}}!', { name: 'World' }) // 'Hello, World!'
|
|
595
|
+
* @example template('{{user.name}} is {{user.age}}', { user: { name: 'John', age: 30 } }) // 'John is 30'
|
|
596
|
+
*/
|
|
597
|
+
declare function template(input: string, data: Record<string, unknown>, options?: TemplateOptions): string;
|
|
598
|
+
/**
|
|
599
|
+
* Printf-style formatting
|
|
600
|
+
* Supports: %s (string), %d (integer), %f (float), %x (hex), %o (octal), %b (binary)
|
|
601
|
+
* @example sprintf('%s has %d apples', 'John', 5) // 'John has 5 apples'
|
|
602
|
+
* @example sprintf('%05d', 42) // '00042'
|
|
603
|
+
* @example sprintf('%.2f', 3.14159) // '3.14'
|
|
604
|
+
*/
|
|
605
|
+
declare function sprintf(format: string, ...args: unknown[]): string;
|
|
606
|
+
/**
|
|
607
|
+
* Apply mask pattern to string
|
|
608
|
+
* @example mask('1234567890', '(###) ###-####') // '(123) 456-7890'
|
|
609
|
+
* @example mask('4111111111111111', '#### #### #### ####') // '4111 1111 1111 1111'
|
|
610
|
+
*/
|
|
611
|
+
declare function mask(input: string, pattern: string, options?: MaskOptions): string;
|
|
612
|
+
/**
|
|
613
|
+
* Remove mask pattern from string
|
|
614
|
+
* @example unmask('(123) 456-7890', '(###) ###-####') // '1234567890'
|
|
615
|
+
*/
|
|
616
|
+
declare function unmask(input: string, pattern: string, options?: MaskOptions): string;
|
|
617
|
+
/**
|
|
618
|
+
* Convert number to ordinal string
|
|
619
|
+
* @example ordinalize(1) // '1st'
|
|
620
|
+
* @example ordinalize(2) // '2nd'
|
|
621
|
+
* @example ordinalize(11) // '11th'
|
|
622
|
+
*/
|
|
623
|
+
declare function ordinalize(num: number, locale?: string): string;
|
|
624
|
+
/**
|
|
625
|
+
* Format number as currency
|
|
626
|
+
* @example formatCurrency(1234.56, { locale: 'en-US', currency: 'USD' }) // '$1,234.56'
|
|
627
|
+
*/
|
|
628
|
+
declare function formatCurrency(amount: number, options?: CurrencyOptions): string;
|
|
629
|
+
/**
|
|
630
|
+
* Format number with thousands separator
|
|
631
|
+
* @example formatNumber(1234567.89) // '1,234,567.89'
|
|
632
|
+
* @example formatNumber(1234567.89, { thousands: '.', decimal: ',' }) // '1.234.567,89'
|
|
633
|
+
*/
|
|
634
|
+
declare function formatNumber(input: string | number, options?: {
|
|
635
|
+
decimals?: number;
|
|
636
|
+
thousands?: string;
|
|
637
|
+
decimal?: string;
|
|
638
|
+
}): string;
|
|
639
|
+
|
|
640
|
+
/**
|
|
641
|
+
* Similarity Plugin
|
|
642
|
+
* Provides methods for computing string similarity and distance
|
|
643
|
+
*/
|
|
644
|
+
|
|
645
|
+
/**
|
|
646
|
+
* Calculate Levenshtein edit distance
|
|
647
|
+
* @example levenshtein('kitten', 'sitting') // 3
|
|
648
|
+
*/
|
|
649
|
+
declare function levenshtein(a: string, b: string): number;
|
|
650
|
+
/**
|
|
651
|
+
* Calculate normalized Levenshtein similarity ratio (0-1)
|
|
652
|
+
* @example levenshteinRatio('kitten', 'sitting') // 0.571...
|
|
653
|
+
*/
|
|
654
|
+
declare function levenshteinRatio(a: string, b: string): number;
|
|
655
|
+
/**
|
|
656
|
+
* Calculate Dice coefficient (bigram similarity)
|
|
657
|
+
* @example dice('night', 'nacht') // 0.25
|
|
658
|
+
*/
|
|
659
|
+
declare function dice(a: string, b: string): number;
|
|
660
|
+
/**
|
|
661
|
+
* Calculate Jaro-Winkler similarity
|
|
662
|
+
* @example jaroWinkler('DWAYNE', 'DUANE') // ~0.84
|
|
663
|
+
*/
|
|
664
|
+
declare function jaroWinkler(a: string, b: string): number;
|
|
665
|
+
/**
|
|
666
|
+
* Calculate Hamming distance (for equal-length strings)
|
|
667
|
+
* @example hamming('karolin', 'kathrin') // 3
|
|
668
|
+
*/
|
|
669
|
+
declare function hamming(a: string, b: string): number;
|
|
670
|
+
/**
|
|
671
|
+
* Calculate cosine similarity based on word frequency
|
|
672
|
+
* @example cosine('hello world', 'world hello') // 1.0
|
|
673
|
+
*/
|
|
674
|
+
declare function cosine(a: string, b: string): number;
|
|
675
|
+
/**
|
|
676
|
+
* Find the longest common subsequence
|
|
677
|
+
* @example lcs('ABCDGH', 'AEDFHR') // 'ADH'
|
|
678
|
+
*/
|
|
679
|
+
declare function lcs(a: string, b: string): string;
|
|
680
|
+
/**
|
|
681
|
+
* Get the length of the longest common subsequence
|
|
682
|
+
* @example lcsLength('ABCDGH', 'AEDFHR') // 3
|
|
683
|
+
*/
|
|
684
|
+
declare function lcsLength(a: string, b: string): number;
|
|
685
|
+
/**
|
|
686
|
+
* Calculate similarity using specified algorithm
|
|
687
|
+
*/
|
|
688
|
+
declare function similarity(a: string, b: string, options?: SimilarityOptions): number;
|
|
689
|
+
/**
|
|
690
|
+
* Find the best match from an array of candidates
|
|
691
|
+
* @example bestMatch('hello', ['hallo', 'hullo', 'hey']) // { match: 'hallo', score: 0.8, index: 0 }
|
|
692
|
+
*/
|
|
693
|
+
declare function bestMatch(input: string, candidates: string[], options?: SimilarityOptions): MatchResult | null;
|
|
694
|
+
/**
|
|
695
|
+
* Find all matches above a threshold
|
|
696
|
+
* @example findSimilar('apple', ['apply', 'maple', 'banana'], { threshold: 0.5 })
|
|
697
|
+
*/
|
|
698
|
+
declare function findSimilar(input: string, candidates: string[], options?: SimilarityOptions): MatchResult[];
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* Analysis Plugin
|
|
702
|
+
* Provides methods for analyzing string content
|
|
703
|
+
*/
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* Count words in a string
|
|
707
|
+
* @example wordCount('Hello world, how are you?') // 5
|
|
708
|
+
*/
|
|
709
|
+
declare function wordCount(input: string): number;
|
|
710
|
+
/**
|
|
711
|
+
* Count characters in a string
|
|
712
|
+
* @example charCount('Hello') // 5
|
|
713
|
+
* @example charCount('Hello World', { ignoreSpaces: true }) // 10
|
|
714
|
+
*/
|
|
715
|
+
declare function charCount(input: string, options?: AnalysisOptions): number;
|
|
716
|
+
/**
|
|
717
|
+
* Count lines in a string
|
|
718
|
+
* @example lineCount('line1\nline2\nline3') // 3
|
|
719
|
+
*/
|
|
720
|
+
declare function lineCount(input: string): number;
|
|
721
|
+
/**
|
|
722
|
+
* Count sentences in a string
|
|
723
|
+
* @example sentenceCount('Hello. How are you? Fine!') // 3
|
|
724
|
+
*/
|
|
725
|
+
declare function sentenceCount(input: string): number;
|
|
726
|
+
/**
|
|
727
|
+
* Count paragraphs in a string
|
|
728
|
+
* @example paragraphCount('Para 1\n\nPara 2') // 2
|
|
729
|
+
*/
|
|
730
|
+
declare function paragraphCount(input: string): number;
|
|
731
|
+
/**
|
|
732
|
+
* Get UTF-8 byte size of a string
|
|
733
|
+
* @example byteSize('Hello') // 5
|
|
734
|
+
* @example byteSize('Merhaba') // 7 (Turkish ü takes 2 bytes)
|
|
735
|
+
*/
|
|
736
|
+
declare function byteSize(input: string): number;
|
|
737
|
+
/**
|
|
738
|
+
* Calculate Shannon entropy of a string
|
|
739
|
+
* Higher entropy = more randomness/unpredictability
|
|
740
|
+
* @example entropy('password') // ~2.75 (low entropy)
|
|
741
|
+
* @example entropy('xK#9$mP@2q') // ~3.32 (high entropy)
|
|
742
|
+
*/
|
|
743
|
+
declare function entropy(input: string): number;
|
|
744
|
+
/**
|
|
745
|
+
* Get character or word frequency
|
|
746
|
+
* @example frequency('hello') // { h: 1, e: 1, l: 2, o: 1 }
|
|
747
|
+
* @example frequency('hello world', { type: 'word' }) // { hello: 1, world: 1 }
|
|
748
|
+
*/
|
|
749
|
+
declare function frequency(input: string, options?: {
|
|
750
|
+
type?: 'char' | 'word';
|
|
751
|
+
}): FrequencyResult;
|
|
752
|
+
/**
|
|
753
|
+
* Estimate reading time in minutes
|
|
754
|
+
* @example readingTime('Lorem ipsum...') // time in minutes
|
|
755
|
+
*/
|
|
756
|
+
declare function readingTime(input: string, options?: {
|
|
757
|
+
wordsPerMinute?: number;
|
|
758
|
+
}): number;
|
|
759
|
+
/**
|
|
760
|
+
* Estimate speaking time in minutes
|
|
761
|
+
* @example speakingTime('Lorem ipsum...') // time in minutes
|
|
762
|
+
*/
|
|
763
|
+
declare function speakingTime(input: string, options?: {
|
|
764
|
+
wordsPerMinute?: number;
|
|
765
|
+
}): number;
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* Pluralization Plugin
|
|
769
|
+
* Provides methods for pluralizing and singularizing words
|
|
770
|
+
*/
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* Pluralize a word
|
|
774
|
+
* @example pluralize('apple') // 'apples'
|
|
775
|
+
* @example pluralize('child') // 'children'
|
|
776
|
+
* @example pluralize('apple', 1) // 'apple'
|
|
777
|
+
* @example pluralize('apple', 5, true) // '5 apples'
|
|
778
|
+
*/
|
|
779
|
+
declare function pluralize(word: string, count?: number, showCount?: boolean, _options?: StrKitOptions): string;
|
|
780
|
+
/**
|
|
781
|
+
* Singularize a word
|
|
782
|
+
* @example singularize('apples') // 'apple'
|
|
783
|
+
* @example singularize('children') // 'child'
|
|
784
|
+
*/
|
|
785
|
+
declare function singularize(word: string, _options?: StrKitOptions): string;
|
|
786
|
+
/**
|
|
787
|
+
* Check if a word is plural
|
|
788
|
+
* @example isPlural('apples') // true
|
|
789
|
+
* @example isPlural('apple') // false
|
|
790
|
+
*/
|
|
791
|
+
declare function isPlural(word: string, _options?: StrKitOptions): boolean;
|
|
792
|
+
/**
|
|
793
|
+
* Check if a word is singular
|
|
794
|
+
* @example isSingular('apple') // true
|
|
795
|
+
* @example isSingular('apples') // false
|
|
796
|
+
*/
|
|
797
|
+
declare function isSingular(word: string, _options?: StrKitOptions): boolean;
|
|
798
|
+
/**
|
|
799
|
+
* Add a custom pluralization rule
|
|
800
|
+
* @example addPluralRule(/gex$/i, 'gexii')
|
|
801
|
+
*/
|
|
802
|
+
declare function addPluralRule(rule: RegExp, replacement: string): void;
|
|
803
|
+
/**
|
|
804
|
+
* Add an irregular word
|
|
805
|
+
* @example addIrregular('opus', 'opera')
|
|
806
|
+
*/
|
|
807
|
+
declare function addIrregular(singular: string, plural: string): void;
|
|
808
|
+
/**
|
|
809
|
+
* Add an uncountable word
|
|
810
|
+
* @example addUncountable('sheep')
|
|
811
|
+
*/
|
|
812
|
+
declare function addUncountable(word: string): void;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Diff Plugin
|
|
816
|
+
* Provides methods for computing differences between strings
|
|
817
|
+
*/
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Character-level diff using Myers algorithm
|
|
821
|
+
* @example diffChars('hello', 'hallo') // [{ type: 'equal', value: 'h' }, { type: 'remove', value: 'e' }, { type: 'add', value: 'a' }, { type: 'equal', value: 'llo' }]
|
|
822
|
+
*/
|
|
823
|
+
declare function diffChars(oldStr: string, newStr: string): DiffResult[];
|
|
824
|
+
/**
|
|
825
|
+
* Word-level diff
|
|
826
|
+
* @example diffWords('hello world', 'hello there world') // [{ type: 'equal', value: 'hello ' }, { type: 'add', value: 'there ' }, { type: 'equal', value: 'world' }]
|
|
827
|
+
*/
|
|
828
|
+
declare function diffWords(oldStr: string, newStr: string): DiffResult[];
|
|
829
|
+
/**
|
|
830
|
+
* Line-level diff
|
|
831
|
+
* @example diffLines('line1\nline2', 'line1\nline3') // [{ type: 'equal', value: 'line1\n' }, { type: 'remove', value: 'line2' }, { type: 'add', value: 'line3' }]
|
|
832
|
+
*/
|
|
833
|
+
declare function diffLines(oldStr: string, newStr: string): DiffResult[];
|
|
834
|
+
/**
|
|
835
|
+
* Generic diff with configurable granularity
|
|
836
|
+
*/
|
|
837
|
+
declare function diff(oldStr: string, newStr: string, options?: DiffOptions): DiffResult[];
|
|
838
|
+
/**
|
|
839
|
+
* Create a unified diff patch
|
|
840
|
+
* @example createPatch('file.txt', 'old content', 'new content')
|
|
841
|
+
*/
|
|
842
|
+
declare function createPatch(fileName: string, oldStr: string, newStr: string, _options?: DiffOptions): string;
|
|
843
|
+
/**
|
|
844
|
+
* Apply a patch to a string
|
|
845
|
+
* @example applyPatch(originalText, patchString)
|
|
846
|
+
*/
|
|
847
|
+
declare function applyPatch(input: string, patch: string): string;
|
|
848
|
+
/**
|
|
849
|
+
* Reverse a patch (swap add and remove)
|
|
850
|
+
*/
|
|
851
|
+
declare function reversePatch(patch: string): string;
|
|
852
|
+
|
|
853
|
+
/**
|
|
854
|
+
* Search Plugin
|
|
855
|
+
* Provides methods for searching within strings
|
|
856
|
+
*/
|
|
857
|
+
|
|
858
|
+
/**
|
|
859
|
+
* Check if string contains a substring
|
|
860
|
+
* @example contains('hello world', 'world') // true
|
|
861
|
+
* @example contains('Hello World', 'world', { caseSensitive: false }) // true
|
|
862
|
+
*/
|
|
863
|
+
declare function contains(input: string, search: string, options?: StrKitOptions): boolean;
|
|
864
|
+
/**
|
|
865
|
+
* Check if string starts with a substring
|
|
866
|
+
* @example startsWith('hello world', 'hello') // true
|
|
867
|
+
*/
|
|
868
|
+
declare function startsWith(input: string, search: string): boolean;
|
|
869
|
+
/**
|
|
870
|
+
* Check if string ends with a substring
|
|
871
|
+
* @example endsWith('hello world', 'world') // true
|
|
872
|
+
*/
|
|
873
|
+
declare function endsWith(input: string, search: string): boolean;
|
|
874
|
+
/**
|
|
875
|
+
* Find the first index of a substring
|
|
876
|
+
* @example indexOf('hello world', 'o') // 4
|
|
877
|
+
* @example indexOf('hello world', 'o', { fromIndex: 5 }) // 7
|
|
878
|
+
*/
|
|
879
|
+
declare function indexOf(input: string, search: string, options?: SearchOptions): number;
|
|
880
|
+
/**
|
|
881
|
+
* Find the last index of a substring
|
|
882
|
+
* @example lastIndexOf('hello world', 'o') // 7
|
|
883
|
+
*/
|
|
884
|
+
declare function lastIndexOf(input: string, search: string, options?: SearchOptions): number;
|
|
885
|
+
/**
|
|
886
|
+
* Count occurrences of a substring
|
|
887
|
+
* @example countOccurrences('abracadabra', 'a') // 5
|
|
888
|
+
* @example countOccurrences('hello hello', 'hello') // 2
|
|
889
|
+
*/
|
|
890
|
+
declare function countOccurrences(input: string, search: string, options?: StrKitOptions): number;
|
|
891
|
+
/**
|
|
892
|
+
* Get all positions of a substring
|
|
893
|
+
* @example positions('abracadabra', 'a') // [0, 3, 5, 7, 10]
|
|
894
|
+
*/
|
|
895
|
+
declare function positions(input: string, search: string, options?: StrKitOptions): number[];
|
|
896
|
+
/**
|
|
897
|
+
* Get the first regex match
|
|
898
|
+
* @example match('hello 123 world 456', /\d+/) // '123'
|
|
899
|
+
*/
|
|
900
|
+
declare function match(input: string, pattern: RegExp): string | null;
|
|
901
|
+
/**
|
|
902
|
+
* Get all regex matches
|
|
903
|
+
* @example matchAll('hello 123 world 456', /\d+/g) // ['123', '456']
|
|
904
|
+
*/
|
|
905
|
+
declare function matchAll(input: string, pattern: RegExp): string[];
|
|
906
|
+
/**
|
|
907
|
+
* Extract with regex groups
|
|
908
|
+
* @example extract('hello world', /(\w+) (\w+)/) // ['hello world', 'hello', 'world']
|
|
909
|
+
*/
|
|
910
|
+
declare function extract(input: string, pattern: RegExp): RegExpMatchArray | null;
|
|
911
|
+
/**
|
|
912
|
+
* Extract all with regex groups
|
|
913
|
+
* @example extractAll('a1 b2 c3', /([a-z])(\d)/g) // [['a1', 'a', '1'], ['b2', 'b', '2'], ['c3', 'c', '3']]
|
|
914
|
+
*/
|
|
915
|
+
declare function extractAll(input: string, pattern: RegExp): RegExpMatchArray[];
|
|
916
|
+
|
|
917
|
+
/**
|
|
918
|
+
* Namespace API
|
|
919
|
+
* Provides the str.* namespace for organized access to all methods
|
|
920
|
+
*/
|
|
921
|
+
|
|
922
|
+
/**
|
|
923
|
+
* The str namespace object
|
|
924
|
+
* Provides organized access to all StrKit methods
|
|
925
|
+
*
|
|
926
|
+
* @example
|
|
927
|
+
* import { str } from '@oxog/strkit';
|
|
928
|
+
*
|
|
929
|
+
* str.case.camel('hello world'); // 'helloWorld'
|
|
930
|
+
* str.validate.email('test@test.com'); // true
|
|
931
|
+
* str.similarity.levenshtein('cat', 'bat'); // 1
|
|
932
|
+
*/
|
|
933
|
+
declare const str: {
|
|
934
|
+
/**
|
|
935
|
+
* Case conversion methods
|
|
936
|
+
*/
|
|
937
|
+
case: {
|
|
938
|
+
camel: typeof camelCase;
|
|
939
|
+
kebab: typeof kebabCase;
|
|
940
|
+
snake: typeof snakeCase;
|
|
941
|
+
pascal: typeof pascalCase;
|
|
942
|
+
title: typeof titleCase;
|
|
943
|
+
sentence: typeof sentenceCase;
|
|
944
|
+
constant: typeof constantCase;
|
|
945
|
+
dot: typeof dotCase;
|
|
946
|
+
path: typeof pathCase;
|
|
947
|
+
header: typeof headerCase;
|
|
948
|
+
swap: typeof swapCase;
|
|
949
|
+
upper: typeof toUpper;
|
|
950
|
+
lower: typeof toLower;
|
|
951
|
+
capitalize: typeof capitalize;
|
|
952
|
+
decapitalize: typeof decapitalize;
|
|
953
|
+
};
|
|
954
|
+
/**
|
|
955
|
+
* String manipulation methods
|
|
956
|
+
*/
|
|
957
|
+
manipulation: {
|
|
958
|
+
trim: typeof trim;
|
|
959
|
+
trimStart: typeof trimStart;
|
|
960
|
+
trimEnd: typeof trimEnd;
|
|
961
|
+
pad: typeof pad;
|
|
962
|
+
padStart: typeof padStart;
|
|
963
|
+
padEnd: typeof padEnd;
|
|
964
|
+
repeat: typeof repeat;
|
|
965
|
+
reverse: typeof reverse;
|
|
966
|
+
truncate: typeof truncate;
|
|
967
|
+
wrap: typeof wrap;
|
|
968
|
+
unwrap: typeof unwrap;
|
|
969
|
+
splice: typeof splice;
|
|
970
|
+
insert: typeof insert;
|
|
971
|
+
remove: typeof remove;
|
|
972
|
+
replace: typeof replace;
|
|
973
|
+
replaceAll: typeof replaceAll;
|
|
974
|
+
between: typeof between;
|
|
975
|
+
before: typeof before;
|
|
976
|
+
after: typeof after;
|
|
977
|
+
beforeLast: typeof beforeLast;
|
|
978
|
+
afterLast: typeof afterLast;
|
|
979
|
+
append: typeof append;
|
|
980
|
+
prepend: typeof prepend;
|
|
981
|
+
surround: typeof surround;
|
|
982
|
+
collapseWhitespace: typeof collapseWhitespace;
|
|
983
|
+
lines: typeof lines;
|
|
984
|
+
words: typeof words;
|
|
985
|
+
chars: typeof chars;
|
|
986
|
+
};
|
|
987
|
+
/**
|
|
988
|
+
* Validation methods
|
|
989
|
+
*/
|
|
990
|
+
validate: {
|
|
991
|
+
email: typeof isEmail;
|
|
992
|
+
url: typeof isUrl;
|
|
993
|
+
uuid: typeof isUuid;
|
|
994
|
+
ip: typeof isIp;
|
|
995
|
+
ipv4: typeof isIpv4;
|
|
996
|
+
ipv6: typeof isIpv6;
|
|
997
|
+
phone: typeof isPhone;
|
|
998
|
+
creditCard: typeof isCreditCard;
|
|
999
|
+
empty: typeof isEmpty;
|
|
1000
|
+
blank: typeof isBlank;
|
|
1001
|
+
alpha: typeof isAlpha;
|
|
1002
|
+
numeric: typeof isNumeric;
|
|
1003
|
+
alphanumeric: typeof isAlphanumeric;
|
|
1004
|
+
hex: typeof isHex;
|
|
1005
|
+
base64: typeof isBase64;
|
|
1006
|
+
json: typeof isJson;
|
|
1007
|
+
upperCase: typeof isUpperCase;
|
|
1008
|
+
lowerCase: typeof isLowerCase;
|
|
1009
|
+
contains: typeof contains$1;
|
|
1010
|
+
startsWith: typeof startsWith$1;
|
|
1011
|
+
endsWith: typeof endsWith$1;
|
|
1012
|
+
equals: typeof equals;
|
|
1013
|
+
matches: typeof matches;
|
|
1014
|
+
};
|
|
1015
|
+
/**
|
|
1016
|
+
* Sanitization methods
|
|
1017
|
+
*/
|
|
1018
|
+
sanitize: {
|
|
1019
|
+
escape: typeof escape;
|
|
1020
|
+
unescape: typeof unescape;
|
|
1021
|
+
escapeHtml: typeof escapeHtml;
|
|
1022
|
+
unescapeHtml: typeof unescapeHtml;
|
|
1023
|
+
escapeRegex: typeof escapeRegex;
|
|
1024
|
+
slugify: typeof slugify;
|
|
1025
|
+
filename: typeof sanitizeFilename;
|
|
1026
|
+
stripHtml: typeof stripHtml;
|
|
1027
|
+
stripTags: typeof stripTags;
|
|
1028
|
+
clean: typeof clean;
|
|
1029
|
+
normalize: typeof normalize;
|
|
1030
|
+
latinise: typeof latinise;
|
|
1031
|
+
transliterate: typeof transliterate;
|
|
1032
|
+
};
|
|
1033
|
+
/**
|
|
1034
|
+
* Formatting methods
|
|
1035
|
+
*/
|
|
1036
|
+
format: {
|
|
1037
|
+
template: typeof template;
|
|
1038
|
+
sprintf: typeof sprintf;
|
|
1039
|
+
mask: typeof mask;
|
|
1040
|
+
unmask: typeof unmask;
|
|
1041
|
+
ordinalize: typeof ordinalize;
|
|
1042
|
+
currency: typeof formatCurrency;
|
|
1043
|
+
number: typeof formatNumber;
|
|
1044
|
+
};
|
|
1045
|
+
/**
|
|
1046
|
+
* Similarity methods
|
|
1047
|
+
*/
|
|
1048
|
+
similarity: {
|
|
1049
|
+
levenshtein: typeof levenshtein;
|
|
1050
|
+
levenshteinRatio: typeof levenshteinRatio;
|
|
1051
|
+
dice: typeof dice;
|
|
1052
|
+
jaroWinkler: typeof jaroWinkler;
|
|
1053
|
+
hamming: typeof hamming;
|
|
1054
|
+
cosine: typeof cosine;
|
|
1055
|
+
lcs: typeof lcs;
|
|
1056
|
+
lcsLength: typeof lcsLength;
|
|
1057
|
+
similarity: typeof similarity;
|
|
1058
|
+
bestMatch: typeof bestMatch;
|
|
1059
|
+
findSimilar: typeof findSimilar;
|
|
1060
|
+
};
|
|
1061
|
+
/**
|
|
1062
|
+
* Analysis methods
|
|
1063
|
+
*/
|
|
1064
|
+
analysis: {
|
|
1065
|
+
wordCount: typeof wordCount;
|
|
1066
|
+
charCount: typeof charCount;
|
|
1067
|
+
lineCount: typeof lineCount;
|
|
1068
|
+
sentenceCount: typeof sentenceCount;
|
|
1069
|
+
paragraphCount: typeof paragraphCount;
|
|
1070
|
+
byteSize: typeof byteSize;
|
|
1071
|
+
entropy: typeof entropy;
|
|
1072
|
+
frequency: typeof frequency;
|
|
1073
|
+
readingTime: typeof readingTime;
|
|
1074
|
+
speakingTime: typeof speakingTime;
|
|
1075
|
+
};
|
|
1076
|
+
/**
|
|
1077
|
+
* Pluralization methods
|
|
1078
|
+
*/
|
|
1079
|
+
plural: {
|
|
1080
|
+
plural: typeof pluralize;
|
|
1081
|
+
singular: typeof singularize;
|
|
1082
|
+
isPlural: typeof isPlural;
|
|
1083
|
+
isSingular: typeof isSingular;
|
|
1084
|
+
addRule: typeof addPluralRule;
|
|
1085
|
+
addIrregular: typeof addIrregular;
|
|
1086
|
+
addUncountable: typeof addUncountable;
|
|
1087
|
+
};
|
|
1088
|
+
/**
|
|
1089
|
+
* Diff methods
|
|
1090
|
+
*/
|
|
1091
|
+
diff: {
|
|
1092
|
+
diff: typeof diff;
|
|
1093
|
+
diffChars: typeof diffChars;
|
|
1094
|
+
diffWords: typeof diffWords;
|
|
1095
|
+
diffLines: typeof diffLines;
|
|
1096
|
+
createPatch: typeof createPatch;
|
|
1097
|
+
applyPatch: typeof applyPatch;
|
|
1098
|
+
reversePatch: typeof reversePatch;
|
|
1099
|
+
};
|
|
1100
|
+
/**
|
|
1101
|
+
* Search methods
|
|
1102
|
+
*/
|
|
1103
|
+
search: {
|
|
1104
|
+
contains: typeof contains;
|
|
1105
|
+
startsWith: typeof startsWith;
|
|
1106
|
+
endsWith: typeof endsWith;
|
|
1107
|
+
indexOf: typeof indexOf;
|
|
1108
|
+
lastIndexOf: typeof lastIndexOf;
|
|
1109
|
+
countOccurrences: typeof countOccurrences;
|
|
1110
|
+
positions: typeof positions;
|
|
1111
|
+
match: typeof match;
|
|
1112
|
+
matchAll: typeof matchAll;
|
|
1113
|
+
extract: typeof extract;
|
|
1114
|
+
extractAll: typeof extractAll;
|
|
1115
|
+
};
|
|
1116
|
+
};
|
|
1117
|
+
|
|
1118
|
+
/**
|
|
1119
|
+
* Set the global locale
|
|
1120
|
+
*/
|
|
1121
|
+
declare function setLocale(code: string): void;
|
|
1122
|
+
/**
|
|
1123
|
+
* Get the current locale code
|
|
1124
|
+
*/
|
|
1125
|
+
declare function getLocale(): string;
|
|
1126
|
+
/**
|
|
1127
|
+
* Register a custom locale
|
|
1128
|
+
*/
|
|
1129
|
+
declare function registerLocale(locale: StrKitLocale): void;
|
|
1130
|
+
/**
|
|
1131
|
+
* Get all available locale codes
|
|
1132
|
+
*/
|
|
1133
|
+
declare function getAvailableLocales(): string[];
|
|
1134
|
+
|
|
1135
|
+
/**
|
|
1136
|
+
* Register a plugin with StrKit
|
|
1137
|
+
*/
|
|
1138
|
+
declare function registerPlugin(plugin: StrKitPlugin): void;
|
|
1139
|
+
/**
|
|
1140
|
+
* Get all registered plugins
|
|
1141
|
+
*/
|
|
1142
|
+
declare function getPlugins(): StrKitPlugin[];
|
|
1143
|
+
/**
|
|
1144
|
+
* Check if a plugin is registered
|
|
1145
|
+
*/
|
|
1146
|
+
declare function hasPlugin(name: string): boolean;
|
|
1147
|
+
|
|
1148
|
+
export { AnalysisOptions, CurrencyOptions, DiffOptions, DiffResult, FrequencyResult, MaskOptions, MatchResult, S, SearchOptions, SimilarityOptions, SlugifyOptions, type StrKitChain, StrKitLocale, StrKitOptions, StrKitPlugin, TemplateOptions, TruncateOptions, addIrregular, addPluralRule, addUncountable, after, afterLast, append, applyPatch, before, beforeLast, bestMatch, between, byteSize, camelCase, capitalize, charCount, chars, clean, collapseWhitespace, constantCase, contains$1 as contains, cosine, countOccurrences, createPatch, decapitalize, dice, diff, diffChars, diffLines, diffWords, dotCase, endsWith$1 as endsWith, entropy, equals, escape, escapeHtml, escapeRegex, extract, extractAll, findSimilar, formatCurrency, formatNumber, frequency, getAvailableLocales, getLocale, getPlugins, hamming, hasPlugin, headerCase, indexOf, insert, isAlpha, isAlphanumeric, isBase64, isBlank, isCreditCard, isEmail, isEmpty, isHex, isIp, isIpv4, isIpv6, isJson, isLowerCase, isNumeric, isPhone, isPlural, isSingular, isUpperCase, isUrl, isUuid, jaroWinkler, kebabCase, lastIndexOf, latinise, lcs, lcsLength, levenshtein, levenshteinRatio, lineCount, lines, mask, match, matchAll, matches, normalize, ordinalize, pad, padEnd, padStart, paragraphCount, pascalCase, pathCase, pluralize, positions, prepend, readingTime, registerLocale, registerPlugin, remove, repeat, replace, replaceAll, reverse, reversePatch, sanitizeFilename, sentenceCase, sentenceCount, setLocale, similarity, singularize, slugify, snakeCase, speakingTime, splice, sprintf, startsWith$1 as startsWith, str, stripHtml, stripTags, surround, swapCase, template, titleCase, toLower, toUpper, transliterate, trim, trimEnd, trimStart, truncate, unescape, unescapeHtml, unmask, unwrap, wordCount, words, wrap };
|