@zinaid/str 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/ascii/index.d.ts +14 -0
  2. package/dist/ascii/index.d.ts.map +1 -0
  3. package/dist/ascii/index.js +7 -0
  4. package/dist/base64/index.d.ts +23 -0
  5. package/dist/base64/index.d.ts.map +1 -0
  6. package/dist/base64/index.js +124 -0
  7. package/dist/{convertcase.d.ts → convertcase/index.d.ts} +11 -1
  8. package/dist/convertcase/index.d.ts.map +1 -0
  9. package/dist/index.d.ts +4 -0
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +136 -131
  12. package/dist/markdown/index.d.ts +49 -0
  13. package/dist/markdown/index.d.ts.map +1 -0
  14. package/dist/markdown/index.js +32 -0
  15. package/dist/pluralizer/index.d.ts +100 -0
  16. package/dist/pluralizer/index.d.ts.map +1 -0
  17. package/dist/{pluralizer.js → pluralizer/index.js} +39 -32
  18. package/dist/{random.d.ts → random/index.d.ts} +3 -3
  19. package/dist/random/index.d.ts.map +1 -0
  20. package/dist/{random.js → random/index.js} +2 -1
  21. package/dist/replacer/index.d.ts +31 -0
  22. package/dist/replacer/index.d.ts.map +1 -0
  23. package/dist/str.d.ts +308 -173
  24. package/dist/str.d.ts.map +1 -1
  25. package/dist/str.js +510 -661
  26. package/dist/stringable/index.d.ts +952 -0
  27. package/dist/stringable/index.d.ts.map +1 -0
  28. package/dist/{stringable.js → stringable/index.js} +400 -13
  29. package/dist/transliterate/index.d.ts +14 -0
  30. package/dist/transliterate/index.d.ts.map +1 -0
  31. package/dist/transliterate/index.js +7 -0
  32. package/dist/trimmer/index.d.ts +25 -0
  33. package/dist/trimmer/index.d.ts.map +1 -0
  34. package/dist/ulid/index.d.ts +79 -0
  35. package/dist/ulid/index.d.ts.map +1 -0
  36. package/dist/ulid/index.js +58 -0
  37. package/dist/uuid/index.d.ts +92 -0
  38. package/dist/uuid/index.d.ts.map +1 -0
  39. package/dist/uuid/index.js +50 -0
  40. package/package.json +78 -21
  41. package/dist/base64.d.ts +0 -7
  42. package/dist/base64.d.ts.map +0 -1
  43. package/dist/base64.js +0 -123
  44. package/dist/convertcase.d.ts.map +0 -1
  45. package/dist/markdown.d.ts +0 -26
  46. package/dist/markdown.d.ts.map +0 -1
  47. package/dist/markdown.js +0 -55
  48. package/dist/pluralizer.d.ts +0 -38
  49. package/dist/pluralizer.d.ts.map +0 -1
  50. package/dist/random.d.ts.map +0 -1
  51. package/dist/replacer.d.ts +0 -31
  52. package/dist/replacer.d.ts.map +0 -1
  53. package/dist/stringable.d.ts +0 -555
  54. package/dist/stringable.d.ts.map +0 -1
  55. package/dist/trimmer.d.ts +0 -4
  56. package/dist/trimmer.d.ts.map +0 -1
  57. /package/dist/{convertcase.js → convertcase/index.js} +0 -0
  58. /package/dist/{replacer.js → replacer/index.js} +0 -0
  59. /package/dist/{trimmer.js → trimmer/index.js} +0 -0
@@ -0,0 +1,952 @@
1
+ import { ConvertCaseMode, MarkDownExtensions, MarkDownOptions } from '../index.ts';
2
+ export type ConditionableValue = string | number | boolean | ((instance: Stringable) => string | number | boolean);
3
+ export type ConditionableClosure = ((instance: Stringable, value: ConditionableValue) => unknown) | null;
4
+ /**
5
+ * Get a new stringable object from the given string.
6
+ *
7
+ * @param value - The string value to wrap in a Stringable instance.
8
+ * @returns A new Stringable instance.
9
+ *
10
+ * @example
11
+ *
12
+ * of('foo').append('bar'); -> 'foobar'
13
+ */
14
+ export declare function of(value: string): Stringable;
15
+ /**
16
+ * Get a new stringable object from the given string.
17
+ *
18
+ * @param value - The string value to wrap in a Stringable instance.
19
+ * @returns A new Stringable instance.
20
+ *
21
+ * @example
22
+ *
23
+ * str('foo').append('bar'); -> 'foobar'
24
+ */
25
+ export declare function str(value: string): Stringable;
26
+ export declare class Stringable {
27
+ private readonly _value;
28
+ /**
29
+ * Create a new instance of the class.
30
+ *
31
+ * @param _value - The initial string value. Defaults to an empty string.
32
+ */
33
+ constructor(_value?: string);
34
+ /**
35
+ * Return the remainder of a string after the first occurrence of a given value.
36
+ *
37
+ * @param search - The substring to search for.
38
+ * @returns The portion of the string after the first occurrence of the search value.
39
+ */
40
+ after(search: string | number): Stringable;
41
+ /**
42
+ * Return the remainder of a string after the last occurrence of a given value
43
+ *
44
+ * @param search - The substring to search for.
45
+ * @returns The portion of the string after the last occurrence of the search value.
46
+ */
47
+ afterLast(search: string | number): Stringable;
48
+ /**
49
+ * Append the given values to the string.
50
+ *
51
+ * @param values - The values to append to the string.
52
+ * @returns The updated Stringable instance.
53
+ */
54
+ append(...values: Array<string | number>): Stringable;
55
+ /**
56
+ * Append a new line to the string.
57
+ *
58
+ * @param count - The number of new lines to append. Defaults to 1.
59
+ * @returns The updated Stringable instance.
60
+ */
61
+ newLine(count?: number): Stringable;
62
+ /**
63
+ * Transliterate a UTF-8 value to ASCII.
64
+ *
65
+ * @returns The transliterated string as a new Stringable instance.
66
+ */
67
+ ascii(): Stringable;
68
+ /**
69
+ * Get the portion of a string before the first occurrence of a given value.
70
+ *
71
+ * @param search - The substring to search for.
72
+ * @returns The portion of the string before the first occurrence of the search value.
73
+ */
74
+ before(search: string | number): Stringable;
75
+ /**
76
+ * Get the portion of a string before the last occurrence of a given value.
77
+ *
78
+ * @param search - The substring to search for.
79
+ * @returns The portion of the string before the last occurrence of the search value.
80
+ */
81
+ beforeLast(search: string | number): Stringable;
82
+ /**
83
+ * Get the portion of a string between two given values.
84
+ *
85
+ * @param from - The starting substring.
86
+ * @param to - The ending substring.
87
+ * @returns The portion of the string between the two given values.
88
+ */
89
+ between(from: string | number, to: string | number): Stringable;
90
+ /**
91
+ * Get the smallest possible portion of a string between two given values.
92
+ *
93
+ * @param from - The starting substring.
94
+ * @param to - The ending substring.
95
+ * @returns The smallest possible portion of the string between the two given values.
96
+ */
97
+ betweenFirst(from: string | number, to: string | number): Stringable;
98
+ /**
99
+ * Convert a value to camel case.
100
+ *
101
+ * @returns The camel-cased string as a new Stringable instance.
102
+ */
103
+ camel(): Stringable;
104
+ /**
105
+ * Get the character at the specified index.
106
+ *
107
+ * @param index - The index of the character to retrieve.
108
+ * @returns The character at the specified index, or false if the index is out of bounds.
109
+ */
110
+ charAt(index: number): string | false;
111
+ /**
112
+ * Remove the given string if it exists at the start of the current string.
113
+ *
114
+ * @param needle - The string or array of strings to remove from the start.
115
+ * @returns The updated Stringable instance.
116
+ */
117
+ chopStart(needle: string | string[]): Stringable;
118
+ /**
119
+ * Remove the given string if it exists at the end of the current string.
120
+ *
121
+ * @param needle - The string or array of strings to remove from the end.
122
+ * @returns The updated Stringable instance.
123
+ */
124
+ chopEnd(needle: string | string[]): Stringable;
125
+ /**
126
+ * Determine if a given string contains a given substring.
127
+ *
128
+ * @param needles - The substring(s) to search for
129
+ * @param ignoreCase - Whether the search should be case-insensitive
130
+ * @returns boolean - True if the substring(s) are found, false otherwise
131
+ */
132
+ contains(needles: string | Iterable<string>, ignoreCase?: boolean): boolean;
133
+ /**
134
+ * Determine if a given string contains all array values.
135
+ *
136
+ * @param needles - The substring(s) to search for
137
+ * @param ignoreCase - Whether the search should be case-insensitive
138
+ * @returns boolean - True if all substring(s) are found, false otherwise
139
+ */
140
+ containsAll(needles: Iterable<string>, ignoreCase?: boolean): boolean;
141
+ /**
142
+ * Determine if a given string doesn't contain a given substring.
143
+ *
144
+ * @param needles - The substring(s) to search for
145
+ * @param ignoreCase - Whether the search should be case-insensitive
146
+ * @returns boolean - True if the substring(s) are not found, false otherwise
147
+ */
148
+ doesntContain(needles: string | Iterable<string>, ignoreCase?: boolean): boolean;
149
+ /**
150
+ * Convert the case of a string.
151
+ *
152
+ * @param mode - The case conversion mode to apply.
153
+ * @returns The converted string as a new Stringable instance.
154
+ */
155
+ convertCase(mode: ConvertCaseMode): Stringable;
156
+ /**
157
+ * Replace consecutive instances of a given character with a single character.
158
+ *
159
+ * @param character - The character or array of characters to deduplicate. Defaults to a space.
160
+ * @returns The updated Stringable instance.
161
+ */
162
+ deduplicate(character?: string | string[]): Stringable;
163
+ /**
164
+ * Determine if a given string ends with a given substring.
165
+ *
166
+ * @param needles - The substring(s) to search for
167
+ * @returns boolean - True if the substring(s) are found, false otherwise
168
+ */
169
+ endsWith(needles: string | number | Iterable<string>): boolean;
170
+ /**
171
+ * Determine if a given string doesn't end with a given substring.
172
+ *
173
+ * @param needles - The substring(s) to search for
174
+ * @returns boolean - True if the substring(s) are not found, false otherwise
175
+ */
176
+ doesntEndWith(needles: string | number | Iterable<string>): boolean;
177
+ /**
178
+ * Determine if the string is an exact match with the given value.
179
+ *
180
+ * @param value - The value to compare against.
181
+ * @returns True if the strings are exactly the same, false otherwise.
182
+ */
183
+ exactly(value: Stringable | string): boolean;
184
+ /**
185
+ * Extracts an excerpt from text that matches the first instance of a phrase.
186
+ *
187
+ * @param phrase - The phrase to search for within the text.
188
+ * @param options - Options to customize the excerpt extraction, including radius and omission string.
189
+ * @returns The extracted excerpt or null if the phrase is not found.
190
+ */
191
+ excerpt(phrase?: string | null, options?: {
192
+ radius?: number;
193
+ omission?: string;
194
+ }): string | null;
195
+ /**
196
+ * Explode the string into an array
197
+ *
198
+ * @param delimiter - The delimiter string to split the string by.
199
+ * @param limit - The maximum number of elements to return. Defaults to Number.MAX_SAFE_INTEGER.
200
+ * @returns An array of strings obtained by splitting the original string.
201
+ */
202
+ explode(delimiter: string, limit?: number): string[];
203
+ /**
204
+ * Split a string using a regular expression or by length.
205
+ *
206
+ * @param pattern - The regex pattern or length to split the string by.
207
+ * @param limit - The maximum number of splits to perform. Defaults to null (no limit).
208
+ * @returns An array of strings obtained by splitting the original string.
209
+ */
210
+ split(pattern: string | number, limit?: number | null): string[];
211
+ /**
212
+ * Cap a string with a single instance of a given value.
213
+ *
214
+ * @param cap - The string to cap the original string with.
215
+ * @returns The updated Stringable instance.
216
+ */
217
+ finish(cap: string): Stringable;
218
+ /**
219
+ * Determine if a given string matches a given pattern.
220
+ *
221
+ * @param pattern - The pattern(s) to match against
222
+ * @returns boolean - True if the pattern(s) match, false otherwise
223
+ */
224
+ is(pattern: string | Iterable<string>, ignoreCase?: boolean): boolean;
225
+ /**
226
+ * Determine if a given string is 7 bit ASCII.
227
+ *
228
+ * @returns True if the string is ASCII, false otherwise.
229
+ */
230
+ isAscii(): boolean;
231
+ /**
232
+ * Determine if a given string is valid JSON.
233
+ *
234
+ * @returns True if the string is valid JSON, false otherwise.
235
+ */
236
+ isJson(): boolean;
237
+ /**
238
+ * Determine if a given value is a valid URL.
239
+ *
240
+ * @param protocols - An array of allowed protocols (e.g., ['http', 'https']).
241
+ * @returns True if the string is a valid URL, false otherwise.
242
+ */
243
+ isUrl(protocols?: string[]): boolean;
244
+ /**
245
+ * Determine if a given string is a valid UUID.
246
+ *
247
+ * @param version - The UUID version to validate against (1-5), "nil", "max", or null for any version.
248
+ * @returns True if the string is a valid UUID, false otherwise.
249
+ */
250
+ isUuid(version?: number | "nil" | "max" | null): boolean;
251
+ /**
252
+ * Determine if a given string is a valid ULID.
253
+ *
254
+ * @return True if the string is a valid ULID, false otherwise.
255
+ */
256
+ isUlid(): boolean;
257
+ /**
258
+ * Determine if the given string is empty.
259
+ *
260
+ * @return True if the string is empty, false otherwise.
261
+ */
262
+ isEmpty(): boolean;
263
+ /**
264
+ * Determine if the given string is not empty.
265
+ *
266
+ * @return True if the string is not empty, false otherwise.
267
+ */
268
+ isNotEmpty(): boolean;
269
+ /**
270
+ * Convert a string to kebab case.
271
+ *
272
+ * @returns The kebab-cased string as a new Stringable instance.
273
+ */
274
+ kebab(): Stringable;
275
+ /**
276
+ * Return the length of the given string.
277
+ *
278
+ * @returns The length of the string.
279
+ */
280
+ length(): number;
281
+ /**
282
+ * Limit the number of characters in a string.
283
+ *
284
+ * @param limitValue - The maximum number of characters allowed.
285
+ * @param end - The string to append if the original string exceeds the limit.
286
+ * @param preserveWords - Whether to avoid cutting off in the middle of a word.
287
+ * @returns A new Stringable instance with the limited string.
288
+ */
289
+ limit(limitValue?: number, end?: string, preserveWords?: boolean): Stringable;
290
+ /**
291
+ * Convert the given string to lower-case.
292
+ *
293
+ * @returns The lower-cased string as a new Stringable instance.
294
+ */
295
+ lower(): Stringable;
296
+ /**
297
+ * Convert GitHub flavored Markdown into HTML.
298
+ *
299
+ * @param options - Options to customize the markdown rendering. Defaults to GFM enabled and no anchors.
300
+ * @param extensions - An array of markdown-it extensions to apply during rendering.
301
+ * @returns The resulting HTML string as a new Stringable instance.
302
+ */
303
+ markdown(options?: MarkDownOptions, extensions?: MarkDownExtensions): Stringable;
304
+ /**
305
+ * Convert inline Markdown into HTML.
306
+ *
307
+ * @param options - Options to customize the markdown rendering. Defaults to GFM enabled.
308
+ * @param extensions - An array of markdown-it extensions to apply during rendering.
309
+ * @returns The resulting HTML string as a new Stringable instance.
310
+ */
311
+ inlineMarkdown(options?: MarkDownOptions, extensions?: MarkDownExtensions): Stringable;
312
+ /**
313
+ * Masks a portion of a string with a repeated character.
314
+ *
315
+ * @param character - The character to use for masking.
316
+ * @param index - The starting index to begin masking.
317
+ * @param length - The number of characters to mask. If null, masks to the end of the string.
318
+ * @returns The masked string as a new Stringable instance.
319
+ */
320
+ mask(character: string, index: number, length?: number | null): Stringable;
321
+ /**
322
+ * Get the string matching the given pattern.
323
+ *
324
+ * @param pattern - The pattern to match against.
325
+ * @returns A new Stringable instance containing the matched string.
326
+ */
327
+ match(pattern: string): Stringable;
328
+ /**
329
+ * Determine if a given string matches a given pattern.
330
+ *
331
+ * @param pattern - The pattern(s) to match against
332
+ * @returns boolean - True if the pattern(s) match, false otherwise
333
+ */
334
+ isMatch(pattern: string | Iterable<string>): boolean;
335
+ /**
336
+ * Get the string matching the given pattern.
337
+ *
338
+ * @param pattern - The pattern to match against.
339
+ * @returns An array of all matched strings.
340
+ */
341
+ matchAll(pattern: string): string[];
342
+ /**
343
+ * Determine if the string matches the given pattern.
344
+ *
345
+ * @param pattern - The pattern(s) to match against
346
+ * @returns boolean - True if the pattern(s) match, false otherwise
347
+ */
348
+ test(pattern: string): boolean;
349
+ /**
350
+ * Remove all non-numeric characters from a string.
351
+ *
352
+ * @returns The numeric string as a new Stringable instance.
353
+ */
354
+ numbers(): Stringable;
355
+ /**
356
+ * Pad both sides of the string with another.
357
+ *
358
+ * @param length - The desired total length of the string after padding.
359
+ * @param pad - The string to use for padding. Defaults to a space.
360
+ * @returns The padded string as a new Stringable instance.
361
+ */
362
+ padBoth(length: number, pad?: string): Stringable;
363
+ /**
364
+ * Pad the left side of the string with another.
365
+ *
366
+ * @param length - The desired total length of the string after padding.
367
+ * @param pad - The string to use for padding. Defaults to a space.
368
+ * @returns The padded string as a new Stringable instance.
369
+ */
370
+ padLeft(length: number, pad?: string): Stringable;
371
+ /**
372
+ * Pad the right side of the string with another.
373
+ *
374
+ * @param length - The desired total length of the string after padding.
375
+ * @param pad - The string to use for padding. Defaults to a space.
376
+ * @returns The padded string as a new Stringable instance.
377
+ */
378
+ padRight(length: number, pad?: string): Stringable;
379
+ /**
380
+ * Call the given callback and return a new string.
381
+ *
382
+ * @param callback - The callback function to process the string.
383
+ * @returns The processed string as a new Stringable instance.
384
+ */
385
+ pipe<T = Stringable | string>(callback: (s: Stringable) => T): Stringable;
386
+ /**
387
+ * Get the plural form of an English word.
388
+ *
389
+ * @param count - The count to determine singular or plural form. Defaults to 2.
390
+ * @param prependCount - Whether to prepend the count to the result. Defaults to false.
391
+ * @returns The pluralized string as a new Stringable instance.
392
+ */
393
+ plural(count?: number, prependCount?: boolean): Stringable;
394
+ /**
395
+ * Pluralize the last word of an English, studly caps case string.
396
+ *
397
+ * @param count - The count to determine singular or plural form. Defaults to 2.
398
+ * @returns The pluralized string as a new Stringable instance.
399
+ */
400
+ pluralStudly(count?: number): Stringable;
401
+ /**
402
+ * Pluralize the last word of an English, Pascal caps case string.
403
+ *
404
+ * @param count - The count to determine singular or plural form. Defaults to 2.
405
+ * @returns The pluralized string as a new Stringable instance.
406
+ */
407
+ pluralPascal(count?: number): Stringable;
408
+ /**
409
+ * Find the multi-byte safe position of the first occurrence of the given substring.
410
+ *
411
+ * @param needle - The substring to search for.
412
+ * @param offset - The offset from which to start the search. Defaults to 0.
413
+ * @returns The position of the first occurrence of the substring, or false if not found.
414
+ */
415
+ position(needle: string, offset?: number): number | false;
416
+ /**
417
+ * Prepend the given values to the string.
418
+ *
419
+ * @param values - The values to prepend to the string.
420
+ * @returns The updated Stringable instance.
421
+ */
422
+ prepend(...values: Array<string | number>): Stringable;
423
+ /**
424
+ * Remove any occurrence of the given string in the subject.
425
+ *
426
+ * @param search - The string or iterable of strings to remove.
427
+ * @param caseSensitive - Whether the search should be case-sensitive. Defaults to true.
428
+ * @returns The updated Stringable instance.
429
+ */
430
+ remove(search: string | Iterable<string>, caseSensitive?: boolean): Stringable;
431
+ /**
432
+ * Reverse the string.
433
+ *
434
+ * @returns The reversed string as a new Stringable instance.
435
+ */
436
+ reverse(): Stringable;
437
+ /**
438
+ * Repeat the string.
439
+ *
440
+ * @param times - The number of times to repeat the string.
441
+ * @returns The repeated string as a new Stringable instance.
442
+ */
443
+ repeat(times: number): Stringable;
444
+ /**
445
+ * Replace the given value in the given string.
446
+ *
447
+ * @param search - The value or iterable of values to search for.
448
+ * @param replacement - The replacement value or iterable of values.
449
+ * @param caseSensitive - Whether the search should be case-sensitive. Defaults to true.
450
+ * @returns The updated Stringable instance.
451
+ */
452
+ replace(search: string | Iterable<string>, replacement: string | Iterable<string>, caseSensitive?: boolean): Stringable;
453
+ /**
454
+ * Replace a given value in the string sequentially with an array.
455
+ *
456
+ * @param search - The value to search for.
457
+ * @param replace - The array or record of replacements.
458
+ * @returns The updated Stringable instance.
459
+ */
460
+ replaceArray(search: string, replace: Record<string, string> | Iterable<string>): Stringable;
461
+ /**
462
+ * Replace the first occurrence of a given value in the string.
463
+ *
464
+ * @param search - The value to search for.
465
+ * @param replace - The replacement value.
466
+ * @returns The updated Stringable instance.
467
+ */
468
+ replaceFirst(search: string | number, replace: string): Stringable;
469
+ /**
470
+ * Replace the first occurrence of the given value if it appears at the start of the string.
471
+ *
472
+ * @param search - The value to search for.
473
+ * @param replace - The replacement value.
474
+ * @returns The updated Stringable instance.
475
+ */
476
+ replaceStart(search: string | number, replace: string): Stringable;
477
+ /**
478
+ * Replace the last occurrence of a given value in the string.
479
+ *
480
+ * @param search - The value to search for.
481
+ * @param replace - The replacement value.
482
+ * @returns The updated Stringable instance.
483
+ */
484
+ replaceLast(search: string | number, replace: string): Stringable;
485
+ /**
486
+ * Replace the last occurrence of a given value if it appears at the end of the string.
487
+ *
488
+ * @param search - The value to search for.
489
+ * @param replace - The replacement value.
490
+ * @returns The updated Stringable instance.
491
+ */
492
+ replaceEnd(search: string | number, replace: string): Stringable;
493
+ /**
494
+ * Replace the patterns matching the given regular expression.
495
+ *
496
+ * @param pattern - The pattern(s) to search for.
497
+ * @param replace - The replacement string(s) or a callback function.
498
+ * @param limit - The maximum number of replacements to perform. Defaults to -1 (no limit).
499
+ * @returns The updated Stringable instance.
500
+ */
501
+ replaceMatches(pattern: string | string[] | RegExp | RegExp[], replace: string | string[] | ((match: string[]) => string), limit?: number): Stringable;
502
+ /**
503
+ * Parse input from a string to an array, according to a format.
504
+ *
505
+ * @param format - A format string like "%d", "%s", "%[^,],%s", etc.
506
+ * @returns Array of parsed values according to the format
507
+ *
508
+ * @example
509
+ *
510
+ * Str.of("SN/123456").scan("SN/%d") -> ["123456"]
511
+ * Str.of("Otwell, Taylor").scan("%[^,],%s") -> ["Otwell", "Taylor"]
512
+ * Str.of("filename.jpg").scan("%[^.].%s") -> ["filename", "jpg"]
513
+ */
514
+ scan(format: string): string[];
515
+ /**
516
+ * Remove all "extra" blank space from the given string.
517
+ *
518
+ * @returns The updated Stringable instance.
519
+ */
520
+ squish(): Stringable;
521
+ /**
522
+ * Begin a string with a single instance of a given value.
523
+ *
524
+ * @param prefix - The string to start the original string with.
525
+ * @returns The updated Stringable instance.
526
+ */
527
+ start(prefix: string): Stringable;
528
+ /**
529
+ * Strip HTML and PHP tags from the given string.
530
+ *
531
+ * @returns The updated Stringable instance.
532
+ */
533
+ stripTags(): Stringable;
534
+ /**
535
+ * Convert the given string to upper-case.
536
+ *
537
+ * @returns The upper-cased string as a new Stringable instance.
538
+ */
539
+ upper(): Stringable;
540
+ /**
541
+ * Convert the given string to proper case.
542
+ *
543
+ * @returns The title-cased string as a new Stringable instance.
544
+ */
545
+ title(): Stringable;
546
+ /**
547
+ * Convert the given string to proper case for each word.
548
+ *
549
+ * @returns The headline-cased string as a new Stringable instance.
550
+ */
551
+ headline(): Stringable;
552
+ /**
553
+ * Convert the given string to APA-style title case.
554
+ *
555
+ * @returns The APA title-cased string as a new Stringable instance.
556
+ */
557
+ apa(): Stringable;
558
+ /**
559
+ * Transliterate a string to its closest ASCII representation.
560
+ *
561
+ * @returns The transliterated string as a new Stringable instance.
562
+ */
563
+ transliterate(): Stringable;
564
+ /**
565
+ * Get the singular form of an English word.
566
+ *
567
+ * @returns The singularized string as a new Stringable instance.
568
+ */
569
+ singular(): Stringable;
570
+ /**
571
+ * Generate a URL friendly "slug" from a given string.
572
+ *
573
+ * @param separator - The separator to use in the slug. Defaults to "-".
574
+ * @param dictionary - A dictionary of characters to replace. Defaults to { "@": "at" }.
575
+ * @returns The slugified string as a new Stringable instance.
576
+ */
577
+ slug(separator?: string, dictionary?: Record<string, string>): Stringable;
578
+ /**
579
+ * Convert a string to snake case.
580
+ *
581
+ * @param delimiter - The delimiter to use in the snake case. Defaults to "_".
582
+ * @returns The snake-cased string as a new Stringable instance.
583
+ */
584
+ snake(delimiter?: string): Stringable;
585
+ /**
586
+ * Determine if a given string starts with a given substring.
587
+ *
588
+ * @param needles - The substring(s) to search for
589
+ * @returns boolean - True if the substring(s) are found, false otherwise
590
+ */
591
+ startsWith(needles: string | number | null | Iterable<string | number | null>): boolean;
592
+ /**
593
+ * Determine if a given string doesn't start with a given substring.
594
+ *
595
+ * @param needles - The substring(s) to search for
596
+ * @returns boolean - True if the substring(s) are not found, false otherwise
597
+ */
598
+ doesntStartWith(needles: string | number | null | Iterable<string | number | null>): boolean;
599
+ /**
600
+ * Convert a value to studly caps case.
601
+ *
602
+ * @returns The studly-cased string as a new Stringable instance.
603
+ */
604
+ studly(): Stringable;
605
+ /**
606
+ * Convert the string to Pascal case.
607
+ *
608
+ * @returns The pascal-cased string as a new Stringable instance.
609
+ */
610
+ pascal(): Stringable;
611
+ /**
612
+ * Returns the portion of the string specified by the start and length parameters.
613
+ *
614
+ * @param start - The starting position of the substring.
615
+ * @param length - The length of the substring. If null, extracts to the end of the string.
616
+ * @returns The extracted substring as a new Stringable instance.
617
+ */
618
+ substr(start: number, length?: number | null): Stringable;
619
+ /**
620
+ * Returns the number of substring occurrences.
621
+ *
622
+ * @param needle - The substring to search for.
623
+ * @param offset - The offset to start searching from. Defaults to 0.
624
+ * @param length - The length of the string to search within. If null, searches to the end of the string.
625
+ * @returns The number of occurrences of the substring.
626
+ */
627
+ substrCount(needle: string, offset?: number, length?: number | null): number;
628
+ /**
629
+ * Replace text within a portion of a string.
630
+ *
631
+ * @param replace - The replacement string.
632
+ * @param offset - The starting position to begin replacing.
633
+ * @param length - The number of characters to replace. If null, replaces to the end of the string.
634
+ * @returns The updated Stringable instance.
635
+ */
636
+ substrReplace(replace: string, offset?: number | number[], length?: number | number[] | null): Stringable;
637
+ /**
638
+ * Swap multiple keywords in a string with other keywords.
639
+ *
640
+ * @param map - A record of keywords to swap (key: search, value: replacement).
641
+ * @returns The updated Stringable instance.
642
+ */
643
+ swap(map: Record<string, string>): Stringable;
644
+ /**
645
+ * Take the first or last {$limit} characters.
646
+ *
647
+ * @param limit - The number of characters to take. Positive for start, negative for end.
648
+ * @returns The resulting substring as a new Stringable instance.
649
+ */
650
+ take(limit: number): Stringable;
651
+ /**
652
+ * Trim the string of the given characters.
653
+ *
654
+ * @param charlist - The characters to trim from the string. If null, trims whitespace.
655
+ * @returns The trimmed string as a new Stringable instance.
656
+ */
657
+ trim(charlist?: string | null): Stringable;
658
+ /**
659
+ * Left trim the string of the given characters.
660
+ *
661
+ * @param charlist - The characters to trim from the start of the string. If null, trims whitespace.
662
+ * @returns The left-trimmed string as a new Stringable instance.
663
+ */
664
+ ltrim(charlist?: string | null): Stringable;
665
+ /**
666
+ * Right trim the string of the given characters.
667
+ *
668
+ * @param charlist - The characters to trim from the end of the string. If null, trims whitespace.
669
+ * @returns The right-trimmed string as a new Stringable instance.
670
+ */
671
+ rtrim(charlist?: string | null): Stringable;
672
+ /**
673
+ * Make a string's first character lowercase.
674
+ *
675
+ * @returns The updated Stringable instance.
676
+ */
677
+ lcfirst(): Stringable;
678
+ /**
679
+ * Make a string's first character uppercase.
680
+ *
681
+ * @returns The updated Stringable instance.
682
+ */
683
+ ucfirst(): Stringable;
684
+ /**
685
+ * Split a string by uppercase characters.
686
+ *
687
+ * @returns An array of substrings split at uppercase characters.
688
+ */
689
+ ucsplit(): string[];
690
+ /**
691
+ * Uppercase the first character of each word in a string.
692
+ *
693
+ * @returns The updated Stringable instance.
694
+ */
695
+ ucwords(): Stringable;
696
+ /**
697
+ * Apply the callback if the given "value" is (or resolves to) truthy.
698
+ *
699
+ * @param value - The value to evaluate or a closure that returns the value
700
+ * @param callback - The callback to execute if the value is truthy
701
+ * @param defaultCallback - The callback to execute if the value is falsy
702
+ * @returns Stringable - The current instance or the result of the callback
703
+ *
704
+ * @example
705
+ *
706
+ * ```typescript
707
+ * const str = new Stringable('hello world');
708
+ *
709
+ * Using a direct value
710
+ * str.when(true, s => s.upper()); // Returns 'HELLO WORLD'
711
+ * str.when(false, s => s.upper(), s => s.lower()); // Returns 'hello world'
712
+ *
713
+ * Using a closure to determine the value
714
+ * str.when(s => s.contains('world'), s => s.upper()); // Returns 'HELLO WORLD'
715
+ * str.when(s => s.contains('foo'), s => s.upper(), s => s.lower()); // Returns 'hello world'
716
+ * ```
717
+ */
718
+ when<TWhenParameter, TWhenReturnType>(value: ((instance: this) => TWhenParameter) | TWhenParameter | null, callback?: ((instance: this, value: TWhenParameter) => TWhenReturnType) | null, defaultCallback?: ((instance: this, value: TWhenParameter) => TWhenReturnType) | null): Stringable;
719
+ /**
720
+ * Apply the callback if the given "value" is (or resolves to) falsy.
721
+ *
722
+ * @param value - The value to evaluate or a closure that returns the value
723
+ * @param callback - The callback to execute if the value is falsy
724
+ * @param defaultCallback - The callback to execute if the value is truthy
725
+ * @returns Stringable - The current instance or the result of the callback
726
+ *
727
+ * @example
728
+ *
729
+ * const str = new Stringable('hello world');
730
+ * str.unless(true, s => s.upper()); // Returns 'hello world'
731
+ * str.unless(false, s => s.upper(), s => s.lower()); // Returns 'HELLO WORLD'
732
+ */
733
+ unless<TUnlessParameter, TUnlessReturnType>(value: ((instance: this) => TUnlessParameter) | TUnlessParameter | null, callback?: ((instance: this, value: TUnlessParameter) => TUnlessReturnType) | null, defaultCallback?: ((instance: this, value: TUnlessParameter) => TUnlessReturnType) | null): Stringable;
734
+ /**
735
+ * Execute the given callback if the string contains a given substring.
736
+ *
737
+ * @param needles - The substring(s) to search for
738
+ * @param callback - The callback to execute if the substring(s) are found
739
+ * @param defaultCallback - The callback to execute if the substring(s) are not found
740
+ * @returns Stringable - The current instance or the result of the callback
741
+ */
742
+ whenContains(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
743
+ /**
744
+ * Execute the given callback if the string contains all array values.
745
+ *
746
+ * @param needles - The substring(s) to search for
747
+ * @param callback - The callback to execute if all substring(s) are found
748
+ * @param defaultCallback - The callback to execute if not all substring(s) are found
749
+ * @returns Stringable - The current instance or the result of the callback
750
+ */
751
+ whenContainsAll(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
752
+ /**
753
+ * Execute the given callback if the string is empty.
754
+ *
755
+ * @param callback - The callback to execute if the string is empty
756
+ * @param defaultCallback - The callback to execute if the string is not empty
757
+ * @returns Stringable - The current instance or the result of the callback
758
+ */
759
+ whenEmpty(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
760
+ /**
761
+ * Execute the given callback if the string is not empty.
762
+ *
763
+ * @param callback - The callback to execute if the string is not empty
764
+ * @param defaultCallback - The callback to execute if the string is empty
765
+ * @returns Stringable - The current instance or the result of the callback
766
+ */
767
+ whenNotEmpty(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
768
+ /**
769
+ * Execute the given callback if the string ends with a given substring.
770
+ *
771
+ * @param needles - The substring(s) to search for
772
+ * @param callback - The callback to execute if the substring(s) are found
773
+ * @param defaultCallback - The callback to execute if the substring(s) are not found
774
+ * @returns Stringable - The current instance or the result of the callback
775
+ */
776
+ whenEndsWith(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
777
+ /**
778
+ * Execute the given callback if the string doesn't end with a given substring.
779
+ *
780
+ * @param needles - The substring(s) to search for
781
+ * @param callback - The callback to execute if the substring(s) are not found
782
+ * @param defaultCallback - The callback to execute if the substring(s) are found
783
+ * @returns Stringable - The current instance or the result of the callback
784
+ */
785
+ whenDoesntEndWith(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
786
+ /**
787
+ * Execute the given callback if the string is an exact match with the given value.
788
+ *
789
+ * @param value - The value to compare against
790
+ * @param callback - The callback to execute if the string matches the value
791
+ * @param defaultCallback - The callback to execute if the string does not match the value
792
+ * @returns Stringable - The current instance or the result of the callback
793
+ */
794
+ whenExactly(value: string, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
795
+ /**
796
+ * Execute the given callback if the string is not an exact match with the given value.
797
+ *
798
+ * @param value - The value to compare against
799
+ * @param callback - The callback to execute if the string does not match the value
800
+ * @param defaultCallback - The callback to execute if the string matches the value
801
+ * @returns Stringable - The current instance or the result of the callback
802
+ */
803
+ whenNotExactly(value: string, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
804
+ /**
805
+ * Execute the given callback if the string matches a given pattern.
806
+ *
807
+ * @param pattern - The pattern(s) to match against
808
+ * @param callback - The callback to execute if the pattern(s) match
809
+ * @param defaultCallback - The callback to execute if the pattern(s) do not match
810
+ * @returns Stringable - The current instance or the result of the callback
811
+ */
812
+ whenIs(pattern: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
813
+ /**
814
+ * Execute the given callback if the string is 7 bit ASCII.
815
+ *
816
+ * @param callback - The callback to execute if the string is ASCII
817
+ * @param defaultCallback - The callback to execute if the string is not ASCII
818
+ * @returns Stringable - The current instance or the result of the callback
819
+ */
820
+ whenIsAscii(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
821
+ /**
822
+ * Execute the given callback if the string is a valid UUID.
823
+ *
824
+ * @param callback - The callback to execute if the string is a UUID
825
+ * @param defaultCallback - The callback to execute if the string is not a UUID
826
+ * @returns Stringable - The current instance or the result of the callback
827
+ */
828
+ whenIsUuid(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
829
+ /**
830
+ * Execute the given callback if the string is a valid ULID.
831
+ *
832
+ * @param callback - The callback to execute if the string is a ULID
833
+ * @param defaultCallback - The callback to execute if the string is not a ULID
834
+ * @returns Stringable - The current instance or the result of the callback
835
+ */
836
+ whenIsUlid(callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
837
+ /**
838
+ * Execute the given callback if the string starts with a given substring.
839
+ *
840
+ * @param needles - The substring(s) to search for
841
+ * @param callback - The callback to execute if the substring(s) are found
842
+ * @param defaultCallback - The callback to execute if the substring(s) are not found
843
+ * @returns Stringable - The current instance or the result of the callback
844
+ */
845
+ whenStartsWith(needles: string | Iterable<string>, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
846
+ /**
847
+ * Execute the given callback if the string matches the given pattern.
848
+ *
849
+ * @param pattern - The pattern(s) to match against
850
+ * @param callback - The callback to execute if the pattern(s) match
851
+ * @param defaultCallback - The callback to execute if the pattern(s) do not match
852
+ * @returns Stringable - The current instance or the result of the callback
853
+ */
854
+ whenTest(pattern: string, callback: ConditionableClosure, defaultCallback?: ConditionableClosure): Stringable;
855
+ /**
856
+ * Limit the number of words in a string.
857
+ *
858
+ * @param wordsValue - The maximum number of words allowed. Defaults to 100.
859
+ * @param end - The string to append if the string is truncated. Defaults to "...".
860
+ * @returns The truncated string as a new Stringable instance.
861
+ */
862
+ words(wordsValue?: number, end?: string): Stringable;
863
+ /**
864
+ * Get the number of words a string contains.
865
+ *
866
+ * @param characters - The characters to consider as word boundaries. If null, defaults to standard word boundaries.
867
+ * @returns The number of words in the string.
868
+ */
869
+ wordCount(characters?: string | null): number;
870
+ /**
871
+ * Wrap a string to a given number of characters.
872
+ *
873
+ * @param characters - The number of characters at which to wrap the string. Defaults to 75.
874
+ * @param breakStr - The string to insert as a break. Defaults to "\n".
875
+ * @param cutLongWords - Whether to cut words longer than the specified length. Defaults to false.
876
+ * @returns The wrapped string as a new Stringable instance.
877
+ */
878
+ wordWrap(characters?: number, breakStr?: string, cutLongWords?: boolean): Stringable;
879
+ /**
880
+ * Wrap the string with the given strings.
881
+ *
882
+ * @param before - The string to prepend
883
+ * @param after - The string to append. Defaults to the value of `before`
884
+ * @returns The wrapped string as a new Stringable instance.
885
+ */
886
+ wrap(before: string, after?: string | null): Stringable;
887
+ /**
888
+ * Unwrap the string with the given strings.
889
+ *
890
+ * @param before - The string to remove from the start
891
+ * @param after - The string to remove from the end. Defaults to the value of `before`
892
+ * @returns The unwrapped string as a new Stringable instance.
893
+ */
894
+ unwrap(before: string, after?: string | null): Stringable;
895
+ /**
896
+ * Convert the string to Base64 encoding.
897
+ *
898
+ * @returns The Base64 encoded string as a new Stringable instance.
899
+ */
900
+ toBase64(): Stringable;
901
+ /**
902
+ * Decode the Base64 encoded string.
903
+ *
904
+ * @param strict - Whether to use strict decoding. Defaults to false.
905
+ * @returns The decoded string as a new Stringable instance, or false on failure.
906
+ */
907
+ fromBase64(strict?: boolean): Stringable | false;
908
+ /**
909
+ * Get the underlying string value.
910
+ *
911
+ * @returns The string representation of the object.
912
+ */
913
+ toString(): string;
914
+ /**
915
+ * Get the underlying string value.
916
+ *
917
+ * @returns The string value.
918
+ */
919
+ value(): string;
920
+ /**
921
+ * Get the underlying string value as an integer.
922
+ *
923
+ * @param base - The base to use for conversion. Defaults to 10.
924
+ * @returns The integer value.
925
+ */
926
+ toInteger(base?: number): number;
927
+ /**
928
+ * Get the underlying string value as a float.
929
+ *
930
+ * @returns The float value.
931
+ */
932
+ toFloat(): number;
933
+ /**
934
+ * Get the underlying string value as a boolean.
935
+ *
936
+ * @returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
937
+ */
938
+ toBoolean(): boolean;
939
+ /**
940
+ * Get the underlying string value as a Carbon instance.
941
+ *
942
+ * @returns The Date instance or null if parsing fails.
943
+ */
944
+ toDate(): Date | null;
945
+ /**
946
+ * Convert the object to a string when JSON encoded.
947
+ *
948
+ * @returns The string representation of the object.
949
+ */
950
+ jsonSerialize(): string;
951
+ }
952
+ //# sourceMappingURL=index.d.ts.map