@h3ravel/support 0.10.4 → 0.12.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/dist/app.globals.d.ts +12 -0
- package/dist/chunk-PECeCxCb.js +15 -0
- package/dist/index.cjs +5060 -187
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2553 -89
- package/dist/index.d.ts +2550 -89
- package/dist/index.js +4976 -177
- package/dist/index.js.map +1 -1
- package/package.json +7 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
/// <reference path="./app.globals.d.ts" />
|
|
2
|
+
import dayjs, { ConfigType, Dayjs, OpUnitType } from "dayjs";
|
|
2
3
|
import { DotFlatten, DotNestedKeys, DotNestedValue } from "@h3ravel/shared";
|
|
3
4
|
|
|
4
5
|
//#region src/Contracts/StrContract.d.ts
|
|
@@ -14,6 +15,17 @@ type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `$
|
|
|
14
15
|
* Converts snake_cased strings to TitleCasea
|
|
15
16
|
*/
|
|
16
17
|
type SnakeToTitleCase<S extends string> = S extends `${infer First}_${infer Rest}` ? `${Capitalize<Lowercase<First>>}${SnakeToTitleCase<Rest>}` : Capitalize<Lowercase<S>>;
|
|
18
|
+
type HtmlStringType = HTMLElement | Node | string;
|
|
19
|
+
type ExcerptOptions = {
|
|
20
|
+
radius?: number;
|
|
21
|
+
omission?: string;
|
|
22
|
+
};
|
|
23
|
+
type Value<T> = boolean | ((instance: T) => boolean);
|
|
24
|
+
type Callback<T> = (instance: T, value: boolean) => T | void | undefined;
|
|
25
|
+
type Fallback<T> = Callback<T> | null;
|
|
26
|
+
interface Function {
|
|
27
|
+
(...args: any[]): any;
|
|
28
|
+
}
|
|
17
29
|
//#endregion
|
|
18
30
|
//#region src/Contracts/ObjContract.d.ts
|
|
19
31
|
/**
|
|
@@ -24,8 +36,9 @@ type TGeneric<V = any, K extends string = string> = Record<K, V>;
|
|
|
24
36
|
type XGeneric<V = TGeneric, T = any> = {
|
|
25
37
|
[key: string]: T;
|
|
26
38
|
} & V;
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
declare namespace Arr_d_exports {
|
|
40
|
+
export { alternate, chunk, collapse, combine, find, first, flatten, forget, isEmpty, isNotEmpty, last, pop, prepend, range, reverse, shift, take };
|
|
41
|
+
}
|
|
29
42
|
/**
|
|
30
43
|
* Splits an array into chunks of a specified size.
|
|
31
44
|
*
|
|
@@ -35,6 +48,40 @@ type XGeneric<V = TGeneric, T = any> = {
|
|
|
35
48
|
* @returns An array of chunks (arrays)
|
|
36
49
|
*/
|
|
37
50
|
declare const chunk: <T>(arr: T[], size?: number) => T[][];
|
|
51
|
+
/**
|
|
52
|
+
* Collapse an array of arrays into a single array.
|
|
53
|
+
*/
|
|
54
|
+
declare const collapse: <T>(arr: (T | T[])[]) => T[];
|
|
55
|
+
/**
|
|
56
|
+
* Alternates between two arrays, creating a zipped result.
|
|
57
|
+
*/
|
|
58
|
+
declare const alternate: <T>(a: T[], b: T[]) => T[];
|
|
59
|
+
/**
|
|
60
|
+
* Combine arrays and sum their values element by element.
|
|
61
|
+
*/
|
|
62
|
+
declare const combine: (...arr: number[][]) => number[];
|
|
63
|
+
/** Find the value associated with a given key. */
|
|
64
|
+
declare const find: <T>(key: T, arr: T[]) => T | null;
|
|
65
|
+
/** Returns a new array without the given indices. */
|
|
66
|
+
declare const forget: <T>(arr: T[], keys: number[]) => T[];
|
|
67
|
+
/** Remove the first element and return tuple [el, rest]. */
|
|
68
|
+
declare const first: <T>(arr: T[]) => [T, T[]];
|
|
69
|
+
/** Remove the last element and return tuple [el, rest]. */
|
|
70
|
+
declare const last: <T>(arr: T[]) => [T, T[]];
|
|
71
|
+
/** Check if array is empty. */
|
|
72
|
+
declare const isEmpty: <T>(arr: T[]) => boolean;
|
|
73
|
+
/** Check if array is empty. */
|
|
74
|
+
declare const isNotEmpty: <T>(arr: T[]) => boolean;
|
|
75
|
+
/** Pop the element off the end of array. */
|
|
76
|
+
declare const pop: <T>(arr: T[]) => T[];
|
|
77
|
+
/** Add elements to the beginning of array. */
|
|
78
|
+
declare const prepend: <T>(arr: T[], ...elements: T[]) => T[];
|
|
79
|
+
/** Take first n elements of array. */
|
|
80
|
+
declare const take: <T>(amount: number, arr: T[]) => T[];
|
|
81
|
+
/** Create a new array in reverse order. */
|
|
82
|
+
declare const reverse: <T>(arr: T[]) => T[];
|
|
83
|
+
/** Alias for first element removal. */
|
|
84
|
+
declare const shift: <T>(arr: T[]) => [T, T[]];
|
|
38
85
|
/**
|
|
39
86
|
* Generates an array of sequential numbers.
|
|
40
87
|
*
|
|
@@ -43,8 +90,126 @@ declare const chunk: <T>(arr: T[], size?: number) => T[][];
|
|
|
43
90
|
* @returns An array of numbers from startAt to startAt + size - 1
|
|
44
91
|
*/
|
|
45
92
|
declare const range: (size: number, startAt?: number) => number[];
|
|
46
|
-
|
|
47
|
-
|
|
93
|
+
/** Flatten multi-dimensional arrays into single level. */
|
|
94
|
+
declare const flatten: <T>(arr: T[]) => T[];
|
|
95
|
+
declare namespace Crypto_d_exports {
|
|
96
|
+
export { base64Decode, base64Encode, caesarCipher, checksum, hash, hmac, random, randomColor, randomPassword, randomSecure, secureToken, uuid, verifyChecksum, xor };
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Generate a random UUID string.
|
|
100
|
+
*
|
|
101
|
+
* @returns A random UUID string
|
|
102
|
+
*/
|
|
103
|
+
declare const uuid: () => string;
|
|
104
|
+
/**
|
|
105
|
+
* Generate a random string of specified length.
|
|
106
|
+
*
|
|
107
|
+
* @param length - Length of the random string (default: 16)
|
|
108
|
+
* @param charset - Character set to use (default: alphanumeric)
|
|
109
|
+
* @returns A random string
|
|
110
|
+
*/
|
|
111
|
+
declare const random: (length?: number, charset?: string) => string;
|
|
112
|
+
/**
|
|
113
|
+
* Secure random string generator that uses crypto.randomBytes.
|
|
114
|
+
*
|
|
115
|
+
* @param length - Length of the random string (default: 32)
|
|
116
|
+
* @returns A cryptographically secure random string
|
|
117
|
+
*/
|
|
118
|
+
declare const randomSecure: (length?: number) => string;
|
|
119
|
+
/**
|
|
120
|
+
* Hash a string using the specified algorithm.
|
|
121
|
+
*
|
|
122
|
+
* @param data - Data to hash
|
|
123
|
+
* @param algorithm - Hash algorithm (default: 'sha256')
|
|
124
|
+
* @returns Hexadecimal hash string
|
|
125
|
+
*/
|
|
126
|
+
declare const hash: (data: string, algorithm?: string) => string;
|
|
127
|
+
/**
|
|
128
|
+
* Hash a string with salt using HMAC.
|
|
129
|
+
*
|
|
130
|
+
* @param data - Data to hash
|
|
131
|
+
* @param key - Secret key for HMAC
|
|
132
|
+
* @param algorithm - Hash algorithm (default: 'sha256')
|
|
133
|
+
* @returns Hexadecimal hash string
|
|
134
|
+
*/
|
|
135
|
+
declare const hmac: (data: string, key: string, algorithm?: string) => string;
|
|
136
|
+
/**
|
|
137
|
+
* Encode data to base64.
|
|
138
|
+
*
|
|
139
|
+
* @param data - Data to encode
|
|
140
|
+
* @returns Base64 encoded string
|
|
141
|
+
*/
|
|
142
|
+
declare const base64Encode: (data: string) => string;
|
|
143
|
+
/**
|
|
144
|
+
* Decode base64 data.
|
|
145
|
+
*
|
|
146
|
+
* @param data - Base64 string to decode
|
|
147
|
+
* @returns Decoded string
|
|
148
|
+
*/
|
|
149
|
+
declare const base64Decode: (data: string) => string;
|
|
150
|
+
/**
|
|
151
|
+
* Simple XOR encryption/decryption.
|
|
152
|
+
*
|
|
153
|
+
* @param data - Data to encrypt/decrypt
|
|
154
|
+
* @param key - Encryption key
|
|
155
|
+
* @returns Encrypted/decrypted string
|
|
156
|
+
*/
|
|
157
|
+
declare const xor: (data: string, key: string) => string;
|
|
158
|
+
/**
|
|
159
|
+
* Generate a random hex color code.
|
|
160
|
+
*
|
|
161
|
+
* @returns A hex color code string (e.g., '#a3b2f3')
|
|
162
|
+
*/
|
|
163
|
+
declare const randomColor: () => string;
|
|
164
|
+
/**
|
|
165
|
+
* Generate a secure password using configurable parameters.
|
|
166
|
+
*
|
|
167
|
+
* @param length - Password length (default: 16)
|
|
168
|
+
* @param options - Character options
|
|
169
|
+
* @returns A secure password string
|
|
170
|
+
*/
|
|
171
|
+
interface PasswordOptions {
|
|
172
|
+
useUppercase?: boolean;
|
|
173
|
+
useLowercase?: boolean;
|
|
174
|
+
useNumbers?: boolean;
|
|
175
|
+
useSymbols?: boolean;
|
|
176
|
+
}
|
|
177
|
+
declare const randomPassword: (length?: number, options?: PasswordOptions) => string;
|
|
178
|
+
/**
|
|
179
|
+
* Generate a cryptographically secure token for APIs, sessions, etc.
|
|
180
|
+
*
|
|
181
|
+
* @param strength - Token strength (bytes) (default: 32)
|
|
182
|
+
* @returns A secure token string
|
|
183
|
+
*/
|
|
184
|
+
declare const secureToken: (strength?: number) => string;
|
|
185
|
+
/**
|
|
186
|
+
* Create a checksum for data integrity verification.
|
|
187
|
+
*
|
|
188
|
+
* @param data - Data to create checksum for
|
|
189
|
+
* @param algorithm - Hash algorithm (default: 'sha256')
|
|
190
|
+
* @returns SHA256 checksum
|
|
191
|
+
*/
|
|
192
|
+
declare const checksum: (data: string, algorithm?: string) => string;
|
|
193
|
+
/**
|
|
194
|
+
* Verify data integrity using checksum.
|
|
195
|
+
*
|
|
196
|
+
* @param data - Data to verify
|
|
197
|
+
* @param expectedChecksum - Expected checksum
|
|
198
|
+
* @param algorithm - Hash algorithm (default: 'sha256')
|
|
199
|
+
* @returns True if checksums match
|
|
200
|
+
*/
|
|
201
|
+
declare const verifyChecksum: (data: string, expectedChecksum: string, algorithm?: string) => boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Simple Caesar cipher implementation.
|
|
204
|
+
*
|
|
205
|
+
* @param text - Text to encrypt/decrypt
|
|
206
|
+
* @param shift - Number of positions to shift (default: 13)
|
|
207
|
+
* @returns Encrypted/decrypted text
|
|
208
|
+
*/
|
|
209
|
+
declare const caesarCipher: (text: string, shift?: number) => string;
|
|
210
|
+
declare namespace DumpDie_d_exports {
|
|
211
|
+
export { dd, dump };
|
|
212
|
+
}
|
|
48
213
|
/**
|
|
49
214
|
* Dump something and kill the process for quick debugging. Based on Laravel's dd()
|
|
50
215
|
*
|
|
@@ -57,8 +222,9 @@ declare const dd: (...args: unknown[]) => never;
|
|
|
57
222
|
* @param args
|
|
58
223
|
*/
|
|
59
224
|
declare const dump: (...args: unknown[]) => void;
|
|
60
|
-
|
|
61
|
-
|
|
225
|
+
declare namespace Number_d_exports {
|
|
226
|
+
export { abbreviate, humanize, toBytes, toHumanTime };
|
|
227
|
+
}
|
|
62
228
|
/**
|
|
63
229
|
* Abbreviates large numbers using SI symbols (K, M, B...)
|
|
64
230
|
* and formats the output according to the given locale.
|
|
@@ -95,8 +261,9 @@ declare const toBytes: (bytes?: number, decimals?: number, bits?: boolean) => st
|
|
|
95
261
|
* @returns A formatted time string
|
|
96
262
|
*/
|
|
97
263
|
declare const toHumanTime: (seconds?: number, worded?: boolean) => string;
|
|
98
|
-
|
|
99
|
-
|
|
264
|
+
declare namespace Obj_d_exports {
|
|
265
|
+
export { dot, extractProperties, getValue, modObj, safeDot, setNested, slugifyKeys };
|
|
266
|
+
}
|
|
100
267
|
/**
|
|
101
268
|
* Flattens a nested object into a single-level object
|
|
102
269
|
* with dot-separated keys.
|
|
@@ -177,101 +344,2395 @@ declare const setNested: (obj: Record<string, any>, key: string, value: any) =>
|
|
|
177
344
|
declare const slugifyKeys: <T extends object>(obj: T, only?: string[], separator?: string) => KeysToSnakeCase<T>;
|
|
178
345
|
//#endregion
|
|
179
346
|
//#region src/Helpers/Str.d.ts
|
|
347
|
+
declare enum Mode {
|
|
348
|
+
MB_CASE_UPPER = 0,
|
|
349
|
+
MB_CASE_LOWER = 1,
|
|
350
|
+
MB_CASE_TITLE = 2,
|
|
351
|
+
MB_CASE_FOLD = 3,
|
|
352
|
+
MB_CASE_UPPER_SIMPLE = 4,
|
|
353
|
+
MB_CASE_LOWER_SIMPLE = 5,
|
|
354
|
+
MB_CASE_TITLE_SIMPLE = 6,
|
|
355
|
+
MB_CASE_FOLD_SIMPLE = 7,
|
|
356
|
+
}
|
|
357
|
+
declare class Str {
|
|
358
|
+
/**
|
|
359
|
+
* The callback that should be used to generate UUIDs.
|
|
360
|
+
*
|
|
361
|
+
* @type { Function | null }
|
|
362
|
+
*/
|
|
363
|
+
protected static uuidFactory: Function | null;
|
|
364
|
+
/**
|
|
365
|
+
* The callback that should be used to generate ULIDs.
|
|
366
|
+
*
|
|
367
|
+
* @type { Function | null }
|
|
368
|
+
*/
|
|
369
|
+
protected static ulidFactory: Function | null;
|
|
370
|
+
/**
|
|
371
|
+
* The callback that should be used to generate random strings.
|
|
372
|
+
*
|
|
373
|
+
* @type { Function | null }
|
|
374
|
+
*/
|
|
375
|
+
protected static randomStringFactory: Function | null;
|
|
376
|
+
/**
|
|
377
|
+
* Get a new Stringable object from the given string.
|
|
378
|
+
*
|
|
379
|
+
* @param { string } string
|
|
380
|
+
*/
|
|
381
|
+
static of(string: string): Stringable;
|
|
382
|
+
/**
|
|
383
|
+
* Return the remainder of a string after the first occurrence of a given value.
|
|
384
|
+
*
|
|
385
|
+
* @param { string } subject
|
|
386
|
+
* @param { string } search
|
|
387
|
+
*
|
|
388
|
+
* @return { string }
|
|
389
|
+
*/
|
|
390
|
+
static after(subject: string, search: string): string;
|
|
391
|
+
/**
|
|
392
|
+
* Return the remainder of a string after the last occurrence of a given value.
|
|
393
|
+
*
|
|
394
|
+
* @param { string } subject
|
|
395
|
+
* @param { string } search
|
|
396
|
+
*
|
|
397
|
+
* @return { string }
|
|
398
|
+
*/
|
|
399
|
+
static afterLast(subject: string, search: string): string;
|
|
400
|
+
/**
|
|
401
|
+
* Transliterate a UTF-8 value to ASCII.
|
|
402
|
+
*
|
|
403
|
+
* @param { string } value
|
|
404
|
+
*
|
|
405
|
+
* @return { string }
|
|
406
|
+
*/
|
|
407
|
+
static ascii(value: string): string;
|
|
408
|
+
/**
|
|
409
|
+
* Get the portion of a string before the first occurrence of a given value.
|
|
410
|
+
*
|
|
411
|
+
* @param { string } subject
|
|
412
|
+
* @param { string } search
|
|
413
|
+
*
|
|
414
|
+
* @return { string }
|
|
415
|
+
*/
|
|
416
|
+
static before(subject: string, search: string): string;
|
|
417
|
+
/**
|
|
418
|
+
* Get the portion of a string before the last occurrence of a given value.
|
|
419
|
+
*
|
|
420
|
+
* @param { string } subject
|
|
421
|
+
* @param { string } search
|
|
422
|
+
*
|
|
423
|
+
* @return { string }
|
|
424
|
+
*/
|
|
425
|
+
static beforeLast(subject: string, search: string): string;
|
|
426
|
+
/**
|
|
427
|
+
* Get the portion of a string between two given values.
|
|
428
|
+
*
|
|
429
|
+
* @param { string } subject
|
|
430
|
+
* @param { string } from
|
|
431
|
+
* @param { string } to
|
|
432
|
+
*
|
|
433
|
+
* @return { string }
|
|
434
|
+
*/
|
|
435
|
+
static between(subject: string, from: string, to: string): string;
|
|
436
|
+
/**
|
|
437
|
+
* Get the smallest possible portion of a string between two given values.
|
|
438
|
+
*
|
|
439
|
+
* @param { string } subject
|
|
440
|
+
* @param { string } from
|
|
441
|
+
* @param { string } to
|
|
442
|
+
*
|
|
443
|
+
* @return { string }
|
|
444
|
+
*/
|
|
445
|
+
static betweenFirst(subject: string, from: string, to: string): string;
|
|
446
|
+
/**
|
|
447
|
+
* Convert a value to camel case.
|
|
448
|
+
*
|
|
449
|
+
* @param { string } value
|
|
450
|
+
*
|
|
451
|
+
* @return { string }
|
|
452
|
+
*/
|
|
453
|
+
static camel(value: string): string;
|
|
454
|
+
/**
|
|
455
|
+
* Get the character at the specified index.
|
|
456
|
+
*
|
|
457
|
+
* @param { string } subject
|
|
458
|
+
* @param { number } index
|
|
459
|
+
*
|
|
460
|
+
* @return { string | false }
|
|
461
|
+
*/
|
|
462
|
+
static charAt(subject: string, index: number): string | false;
|
|
463
|
+
/**
|
|
464
|
+
* Remove the given string(s) if it exists at the start of the haystack.
|
|
465
|
+
*
|
|
466
|
+
* @param { string } subject
|
|
467
|
+
* @param { string | string[] } needle
|
|
468
|
+
*
|
|
469
|
+
* @return string
|
|
470
|
+
*/
|
|
471
|
+
static chopStart(subject: string, needle: string | string[]): string;
|
|
472
|
+
/**
|
|
473
|
+
* Remove the given string(s) if it exists at the end of the haystack.
|
|
474
|
+
*
|
|
475
|
+
* @param { string } subject
|
|
476
|
+
* @param { string | string[] } needle
|
|
477
|
+
*
|
|
478
|
+
* @return string
|
|
479
|
+
*
|
|
480
|
+
*/
|
|
481
|
+
static chopEnd(subject: string, needle: string | string[]): string;
|
|
482
|
+
/**
|
|
483
|
+
* Determine if a given string contains a given substring.
|
|
484
|
+
*
|
|
485
|
+
* @param { string } haystack
|
|
486
|
+
* @param { string | string[] } needles
|
|
487
|
+
* @param { boolean } ignoreCase
|
|
488
|
+
*
|
|
489
|
+
* @return { boolean }
|
|
490
|
+
*/
|
|
491
|
+
static contains(haystack: string, needles: string | string[], ignoreCase?: boolean): boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Determine if a given string contains all array values.
|
|
494
|
+
*
|
|
495
|
+
* @param { string } haystack
|
|
496
|
+
* @param { string[] } needles
|
|
497
|
+
* @param { boolean } ignoreCase
|
|
498
|
+
*
|
|
499
|
+
* @return { boolean }
|
|
500
|
+
*/
|
|
501
|
+
static containsAll(haystack: string, needles: string[], ignoreCase?: boolean): boolean;
|
|
502
|
+
/**
|
|
503
|
+
* Determine if a given string doesn't contain a given substring.
|
|
504
|
+
*
|
|
505
|
+
* @param { string } haystack
|
|
506
|
+
* @param { string | string[] } needles
|
|
507
|
+
* @param { boolean } ignoreCase
|
|
508
|
+
*
|
|
509
|
+
* @return { boolean }
|
|
510
|
+
*/
|
|
511
|
+
static doesntContain(haystack: string, needles: string | string[], ignoreCase?: boolean): boolean;
|
|
512
|
+
/**
|
|
513
|
+
* Convert the case of a string.
|
|
514
|
+
*
|
|
515
|
+
* @param { string } string
|
|
516
|
+
* @param { Mode | number } mode
|
|
517
|
+
*
|
|
518
|
+
* @return { string }
|
|
519
|
+
*/
|
|
520
|
+
static convertCase(string: string, mode?: Mode | number): string;
|
|
521
|
+
/**
|
|
522
|
+
* Replace consecutive instances of a given character with a single character in the given string.
|
|
523
|
+
*
|
|
524
|
+
* @param { string } string
|
|
525
|
+
* @param { string | string[] } characters
|
|
526
|
+
*
|
|
527
|
+
* @return { string }
|
|
528
|
+
*/
|
|
529
|
+
static deduplicate(string: string, characters?: string | string[]): string;
|
|
530
|
+
/**
|
|
531
|
+
* Determine if a given string ends with a given substring.
|
|
532
|
+
*
|
|
533
|
+
* @param { string } haystack
|
|
534
|
+
* @param { string | string[] } needles
|
|
535
|
+
*
|
|
536
|
+
* @return { boolean }
|
|
537
|
+
*/
|
|
538
|
+
static endsWith(haystack: string, needles: string | string[]): boolean;
|
|
539
|
+
/**
|
|
540
|
+
* Determine if a given string doesn't end with a given substring.
|
|
541
|
+
*
|
|
542
|
+
* @param { string } haystack
|
|
543
|
+
* @param { string | string[] } needles
|
|
544
|
+
*
|
|
545
|
+
* @return { boolean }
|
|
546
|
+
*/
|
|
547
|
+
static doesntEndWith(haystack: string, needles: string | string[]): boolean;
|
|
548
|
+
/**
|
|
549
|
+
* Returns all the characters except the last.
|
|
550
|
+
*
|
|
551
|
+
* @param string
|
|
552
|
+
* @returns
|
|
553
|
+
*/
|
|
554
|
+
static chop(string: string): string;
|
|
555
|
+
/**
|
|
556
|
+
* Escape string for JSON encoding (returns string without quotes).
|
|
557
|
+
*
|
|
558
|
+
* @param string
|
|
559
|
+
* @returns
|
|
560
|
+
*/
|
|
561
|
+
static esc(string: string): string;
|
|
562
|
+
/**
|
|
563
|
+
* Extracts an excerpt from text that matches the first instance of a phrase.
|
|
564
|
+
*
|
|
565
|
+
* @param { string } text
|
|
566
|
+
* @param { string } phrase
|
|
567
|
+
* @param { ExcerptOptions } options
|
|
568
|
+
*
|
|
569
|
+
* @return { string | null }
|
|
570
|
+
*/
|
|
571
|
+
static excerpt(text: string, phrase?: string, options?: ExcerptOptions): string | null;
|
|
572
|
+
/**
|
|
573
|
+
* Explode the string into an array.
|
|
574
|
+
*
|
|
575
|
+
* @param { string } string
|
|
576
|
+
* @param { string } delimiter
|
|
577
|
+
* @param { number } limit
|
|
578
|
+
*
|
|
579
|
+
* @return { string[] }
|
|
580
|
+
*/
|
|
581
|
+
static explode(string: string, delimiter: string, limit?: number): string[];
|
|
582
|
+
/**
|
|
583
|
+
* Cap a string with a single instance of a given value.
|
|
584
|
+
*
|
|
585
|
+
* @param { string } value
|
|
586
|
+
* @param { string } cap
|
|
587
|
+
*
|
|
588
|
+
* @return { string }
|
|
589
|
+
*/
|
|
590
|
+
static finish(value: string, cap: string): string;
|
|
591
|
+
/**
|
|
592
|
+
* Wrap the string with the given strings.
|
|
593
|
+
*
|
|
594
|
+
* @param { string } value
|
|
595
|
+
* @param { string } before
|
|
596
|
+
* @param { string | null } after
|
|
597
|
+
*
|
|
598
|
+
* @return string
|
|
599
|
+
*/
|
|
600
|
+
static wrap(value: string, before: string, after?: string | null): string;
|
|
601
|
+
/**
|
|
602
|
+
* Unwrap the string with the given strings.
|
|
603
|
+
*
|
|
604
|
+
* @param { string } value
|
|
605
|
+
* @param { string } before
|
|
606
|
+
* @param { string | null } after
|
|
607
|
+
*
|
|
608
|
+
* @return { string }
|
|
609
|
+
*/
|
|
610
|
+
static unwrap(value: string, before: string, after?: string | null): string;
|
|
611
|
+
/**
|
|
612
|
+
* Determine if a given string matches a given pattern.
|
|
613
|
+
*
|
|
614
|
+
* @param { string | string[] } pattern
|
|
615
|
+
* @param { string } value
|
|
616
|
+
* @param { boolean } ignoreCase
|
|
617
|
+
*
|
|
618
|
+
* @return { boolean }
|
|
619
|
+
*/
|
|
620
|
+
static is(pattern: string | string[], value: string, ignoreCase?: boolean): boolean;
|
|
621
|
+
/**
|
|
622
|
+
* Determine if a given string is 7-bit ASCII.
|
|
623
|
+
*
|
|
624
|
+
* @param { string } value
|
|
625
|
+
*
|
|
626
|
+
* @return { boolean }
|
|
627
|
+
*/
|
|
628
|
+
static isAscii(value: string): boolean;
|
|
629
|
+
/**
|
|
630
|
+
* Determine if a given string is valid JSON.
|
|
631
|
+
*
|
|
632
|
+
* @param { string } value
|
|
633
|
+
*
|
|
634
|
+
* @return { boolean }
|
|
635
|
+
*/
|
|
636
|
+
static isJson(value: string): boolean;
|
|
637
|
+
/**
|
|
638
|
+
* Determine if a given value is a valid URL.
|
|
639
|
+
*
|
|
640
|
+
* @param { string } value
|
|
641
|
+
* @param { string[] } protocols
|
|
642
|
+
*
|
|
643
|
+
* @return { boolean }
|
|
644
|
+
*/
|
|
645
|
+
static isUrl(value: string, protocols?: string[]): boolean;
|
|
646
|
+
/**
|
|
647
|
+
* Determine if a given string is a valid UUID.
|
|
648
|
+
*
|
|
649
|
+
* @param { string } value
|
|
650
|
+
*
|
|
651
|
+
* @return { boolean }
|
|
652
|
+
*/
|
|
653
|
+
static isUuid(value: string): boolean;
|
|
654
|
+
/**
|
|
655
|
+
* Determine if a given string is a valid ULID.
|
|
656
|
+
*
|
|
657
|
+
* @param { string } value
|
|
658
|
+
*
|
|
659
|
+
* @return { boolean }
|
|
660
|
+
*/
|
|
661
|
+
static isUlid(value: string): boolean;
|
|
662
|
+
/**
|
|
663
|
+
* Convert a string to kebab case.
|
|
664
|
+
*
|
|
665
|
+
* @param { string } value
|
|
666
|
+
*
|
|
667
|
+
* @return { string }
|
|
668
|
+
*/
|
|
669
|
+
static kebab(value: string): string;
|
|
670
|
+
/**
|
|
671
|
+
* Return the length of the given string.
|
|
672
|
+
*
|
|
673
|
+
* @param { string } value
|
|
674
|
+
*
|
|
675
|
+
* @return { number }
|
|
676
|
+
*/
|
|
677
|
+
static length(value: string): number;
|
|
678
|
+
/**
|
|
679
|
+
* Limit the number of characters in a string.
|
|
680
|
+
*
|
|
681
|
+
* @param { string } value
|
|
682
|
+
* @param { number } limit
|
|
683
|
+
* @param { string } end
|
|
684
|
+
* @param { boolean } preserveWords
|
|
685
|
+
*
|
|
686
|
+
* @return { string }
|
|
687
|
+
*/
|
|
688
|
+
static limit(value: string, limit?: number, end?: string, preserveWords?: boolean): string;
|
|
689
|
+
/**
|
|
690
|
+
* Limit the number of characters in a string.
|
|
691
|
+
*
|
|
692
|
+
* @param { string } value
|
|
693
|
+
* @param { number } limit
|
|
694
|
+
* @param { string } end
|
|
695
|
+
* @param { boolean } preserveWords
|
|
696
|
+
*
|
|
697
|
+
* @alias limit
|
|
698
|
+
* @return { string }
|
|
699
|
+
*/
|
|
700
|
+
static truncate(value: string, limit?: number, end?: string, preserveWords?: boolean): string;
|
|
701
|
+
/**
|
|
702
|
+
* Convert the given string to lower-case.
|
|
703
|
+
*
|
|
704
|
+
* @param { string } value
|
|
705
|
+
*
|
|
706
|
+
* @return { string }
|
|
707
|
+
*/
|
|
708
|
+
static lower(value: string): string;
|
|
709
|
+
/**
|
|
710
|
+
* Get substring by start/stop indexes.
|
|
711
|
+
*
|
|
712
|
+
* @param string
|
|
713
|
+
* @param start
|
|
714
|
+
* @param stop
|
|
715
|
+
* @returns
|
|
716
|
+
*/
|
|
717
|
+
static sub(string: string, start: number, stop: number): string;
|
|
718
|
+
/**
|
|
719
|
+
* Limit the number of words in a string.
|
|
720
|
+
*
|
|
721
|
+
* @param { string } value
|
|
722
|
+
* @param { number } words
|
|
723
|
+
* @param { string } end
|
|
724
|
+
*
|
|
725
|
+
* @return { string }
|
|
726
|
+
*/
|
|
727
|
+
static words(value: string, words?: number, end?: string): string;
|
|
728
|
+
/**
|
|
729
|
+
* Masks a portion of a string with a repeated character.
|
|
730
|
+
*
|
|
731
|
+
* @param { string } string
|
|
732
|
+
* @param { string } character
|
|
733
|
+
* @param { number } index
|
|
734
|
+
* @param { number | null } length
|
|
735
|
+
*
|
|
736
|
+
* @return { string }
|
|
737
|
+
*/
|
|
738
|
+
static mask(string: string, character: string, index: number, length?: number | null): string;
|
|
739
|
+
/**
|
|
740
|
+
* Get the string matching the given pattern.
|
|
741
|
+
*
|
|
742
|
+
* @param { string } pattern
|
|
743
|
+
* @param { string } subject
|
|
744
|
+
*
|
|
745
|
+
* @return { string }
|
|
746
|
+
*/
|
|
747
|
+
static match(pattern: string, subject: string): string;
|
|
748
|
+
/**
|
|
749
|
+
* Determine if a given string matches a given pattern.
|
|
750
|
+
*
|
|
751
|
+
* @param { string | string[] } pattern
|
|
752
|
+
* @param { string } value
|
|
753
|
+
*
|
|
754
|
+
* @return { boolean }
|
|
755
|
+
*/
|
|
756
|
+
static isMatch(pattern: string | string[], value: string): boolean;
|
|
757
|
+
/**
|
|
758
|
+
* Get the string matching the given pattern.
|
|
759
|
+
*
|
|
760
|
+
* @param { string } pattern
|
|
761
|
+
* @param { string } subject
|
|
762
|
+
*
|
|
763
|
+
* @return { string[] }
|
|
764
|
+
*/
|
|
765
|
+
static matchAll(pattern: string, subject: string): string[];
|
|
766
|
+
/**
|
|
767
|
+
* Remove all non-numeric characters from a string.
|
|
768
|
+
*
|
|
769
|
+
* @param { string } value
|
|
770
|
+
*
|
|
771
|
+
* @return { string }
|
|
772
|
+
*/
|
|
773
|
+
static numbers(value: string): string;
|
|
774
|
+
/**
|
|
775
|
+
* Pad both sides of a string with another.
|
|
776
|
+
*
|
|
777
|
+
* @param { string } value
|
|
778
|
+
* @param { number } length
|
|
779
|
+
* @param { string } pad
|
|
780
|
+
*
|
|
781
|
+
* @return { string }
|
|
782
|
+
*/
|
|
783
|
+
static padBoth(value: string, length: number, pad?: string): string;
|
|
784
|
+
/**
|
|
785
|
+
* Pad the left side of a string with another.
|
|
786
|
+
*
|
|
787
|
+
* @param { string } value
|
|
788
|
+
* @param { number } length
|
|
789
|
+
* @param { string } pad
|
|
790
|
+
*
|
|
791
|
+
* @return { string }
|
|
792
|
+
*/
|
|
793
|
+
static padLeft(value: string, length: number, pad?: string): string;
|
|
794
|
+
/**
|
|
795
|
+
* Pad the right side of a string with another.
|
|
796
|
+
*
|
|
797
|
+
* @param { string } value
|
|
798
|
+
* @param { number } length
|
|
799
|
+
* @param { string } pad
|
|
800
|
+
*
|
|
801
|
+
* @return { string }
|
|
802
|
+
*/
|
|
803
|
+
static padRight(value: string, length: number, pad?: string): string;
|
|
804
|
+
/**
|
|
805
|
+
* Get the plural form of an English word.
|
|
806
|
+
*
|
|
807
|
+
* @param { string } value
|
|
808
|
+
* @param { number | array } count
|
|
809
|
+
*
|
|
810
|
+
* @return { string }
|
|
811
|
+
*/
|
|
812
|
+
static plural(value: string, count?: number | number[]): string;
|
|
813
|
+
/**
|
|
814
|
+
* Get the plural form of an English word.
|
|
815
|
+
*
|
|
816
|
+
* @param { string } value
|
|
817
|
+
* @param { number | array } count
|
|
818
|
+
*
|
|
819
|
+
* @alias plural
|
|
820
|
+
*
|
|
821
|
+
* @return { string }
|
|
822
|
+
*/
|
|
823
|
+
static pluralize: (value: string, count?: number | number[]) => string;
|
|
824
|
+
/**
|
|
825
|
+
* Pluralize the last word of an English, studly caps case string.
|
|
826
|
+
*
|
|
827
|
+
* @param { string } value
|
|
828
|
+
* @param { number | array } count
|
|
829
|
+
*
|
|
830
|
+
* @return { string }
|
|
831
|
+
*/
|
|
832
|
+
static pluralStudly(value: string, count?: number | number[]): string;
|
|
833
|
+
/**
|
|
834
|
+
* Pluralize the last word of an English, Pascal case string.
|
|
835
|
+
*
|
|
836
|
+
* @param { string } value
|
|
837
|
+
* @param { number | array } count
|
|
838
|
+
*
|
|
839
|
+
* @return { string }
|
|
840
|
+
*/
|
|
841
|
+
static pluralPascal(value: string, count?: number | number[]): string;
|
|
842
|
+
/**
|
|
843
|
+
* Generate a random, secure password.
|
|
844
|
+
*
|
|
845
|
+
* @param { number } length
|
|
846
|
+
* @param { boolean } letters
|
|
847
|
+
* @param { boolean } numbers
|
|
848
|
+
* @param { boolean } symbols
|
|
849
|
+
* @param { boolean } spaces
|
|
850
|
+
*
|
|
851
|
+
* @return { string }
|
|
852
|
+
*/
|
|
853
|
+
static password(length?: number, letters?: boolean, numbers?: boolean, symbols?: boolean, spaces?: boolean): string;
|
|
854
|
+
/**
|
|
855
|
+
* Find the position of the first occurrence of a given substring in a string.
|
|
856
|
+
*
|
|
857
|
+
* @param { string } haystack
|
|
858
|
+
* @param { string } needle
|
|
859
|
+
* @param { number } offset
|
|
860
|
+
*
|
|
861
|
+
* @return { number | false }
|
|
862
|
+
*/
|
|
863
|
+
static position(haystack: string, needle: string, offset?: number): number | false;
|
|
864
|
+
/**
|
|
865
|
+
* Generate a more truly "random" alpha-numeric string.
|
|
866
|
+
*
|
|
867
|
+
* @param { number } length
|
|
868
|
+
*
|
|
869
|
+
* @return { string }
|
|
870
|
+
*/
|
|
871
|
+
static random(length?: number): string;
|
|
872
|
+
/**
|
|
873
|
+
* Set the callable that will be used to generate random strings.
|
|
874
|
+
*
|
|
875
|
+
* @param { ((length: number) => string) | null } factory
|
|
876
|
+
*
|
|
877
|
+
* @return { void }
|
|
878
|
+
*/
|
|
879
|
+
static createRandomStringsUsing(factory?: ((length: number) => string) | null): void;
|
|
880
|
+
/**
|
|
881
|
+
* Set the sequence that will be used to generate random strings.
|
|
882
|
+
*
|
|
883
|
+
* @param { (string | undefined)[] } sequence
|
|
884
|
+
* @param { Function | null } whenMissing
|
|
885
|
+
*
|
|
886
|
+
* @return { void }
|
|
887
|
+
*/
|
|
888
|
+
static createRandomStringsUsingSequence(sequence: (string | undefined)[], whenMissing?: Function | null): void;
|
|
889
|
+
/**
|
|
890
|
+
* Indicate that random strings should be created normally and not using a custom factory.
|
|
891
|
+
*
|
|
892
|
+
* @return { void }
|
|
893
|
+
*/
|
|
894
|
+
static createRandomStringsNormally(): void;
|
|
895
|
+
/**
|
|
896
|
+
* Repeat the given string.
|
|
897
|
+
*
|
|
898
|
+
* @param { string } string
|
|
899
|
+
* @param { number } times
|
|
900
|
+
*
|
|
901
|
+
* @return { string }
|
|
902
|
+
*/
|
|
903
|
+
static repeat(string: string, times?: number): string;
|
|
904
|
+
/**
|
|
905
|
+
* Replace a given value in the string sequentially with an array.
|
|
906
|
+
*
|
|
907
|
+
* @param { string[] } replace
|
|
908
|
+
* @param { string } subject
|
|
909
|
+
* @param { string } search
|
|
910
|
+
*
|
|
911
|
+
* @return { string }
|
|
912
|
+
*/
|
|
913
|
+
static replaceArray(search: string, replace: string[], subject: string): string;
|
|
914
|
+
/**
|
|
915
|
+
* Convert the given value to a string or return the given fallback on failure.
|
|
916
|
+
*
|
|
917
|
+
* @param { * } value
|
|
918
|
+
* @param { string } fallback
|
|
919
|
+
*
|
|
920
|
+
* @return { string }
|
|
921
|
+
*/
|
|
922
|
+
static toStringOr(value: any, fallback: string): string;
|
|
923
|
+
/**
|
|
924
|
+
* Replace the given value in the given string.
|
|
925
|
+
*
|
|
926
|
+
* @param { string | string[] } search
|
|
927
|
+
* @param { string } replace
|
|
928
|
+
* @param { string } subject
|
|
929
|
+
* @param { boolean } caseSensitive
|
|
930
|
+
*
|
|
931
|
+
* @return { string }
|
|
932
|
+
*/
|
|
933
|
+
static replace(search: string | string[], replace: string, subject: string, caseSensitive?: boolean): string;
|
|
934
|
+
/**
|
|
935
|
+
* Replace the first occurrence of a given value in the string.
|
|
936
|
+
*
|
|
937
|
+
* @param { string } search
|
|
938
|
+
* @param { string } replace
|
|
939
|
+
* @param { string } subject
|
|
940
|
+
*
|
|
941
|
+
* @return { string }
|
|
942
|
+
*/
|
|
943
|
+
static replaceFirst(search: string, replace: string, subject: string): string;
|
|
944
|
+
/**
|
|
945
|
+
* Replace the first occurrence of the given value if it appears at the start of the string.
|
|
946
|
+
*
|
|
947
|
+
* @param { string } search
|
|
948
|
+
* @param { string } replace
|
|
949
|
+
* @param { string } subject
|
|
950
|
+
*
|
|
951
|
+
* @return { string }
|
|
952
|
+
*/
|
|
953
|
+
static replaceStart(search: string, replace: string, subject: string): string;
|
|
954
|
+
/**
|
|
955
|
+
* Replace the last occurrence of a given value in the string.
|
|
956
|
+
*
|
|
957
|
+
* @param { string } search
|
|
958
|
+
* @param { string } replace
|
|
959
|
+
* @param { string } subject
|
|
960
|
+
*
|
|
961
|
+
* @return { string }
|
|
962
|
+
*/
|
|
963
|
+
static replaceLast(search: string, replace: string, subject: string): string;
|
|
964
|
+
/**
|
|
965
|
+
* Replace the last occurrence of a given value if it appears at the end of the string.
|
|
966
|
+
*
|
|
967
|
+
* @param { string } search
|
|
968
|
+
* @param { string } replace
|
|
969
|
+
* @param { string } subject
|
|
970
|
+
*
|
|
971
|
+
* @return { string }
|
|
972
|
+
*/
|
|
973
|
+
static replaceEnd(search: string, replace: string, subject: string): string;
|
|
974
|
+
/**
|
|
975
|
+
* Replace the patterns matching the given regular expression.
|
|
976
|
+
*
|
|
977
|
+
* @param { string } pattern
|
|
978
|
+
* @param { string | function } replace
|
|
979
|
+
* @param { string } subject
|
|
980
|
+
*
|
|
981
|
+
* @return { string }
|
|
982
|
+
*/
|
|
983
|
+
static replaceMatches(pattern: string, replace: string | Function, subject: string): string;
|
|
984
|
+
/**
|
|
985
|
+
* Remove any occurrence of the given string in the subject.
|
|
986
|
+
*
|
|
987
|
+
* @param { string } search
|
|
988
|
+
* @param { string } subject
|
|
989
|
+
* @param { boolean } caseSensitive
|
|
990
|
+
*
|
|
991
|
+
* @return { string }
|
|
992
|
+
*/
|
|
993
|
+
static remove(search: string, subject: string, caseSensitive?: boolean): string;
|
|
994
|
+
/**
|
|
995
|
+
* Reverse the given string.
|
|
996
|
+
*
|
|
997
|
+
* @param { string } value
|
|
998
|
+
*
|
|
999
|
+
* @return { string }
|
|
1000
|
+
*/
|
|
1001
|
+
static reverse(value: string): string;
|
|
1002
|
+
/**
|
|
1003
|
+
* Begin a string with a single instance of a given value.
|
|
1004
|
+
*
|
|
1005
|
+
* @param { string } value
|
|
1006
|
+
* @param { string } prefix
|
|
1007
|
+
*
|
|
1008
|
+
* @return { string }
|
|
1009
|
+
*/
|
|
1010
|
+
static start(value: string, prefix: string): string;
|
|
1011
|
+
/**
|
|
1012
|
+
* Substitute placeholders { key } using object with dot notation.
|
|
1013
|
+
*
|
|
1014
|
+
* @param str
|
|
1015
|
+
* @param data
|
|
1016
|
+
* @param def
|
|
1017
|
+
* @returns
|
|
1018
|
+
*/
|
|
1019
|
+
static substitute(str: string, data?: Record<string, unknown>, def?: string): string | undefined;
|
|
1020
|
+
/**
|
|
1021
|
+
* Convert the given string to upper-case.
|
|
1022
|
+
*
|
|
1023
|
+
* @param { string } value
|
|
1024
|
+
*
|
|
1025
|
+
* @return { string }
|
|
1026
|
+
*/
|
|
1027
|
+
static upper(value: string): string;
|
|
1028
|
+
/**
|
|
1029
|
+
* Convert the given string to title case.
|
|
1030
|
+
*
|
|
1031
|
+
* @param { string } value
|
|
1032
|
+
*
|
|
1033
|
+
* @return { string }
|
|
1034
|
+
*/
|
|
1035
|
+
static title(value: string): string;
|
|
1036
|
+
/**
|
|
1037
|
+
* Convert the given string to title case for each word.
|
|
1038
|
+
*
|
|
1039
|
+
* @param { string } value
|
|
1040
|
+
*
|
|
1041
|
+
* @return { string }
|
|
1042
|
+
*/
|
|
1043
|
+
static headline(value: string): string;
|
|
1044
|
+
/**
|
|
1045
|
+
* Convert the given string to APA-style title case.
|
|
1046
|
+
*
|
|
1047
|
+
* @see https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
|
|
1048
|
+
*
|
|
1049
|
+
* @param { string } value
|
|
1050
|
+
*
|
|
1051
|
+
* @return { string }
|
|
1052
|
+
*/
|
|
1053
|
+
static apa(value: string): string;
|
|
1054
|
+
/**
|
|
1055
|
+
* Get the singular form of an English word.
|
|
1056
|
+
*
|
|
1057
|
+
* @param { string } value
|
|
1058
|
+
*
|
|
1059
|
+
* @return { string }
|
|
1060
|
+
*/
|
|
1061
|
+
static singular(value: string): string;
|
|
1062
|
+
/**
|
|
1063
|
+
* Get the singular form of an English word.
|
|
1064
|
+
*
|
|
1065
|
+
* @param { string } value
|
|
1066
|
+
*
|
|
1067
|
+
* @alias singular
|
|
1068
|
+
*
|
|
1069
|
+
* @return { string }
|
|
1070
|
+
*/
|
|
1071
|
+
static singularize(value: string): string;
|
|
1072
|
+
/**
|
|
1073
|
+
* Generate a URL friendly "slug" from a given string.
|
|
1074
|
+
*
|
|
1075
|
+
* @param { string } title
|
|
1076
|
+
* @param { string } separator
|
|
1077
|
+
* @param { object } dictionary
|
|
1078
|
+
*
|
|
1079
|
+
* @return { string }
|
|
1080
|
+
*/
|
|
1081
|
+
static slug(title: string, separator?: string, dictionary?: {
|
|
1082
|
+
[key: string]: string;
|
|
1083
|
+
}): string;
|
|
1084
|
+
/**
|
|
1085
|
+
* Generate a URL friendly "slug" from a given string.
|
|
1086
|
+
*
|
|
1087
|
+
* @param { string } separator
|
|
1088
|
+
* @param { string } title
|
|
1089
|
+
* @param { object } dictionary
|
|
1090
|
+
*
|
|
1091
|
+
* @alias singular
|
|
1092
|
+
*
|
|
1093
|
+
* @return { string }
|
|
1094
|
+
*/
|
|
1095
|
+
static slugify(title: string, separator?: string, dictionary?: {
|
|
1096
|
+
[key: string]: string;
|
|
1097
|
+
}): string;
|
|
1098
|
+
/**
|
|
1099
|
+
* Convert a string to snake case.
|
|
1100
|
+
*
|
|
1101
|
+
* @param { string } value
|
|
1102
|
+
* @param { string } delimiter
|
|
1103
|
+
*
|
|
1104
|
+
* @return { string }
|
|
1105
|
+
*/
|
|
1106
|
+
static snake(value: string, delimiter?: string): string;
|
|
1107
|
+
/**
|
|
1108
|
+
* Uppercase the first character of each word in a string
|
|
1109
|
+
*
|
|
1110
|
+
* @param { string } string The input string.
|
|
1111
|
+
* @param { string } separators The optional separators contains the word separator characters.
|
|
1112
|
+
|
|
1113
|
+
* @return { string } String the modified string.
|
|
1114
|
+
*/
|
|
1115
|
+
static capitalize(string: string, separators?: string): string;
|
|
1116
|
+
/**
|
|
1117
|
+
* Uppercase the first character of each word in a string
|
|
1118
|
+
*
|
|
1119
|
+
* @param { string } string The input string.
|
|
1120
|
+
* @param { string } separators The optional separators contains the word separator characters.
|
|
1121
|
+
|
|
1122
|
+
* @return { string } String the modified string.
|
|
1123
|
+
*/
|
|
1124
|
+
static ucwords(string: string, separators?: string): string;
|
|
1125
|
+
/**
|
|
1126
|
+
* Remove all whitespace from both ends of a string.
|
|
1127
|
+
*
|
|
1128
|
+
* @param { string } value
|
|
1129
|
+
* @param { string | null } characters
|
|
1130
|
+
*
|
|
1131
|
+
* @return { string }
|
|
1132
|
+
*/
|
|
1133
|
+
static trim(value: string, characters?: string | null): string;
|
|
1134
|
+
/**
|
|
1135
|
+
* Remove all whitespace from the beginning of a string.
|
|
1136
|
+
*
|
|
1137
|
+
* @param { string } value
|
|
1138
|
+
* @param { string | null } characters
|
|
1139
|
+
*
|
|
1140
|
+
* @return { string }
|
|
1141
|
+
*/
|
|
1142
|
+
static ltrim(value: string, characters?: string | null): string;
|
|
1143
|
+
/**
|
|
1144
|
+
* Remove all whitespace from the end of a string.
|
|
1145
|
+
*
|
|
1146
|
+
* @param { string } value
|
|
1147
|
+
* @param { string | null } characters
|
|
1148
|
+
*
|
|
1149
|
+
* @return { string }
|
|
1150
|
+
*/
|
|
1151
|
+
static rtrim(value: string, characters?: string | null): string;
|
|
1152
|
+
/**
|
|
1153
|
+
* Remove all "extra" blank space from the given string.
|
|
1154
|
+
*
|
|
1155
|
+
* @param { string } value
|
|
1156
|
+
*
|
|
1157
|
+
* @return { string }
|
|
1158
|
+
*/
|
|
1159
|
+
static squish(value: string): string;
|
|
1160
|
+
/**
|
|
1161
|
+
* Determine if a given string starts with a given substring.
|
|
1162
|
+
*
|
|
1163
|
+
* @param { string } haystack
|
|
1164
|
+
* @param { string | string[] } needles
|
|
1165
|
+
*
|
|
1166
|
+
* @return { boolean }
|
|
1167
|
+
*/
|
|
1168
|
+
static startsWith(haystack: string, needles: string | string[]): boolean;
|
|
1169
|
+
/**
|
|
1170
|
+
* Determine if a given string doesn't start with a given substring.
|
|
1171
|
+
*
|
|
1172
|
+
* @param { string } haystack
|
|
1173
|
+
* @param { string | string[] } needles
|
|
1174
|
+
*
|
|
1175
|
+
* @return { boolean }
|
|
1176
|
+
*/
|
|
1177
|
+
static doesntStartWith(haystack: string, needles: string | string[]): boolean;
|
|
1178
|
+
/**
|
|
1179
|
+
* Convert a value to studly caps case.
|
|
1180
|
+
*
|
|
1181
|
+
* @param { string } value
|
|
1182
|
+
*
|
|
1183
|
+
* @return { string }
|
|
1184
|
+
*/
|
|
1185
|
+
static studly(value: string): string;
|
|
1186
|
+
/**
|
|
1187
|
+
* Convert a value to Pascal case.
|
|
1188
|
+
*
|
|
1189
|
+
* @param { string } value
|
|
1190
|
+
*
|
|
1191
|
+
* @return { string }
|
|
1192
|
+
*/
|
|
1193
|
+
static pascal(value: string): string;
|
|
1194
|
+
/**
|
|
1195
|
+
* Returns the portion of the string specified by the start and length parameters.
|
|
1196
|
+
*
|
|
1197
|
+
* @param { string } string
|
|
1198
|
+
* @param { number } start
|
|
1199
|
+
* @param { number | null } length
|
|
1200
|
+
*
|
|
1201
|
+
* @return { string }
|
|
1202
|
+
*/
|
|
1203
|
+
static substr(string: string, start: number, length?: number | null): string;
|
|
1204
|
+
/**
|
|
1205
|
+
* Returns the number of substring occurrences.
|
|
1206
|
+
*
|
|
1207
|
+
* @param { string } haystack
|
|
1208
|
+
* @param { string } needle
|
|
1209
|
+
* @param { number } offset
|
|
1210
|
+
* @param { number | null } length
|
|
1211
|
+
*
|
|
1212
|
+
* @return { number }
|
|
1213
|
+
*/
|
|
1214
|
+
static substrCount(haystack: string, needle: string, offset?: number, length?: number | null): number;
|
|
1215
|
+
/**
|
|
1216
|
+
* Replace text within a portion of a string.
|
|
1217
|
+
*
|
|
1218
|
+
* @param { string } string
|
|
1219
|
+
* @param { string } replace
|
|
1220
|
+
* @param { number } offset
|
|
1221
|
+
* @param { number | null } length
|
|
1222
|
+
*
|
|
1223
|
+
* @return { string }
|
|
1224
|
+
*/
|
|
1225
|
+
static substrReplace(string: string, replace: string, offset?: number, length?: number | null): string;
|
|
1226
|
+
/**
|
|
1227
|
+
* Swap multiple keywords in a string with other keywords.
|
|
1228
|
+
*
|
|
1229
|
+
* @param { object } map
|
|
1230
|
+
* @param { string } subject
|
|
1231
|
+
*
|
|
1232
|
+
* @return { string }
|
|
1233
|
+
*/
|
|
1234
|
+
static swap(map: Record<string, string>, subject: string): string;
|
|
1235
|
+
/**
|
|
1236
|
+
* Take the first or last {limit} characters of a string.
|
|
1237
|
+
*
|
|
1238
|
+
* @param { string } string
|
|
1239
|
+
* @param { number } limit
|
|
1240
|
+
*
|
|
1241
|
+
* @return { string }
|
|
1242
|
+
*/
|
|
1243
|
+
static take(string: string, limit: number): string;
|
|
1244
|
+
/**
|
|
1245
|
+
* Convert the given string to Base64 encoding.
|
|
1246
|
+
*
|
|
1247
|
+
* @param { string } string
|
|
1248
|
+
*
|
|
1249
|
+
* @return { string }
|
|
1250
|
+
*/
|
|
1251
|
+
static toBase64(string: string): string;
|
|
1252
|
+
/**
|
|
1253
|
+
* Decode the given Base64 encoded string.
|
|
1254
|
+
*
|
|
1255
|
+
* @param { string } string
|
|
1256
|
+
*
|
|
1257
|
+
* @return { string }
|
|
1258
|
+
*/
|
|
1259
|
+
static fromBase64(string: string): string;
|
|
1260
|
+
/**
|
|
1261
|
+
* Checks if a string is numeric
|
|
1262
|
+
*
|
|
1263
|
+
* @param string
|
|
1264
|
+
* @returns
|
|
1265
|
+
*/
|
|
1266
|
+
static isNumber(string: string): boolean;
|
|
1267
|
+
/**
|
|
1268
|
+
* Checks if a string is an integer
|
|
1269
|
+
*
|
|
1270
|
+
* @param string
|
|
1271
|
+
* @returns
|
|
1272
|
+
*/
|
|
1273
|
+
static isInteger(string: string): boolean;
|
|
1274
|
+
/**
|
|
1275
|
+
* ROT-N cipher.
|
|
1276
|
+
*
|
|
1277
|
+
* @param string
|
|
1278
|
+
* @param n
|
|
1279
|
+
* @returns
|
|
1280
|
+
*/
|
|
1281
|
+
static rot(string: string, n?: number): string;
|
|
1282
|
+
/**
|
|
1283
|
+
* Replace trailing punctuation with new format.
|
|
1284
|
+
*
|
|
1285
|
+
* @param string
|
|
1286
|
+
* @param newFormat
|
|
1287
|
+
* @returns
|
|
1288
|
+
*/
|
|
1289
|
+
static replacePunctuation(string: string, newFormat: string): string;
|
|
1290
|
+
/**
|
|
1291
|
+
* Array/object driven text replacement.
|
|
1292
|
+
*
|
|
1293
|
+
* @param string
|
|
1294
|
+
* @param replacements
|
|
1295
|
+
* @returns
|
|
1296
|
+
*/
|
|
1297
|
+
static translate(string: string, replacements: Record<string, string> | Array<[string, string]>): string;
|
|
1298
|
+
/**
|
|
1299
|
+
* Strip slashes recursively.
|
|
1300
|
+
*
|
|
1301
|
+
* @param string
|
|
1302
|
+
* @returns
|
|
1303
|
+
*/
|
|
1304
|
+
static ss(string: string): string;
|
|
1305
|
+
/**
|
|
1306
|
+
* First and last N lines.
|
|
1307
|
+
*
|
|
1308
|
+
* @param string
|
|
1309
|
+
* @param amount
|
|
1310
|
+
* @returns
|
|
1311
|
+
*/
|
|
1312
|
+
static firstLines(string: string, amount?: number): string;
|
|
1313
|
+
/**
|
|
1314
|
+
* Last and first N lines.
|
|
1315
|
+
*
|
|
1316
|
+
* @param string
|
|
1317
|
+
* @param amount
|
|
1318
|
+
* @returns
|
|
1319
|
+
*/
|
|
1320
|
+
static lastLines(string: string, amount?: number): string;
|
|
1321
|
+
/**
|
|
1322
|
+
* Make a string's first character lowercase.
|
|
1323
|
+
*
|
|
1324
|
+
* @param { string } string
|
|
1325
|
+
*
|
|
1326
|
+
* @return { string }
|
|
1327
|
+
*/
|
|
1328
|
+
static lcfirst(string: string): string;
|
|
1329
|
+
/**
|
|
1330
|
+
* Make a string's first character uppercase.
|
|
1331
|
+
*
|
|
1332
|
+
* @param { string } string
|
|
1333
|
+
*
|
|
1334
|
+
* @return { string }
|
|
1335
|
+
*/
|
|
1336
|
+
static ucfirst(string: string): string;
|
|
1337
|
+
/**
|
|
1338
|
+
* Split a string into pieces by uppercase characters.
|
|
1339
|
+
*
|
|
1340
|
+
* @param { string } string
|
|
1341
|
+
*
|
|
1342
|
+
* @return { string[] }
|
|
1343
|
+
*/
|
|
1344
|
+
static ucsplit(string: string): string[];
|
|
1345
|
+
/**
|
|
1346
|
+
* Get the number of words a string contains.
|
|
1347
|
+
*
|
|
1348
|
+
* @param { string } string
|
|
1349
|
+
*
|
|
1350
|
+
* @return { number }
|
|
1351
|
+
*/
|
|
1352
|
+
static wordCount(string: string): number;
|
|
1353
|
+
/**
|
|
1354
|
+
* Wrap a string to a given number of characters.
|
|
1355
|
+
*
|
|
1356
|
+
* @param { string } string
|
|
1357
|
+
* @param { number } characters
|
|
1358
|
+
* @param { string } breakStr
|
|
1359
|
+
* @param { boolean } cutLongWords
|
|
1360
|
+
*
|
|
1361
|
+
* @returns { string }
|
|
1362
|
+
*/
|
|
1363
|
+
static wordWrap(string: string, characters?: number, breakStr?: string, cutLongWords?: boolean): string;
|
|
1364
|
+
/**
|
|
1365
|
+
* Generate a UUID (version 4).
|
|
1366
|
+
*
|
|
1367
|
+
* @return { string }
|
|
1368
|
+
*/
|
|
1369
|
+
static uuid(): string;
|
|
1370
|
+
/**
|
|
1371
|
+
* Generate a UUID (version 7).
|
|
1372
|
+
*
|
|
1373
|
+
* @return { string }
|
|
1374
|
+
*/
|
|
1375
|
+
static uuid7(time?: Date | null): string;
|
|
1376
|
+
/**
|
|
1377
|
+
* Generate a time-ordered UUID (version 4).
|
|
1378
|
+
*
|
|
1379
|
+
* @return { string }
|
|
1380
|
+
*/
|
|
1381
|
+
static orderedUuid(): string;
|
|
1382
|
+
/**
|
|
1383
|
+
* Set the callable that will be used to generate UUIDs.
|
|
1384
|
+
*
|
|
1385
|
+
* @param { Function | null } factory
|
|
1386
|
+
*
|
|
1387
|
+
* @return { void }
|
|
1388
|
+
*/
|
|
1389
|
+
static createUuidsUsing(factory?: Function | null): void;
|
|
1390
|
+
/**
|
|
1391
|
+
* Set the sequence that will be used to generate random strings.
|
|
1392
|
+
*
|
|
1393
|
+
* @param { (string | undefined)[] } sequence
|
|
1394
|
+
* @param { Function | null } whenMissing
|
|
1395
|
+
*
|
|
1396
|
+
* @return { void }
|
|
1397
|
+
*/
|
|
1398
|
+
static createUuidsUsingSequence(sequence: (string | undefined)[], whenMissing?: Function | null): void;
|
|
1399
|
+
/**
|
|
1400
|
+
* Always return the same UUID when generating new UUIDs.
|
|
1401
|
+
*
|
|
1402
|
+
* @param { Function | null } callback
|
|
1403
|
+
*
|
|
1404
|
+
* @return { string }
|
|
1405
|
+
*/
|
|
1406
|
+
static freezeUuids(callback?: Function | null): string;
|
|
1407
|
+
/**
|
|
1408
|
+
* Indicate that UUIDs should be created normally and not using a custom factory.
|
|
1409
|
+
*
|
|
1410
|
+
* @return { void }
|
|
1411
|
+
*/
|
|
1412
|
+
static createUuidsNormally(): void;
|
|
1413
|
+
/**
|
|
1414
|
+
* Generate a ULID.
|
|
1415
|
+
*
|
|
1416
|
+
* @return { string }
|
|
1417
|
+
*/
|
|
1418
|
+
static ulid(): string;
|
|
1419
|
+
/**
|
|
1420
|
+
* Set the callable that will be used to generate ULIDs.
|
|
1421
|
+
*
|
|
1422
|
+
* @param { Function | null } factory
|
|
1423
|
+
*
|
|
1424
|
+
* @return { void }
|
|
1425
|
+
*/
|
|
1426
|
+
static createUlidsUsing(factory?: Function | null): void;
|
|
1427
|
+
/**
|
|
1428
|
+
* Set the sequence that will be used to generate ULIDs.
|
|
1429
|
+
*
|
|
1430
|
+
* @param { (string | undefined)[] } sequence
|
|
1431
|
+
* @param { Function | null } whenMissing
|
|
1432
|
+
*
|
|
1433
|
+
* @return { void }
|
|
1434
|
+
*/
|
|
1435
|
+
static createUlidsUsingSequence(sequence: (string | undefined)[], whenMissing?: Function | null): void;
|
|
1436
|
+
/**
|
|
1437
|
+
* Always return the same UUID when generating new UUIDs.
|
|
1438
|
+
*
|
|
1439
|
+
* @param { Function | null } callback
|
|
1440
|
+
*
|
|
1441
|
+
* @return { string }
|
|
1442
|
+
*/
|
|
1443
|
+
static freezeUlids(callback?: Function | null): string;
|
|
1444
|
+
/**
|
|
1445
|
+
* Indicate that ULIDs should be created normally and not using a custom factory.
|
|
1446
|
+
*
|
|
1447
|
+
* @return { void }
|
|
1448
|
+
*/
|
|
1449
|
+
static createUlidsNormally(): void;
|
|
1450
|
+
}
|
|
1451
|
+
declare class Stringable {
|
|
1452
|
+
#private;
|
|
1453
|
+
/**
|
|
1454
|
+
* Create a new instance of the class.
|
|
1455
|
+
*
|
|
1456
|
+
* @param { string } value
|
|
1457
|
+
*/
|
|
1458
|
+
constructor(value?: string);
|
|
1459
|
+
/**
|
|
1460
|
+
* Return the remainder of a string after the first occurrence of a given value.
|
|
1461
|
+
*
|
|
1462
|
+
* @param { string } search
|
|
1463
|
+
*
|
|
1464
|
+
* @return { Stringable }
|
|
1465
|
+
*/
|
|
1466
|
+
after(search: string): Stringable;
|
|
1467
|
+
/**
|
|
1468
|
+
* Return the remainder of a string after the last occurrence of a given value.
|
|
1469
|
+
*
|
|
1470
|
+
* @param { string } search
|
|
1471
|
+
*
|
|
1472
|
+
* @return { Stringable }
|
|
1473
|
+
*/
|
|
1474
|
+
afterLast(search: string): Stringable;
|
|
1475
|
+
/**
|
|
1476
|
+
* Append the given values to the string.
|
|
1477
|
+
*
|
|
1478
|
+
* @param { string | string[] } values
|
|
1479
|
+
*
|
|
1480
|
+
* @return { Stringable }
|
|
1481
|
+
*/
|
|
1482
|
+
append(...values: string[]): Stringable;
|
|
1483
|
+
/**
|
|
1484
|
+
* Append a new line to the string.
|
|
1485
|
+
*
|
|
1486
|
+
* @param { number } count
|
|
1487
|
+
*
|
|
1488
|
+
* @return { Stringable }
|
|
1489
|
+
*/
|
|
1490
|
+
newLine(count?: number): Stringable;
|
|
1491
|
+
/**
|
|
1492
|
+
* Transliterate a UTF-8 value to ASCII.
|
|
1493
|
+
*
|
|
1494
|
+
* @return { Stringable }
|
|
1495
|
+
*/
|
|
1496
|
+
ascii(): Stringable;
|
|
1497
|
+
/**
|
|
1498
|
+
* Get the trailing name component of the path.
|
|
1499
|
+
*
|
|
1500
|
+
* @param { string } suffix
|
|
1501
|
+
*
|
|
1502
|
+
* @return { Stringable }
|
|
1503
|
+
*/
|
|
1504
|
+
basename(suffix?: string): Stringable;
|
|
1505
|
+
/**
|
|
1506
|
+
* Get the character at the specified index.
|
|
1507
|
+
*
|
|
1508
|
+
* @param { number } index
|
|
1509
|
+
*
|
|
1510
|
+
* @return { string | false }
|
|
1511
|
+
*/
|
|
1512
|
+
charAt(index: number): string | false;
|
|
1513
|
+
/**
|
|
1514
|
+
* Remove the given string if it exists at the start of the current string.
|
|
1515
|
+
*
|
|
1516
|
+
* @param { string | string[] } needle
|
|
1517
|
+
*
|
|
1518
|
+
* @return { Stringable }
|
|
1519
|
+
*/
|
|
1520
|
+
chopStart(needle: string | string[]): Stringable;
|
|
1521
|
+
/**
|
|
1522
|
+
* Remove the given string if it exists at the end of the current string.
|
|
1523
|
+
*
|
|
1524
|
+
* @param { string | string[] } needle
|
|
1525
|
+
*
|
|
1526
|
+
* @return { Stringable }
|
|
1527
|
+
*/
|
|
1528
|
+
chopEnd(needle: string | string[]): Stringable;
|
|
1529
|
+
/**
|
|
1530
|
+
* Get the basename of the class path.
|
|
1531
|
+
*
|
|
1532
|
+
* @return { Stringable }
|
|
1533
|
+
*/
|
|
1534
|
+
classBasename(): Stringable;
|
|
1535
|
+
/**
|
|
1536
|
+
* Get the portion of a string before the first occurrence of a given value.
|
|
1537
|
+
*
|
|
1538
|
+
* @param { string } search
|
|
1539
|
+
*
|
|
1540
|
+
* @return { Stringable }
|
|
1541
|
+
*/
|
|
1542
|
+
before(search: string): Stringable;
|
|
1543
|
+
/**
|
|
1544
|
+
* Get the portion of a string before the last occurrence of a given value.
|
|
1545
|
+
*
|
|
1546
|
+
* @param { string } search
|
|
1547
|
+
*
|
|
1548
|
+
* @return { Stringable }
|
|
1549
|
+
*/
|
|
1550
|
+
beforeLast(search: string): Stringable;
|
|
1551
|
+
/**
|
|
1552
|
+
* Get the portion of a string between two given values.
|
|
1553
|
+
*
|
|
1554
|
+
* @param { string } from
|
|
1555
|
+
* @param { string } to
|
|
1556
|
+
*
|
|
1557
|
+
* @return { Stringable }
|
|
1558
|
+
*/
|
|
1559
|
+
between(from: string, to: string): Stringable;
|
|
1560
|
+
/**
|
|
1561
|
+
* Get the smallest possible portion of a string between two given values.
|
|
1562
|
+
*
|
|
1563
|
+
* @param { string } from
|
|
1564
|
+
* @param { string } to
|
|
1565
|
+
*
|
|
1566
|
+
* @return { Stringable }
|
|
1567
|
+
*/
|
|
1568
|
+
betweenFirst(from: string, to: string): Stringable;
|
|
1569
|
+
/**
|
|
1570
|
+
* Convert a value to camel case.
|
|
1571
|
+
*
|
|
1572
|
+
* @return { Stringable }
|
|
1573
|
+
*/
|
|
1574
|
+
camel(): Stringable;
|
|
1575
|
+
/**
|
|
1576
|
+
* Determine if a given string contains a given substring.
|
|
1577
|
+
*
|
|
1578
|
+
* @param { string | string[] } needles
|
|
1579
|
+
* @param { boolean } ignoreCase
|
|
1580
|
+
*
|
|
1581
|
+
* @return { boolean }
|
|
1582
|
+
*/
|
|
1583
|
+
contains(needles: string | string[], ignoreCase?: boolean): boolean;
|
|
1584
|
+
/**
|
|
1585
|
+
* Determine if a given string contains all array values.
|
|
1586
|
+
*
|
|
1587
|
+
* @param { string[] } needles
|
|
1588
|
+
* @param { boolean } ignoreCase
|
|
1589
|
+
*
|
|
1590
|
+
* @return { boolean }
|
|
1591
|
+
*/
|
|
1592
|
+
containsAll(needles: string[], ignoreCase?: boolean): boolean;
|
|
1593
|
+
/**
|
|
1594
|
+
* Determine if a given string doesn't contain a given substring.
|
|
1595
|
+
*
|
|
1596
|
+
* @param { string | string[] } needles
|
|
1597
|
+
* @param { boolean } ignoreCase
|
|
1598
|
+
*
|
|
1599
|
+
* @return { boolean }
|
|
1600
|
+
*/
|
|
1601
|
+
doesntContain(needles: string | string[], ignoreCase?: boolean): boolean;
|
|
1602
|
+
/**
|
|
1603
|
+
* Convert the case of a string.
|
|
1604
|
+
*
|
|
1605
|
+
* @param { Mode | number } mode
|
|
1606
|
+
*
|
|
1607
|
+
* @return { Stringable }
|
|
1608
|
+
*/
|
|
1609
|
+
convertCase(mode?: Mode | number): Stringable;
|
|
1610
|
+
/**
|
|
1611
|
+
* Replace consecutive instances of a given character with a single character in the given string.
|
|
1612
|
+
*
|
|
1613
|
+
* @param { string | string[] } characters
|
|
1614
|
+
*
|
|
1615
|
+
* @return { string }
|
|
1616
|
+
*/
|
|
1617
|
+
deduplicate(characters?: string | string[]): Stringable;
|
|
1618
|
+
/**
|
|
1619
|
+
* Get the parent directory's path.
|
|
1620
|
+
*
|
|
1621
|
+
* @param { number } levels
|
|
1622
|
+
*
|
|
1623
|
+
* @return { Stringable }
|
|
1624
|
+
*/
|
|
1625
|
+
dirname(levels?: number): Stringable;
|
|
1626
|
+
/**
|
|
1627
|
+
* Determine if a given string ends with a given substring.
|
|
1628
|
+
*
|
|
1629
|
+
* @param { string | string[] } needles
|
|
1630
|
+
*
|
|
1631
|
+
* @return { boolean }
|
|
1632
|
+
*/
|
|
1633
|
+
endsWith(needles: string | string[]): boolean;
|
|
1634
|
+
/**
|
|
1635
|
+
* Determine if a given string doesn't end with a given substring.
|
|
1636
|
+
*
|
|
1637
|
+
* @param { string | string[] } needles
|
|
1638
|
+
*
|
|
1639
|
+
* @return { boolean }
|
|
1640
|
+
*/
|
|
1641
|
+
doesntEndWith(needles: string | string[]): boolean;
|
|
1642
|
+
/**
|
|
1643
|
+
* Returns all the characters except the last.
|
|
1644
|
+
*
|
|
1645
|
+
* @returns
|
|
1646
|
+
*/
|
|
1647
|
+
chop(): Stringable;
|
|
1648
|
+
/**
|
|
1649
|
+
* Escape string for JSON encoding (returns string without quotes).
|
|
1650
|
+
*
|
|
1651
|
+
* @param string
|
|
1652
|
+
* @returns
|
|
1653
|
+
*/
|
|
1654
|
+
esc(): Stringable;
|
|
1655
|
+
/**
|
|
1656
|
+
* Determine if the string is an exact match with the given value.
|
|
1657
|
+
*
|
|
1658
|
+
* @param { Stringable | string } value
|
|
1659
|
+
*
|
|
1660
|
+
* @return { boolean }
|
|
1661
|
+
*/
|
|
1662
|
+
exactly(value: Stringable | string): boolean;
|
|
1663
|
+
/**
|
|
1664
|
+
* Extracts an excerpt from text that matches the first instance of a phrase.
|
|
1665
|
+
*
|
|
1666
|
+
* @param { string } phrase
|
|
1667
|
+
* @param { ExcerptOptions } options
|
|
1668
|
+
*
|
|
1669
|
+
* @return { string | null }
|
|
1670
|
+
*/
|
|
1671
|
+
excerpt(phrase?: string, options?: ExcerptOptions): string | null;
|
|
1672
|
+
/**
|
|
1673
|
+
* Explode the string into an array.
|
|
1674
|
+
*
|
|
1675
|
+
* @param { string } delimiter
|
|
1676
|
+
* @param { number } limit
|
|
1677
|
+
*
|
|
1678
|
+
* @return { string[] }
|
|
1679
|
+
*/
|
|
1680
|
+
explode(delimiter: string, limit?: number): string[];
|
|
1681
|
+
/**
|
|
1682
|
+
* Split a string using a regular expression or by length.
|
|
1683
|
+
*
|
|
1684
|
+
* @param { string } pattern
|
|
1685
|
+
* @param { number } limit
|
|
1686
|
+
*
|
|
1687
|
+
* @return { string[] }
|
|
1688
|
+
*/
|
|
1689
|
+
split(pattern: string, limit?: number): string[];
|
|
1690
|
+
/**
|
|
1691
|
+
* Cap a string with a single instance of a given value.
|
|
1692
|
+
*
|
|
1693
|
+
* @param { string } cap
|
|
1694
|
+
*
|
|
1695
|
+
* @return { Stringable }
|
|
1696
|
+
*/
|
|
1697
|
+
finish(cap: string): Stringable;
|
|
1698
|
+
/**
|
|
1699
|
+
* Determine if a given string matches a given pattern.
|
|
1700
|
+
*
|
|
1701
|
+
* @param { string | string[] } pattern
|
|
1702
|
+
* @param { boolean } ignoreCase
|
|
1703
|
+
*
|
|
1704
|
+
* @return { boolean }
|
|
1705
|
+
*/
|
|
1706
|
+
is(pattern: string | string[], ignoreCase?: boolean): boolean;
|
|
1707
|
+
/**
|
|
1708
|
+
* Determine if a given string is 7-bit ASCII.
|
|
1709
|
+
*
|
|
1710
|
+
* @return { boolean }
|
|
1711
|
+
*/
|
|
1712
|
+
isAscii(): boolean;
|
|
1713
|
+
/**
|
|
1714
|
+
* Determine if a given string is valid JSON.
|
|
1715
|
+
*
|
|
1716
|
+
* @return { boolean }
|
|
1717
|
+
*/
|
|
1718
|
+
isJson(): boolean;
|
|
1719
|
+
/**
|
|
1720
|
+
* Determine if a given value is a valid URL.
|
|
1721
|
+
*
|
|
1722
|
+
* @return { boolean }
|
|
1723
|
+
*/
|
|
1724
|
+
isUrl(): boolean;
|
|
1725
|
+
/**
|
|
1726
|
+
* Determine if a given string is a valid UUID.
|
|
1727
|
+
*
|
|
1728
|
+
* @return { boolean }
|
|
1729
|
+
*/
|
|
1730
|
+
isUuid(): boolean;
|
|
1731
|
+
/**
|
|
1732
|
+
* Determine if a given string is a valid ULID.
|
|
1733
|
+
*
|
|
1734
|
+
* @return { boolean }
|
|
1735
|
+
*/
|
|
1736
|
+
isUlid(): boolean;
|
|
1737
|
+
/**
|
|
1738
|
+
* Determine if the given string is empty.
|
|
1739
|
+
*
|
|
1740
|
+
* @return { boolean }
|
|
1741
|
+
*/
|
|
1742
|
+
isEmpty(): boolean;
|
|
1743
|
+
/**
|
|
1744
|
+
* Determine if the given string is not empty.
|
|
1745
|
+
*
|
|
1746
|
+
* @return { boolean }
|
|
1747
|
+
*/
|
|
1748
|
+
isNotEmpty(): boolean;
|
|
1749
|
+
/**
|
|
1750
|
+
* Convert a string to kebab case.
|
|
1751
|
+
*
|
|
1752
|
+
* @return { Stringable }
|
|
1753
|
+
*/
|
|
1754
|
+
kebab(): Stringable;
|
|
1755
|
+
/**
|
|
1756
|
+
* Return the length of the given string.
|
|
1757
|
+
*
|
|
1758
|
+
* @return { number }
|
|
1759
|
+
*/
|
|
1760
|
+
length(): number;
|
|
1761
|
+
/**
|
|
1762
|
+
* Limit the number of characters in a string.
|
|
1763
|
+
*
|
|
1764
|
+
* @param { number } limit
|
|
1765
|
+
* @param { string } end
|
|
1766
|
+
* @param { boolean } preserveWords
|
|
1767
|
+
*
|
|
1768
|
+
* @return { Stringable }
|
|
1769
|
+
*/
|
|
1770
|
+
limit(limit?: number, end?: string, preserveWords?: boolean): Stringable;
|
|
1771
|
+
/**
|
|
1772
|
+
* Get substring by start/stop indexes.
|
|
1773
|
+
*
|
|
1774
|
+
* @param start
|
|
1775
|
+
* @param stop
|
|
1776
|
+
* @returns
|
|
1777
|
+
*/
|
|
1778
|
+
sub(start: number, stop: number): Stringable;
|
|
1779
|
+
/**
|
|
1780
|
+
* Limit the number of characters in a string.
|
|
1781
|
+
*
|
|
1782
|
+
* @param { number } limit
|
|
1783
|
+
* @param { string } end
|
|
1784
|
+
* @param { boolean } preserveWords
|
|
1785
|
+
*
|
|
1786
|
+
* @alias limit
|
|
1787
|
+
*
|
|
1788
|
+
* @return { Stringable }
|
|
1789
|
+
*/
|
|
1790
|
+
truncate(limit?: number, end?: string, preserveWords?: boolean): Stringable;
|
|
1791
|
+
/**
|
|
1792
|
+
* Convert the given string to lower-case.
|
|
1793
|
+
*
|
|
1794
|
+
* @return { Stringable }
|
|
1795
|
+
*/
|
|
1796
|
+
lower(): Stringable;
|
|
1797
|
+
/**
|
|
1798
|
+
* Masks a portion of a string with a repeated character.
|
|
1799
|
+
*
|
|
1800
|
+
* @param { string } character
|
|
1801
|
+
* @param { number } index
|
|
1802
|
+
* @param { number | null }length
|
|
1803
|
+
*
|
|
1804
|
+
* @return { Stringable }
|
|
1805
|
+
*/
|
|
1806
|
+
mask(character: string, index: number, length?: number | null): Stringable;
|
|
1807
|
+
/**
|
|
1808
|
+
* Get the string matching the given pattern.
|
|
1809
|
+
*
|
|
1810
|
+
* @param { string } pattern
|
|
1811
|
+
*
|
|
1812
|
+
* @return { Stringable }
|
|
1813
|
+
*/
|
|
1814
|
+
match(pattern: string): Stringable;
|
|
1815
|
+
/**
|
|
1816
|
+
* Determine if a given string matches a given pattern.
|
|
1817
|
+
*
|
|
1818
|
+
* @param { string | string[] } pattern
|
|
1819
|
+
*
|
|
1820
|
+
* @return { boolean }
|
|
1821
|
+
*/
|
|
1822
|
+
isMatch(...pattern: string[]): boolean;
|
|
1823
|
+
/**
|
|
1824
|
+
* Get the string matching the given pattern.
|
|
1825
|
+
*
|
|
1826
|
+
* @param { string } pattern
|
|
1827
|
+
*
|
|
1828
|
+
* @return { string[] }
|
|
1829
|
+
*/
|
|
1830
|
+
matchAll(pattern: string): string[];
|
|
1831
|
+
/**
|
|
1832
|
+
* Determine if the string matches the given pattern.
|
|
1833
|
+
*
|
|
1834
|
+
* @param { string } pattern
|
|
1835
|
+
*
|
|
1836
|
+
* @return { boolean }
|
|
1837
|
+
*/
|
|
1838
|
+
test(pattern: string): boolean;
|
|
1839
|
+
/**
|
|
1840
|
+
* Remove all non-numeric characters from a string.
|
|
1841
|
+
*
|
|
1842
|
+
* @return { Stringable }
|
|
1843
|
+
*/
|
|
1844
|
+
numbers(): Stringable;
|
|
1845
|
+
/**
|
|
1846
|
+
* Pad both sides of the string with another.
|
|
1847
|
+
*
|
|
1848
|
+
* @param { number } length
|
|
1849
|
+
* @param { string } pad
|
|
1850
|
+
*
|
|
1851
|
+
* @return { Stringable }
|
|
1852
|
+
*/
|
|
1853
|
+
padBoth(length: number, pad?: string): Stringable;
|
|
1854
|
+
/**
|
|
1855
|
+
* Pad the left side of the string with another.
|
|
1856
|
+
*
|
|
1857
|
+
* @param { number } length
|
|
1858
|
+
* @param { string } pad
|
|
1859
|
+
*
|
|
1860
|
+
* @return { Stringable }
|
|
1861
|
+
*/
|
|
1862
|
+
padLeft(length: number, pad?: string): Stringable;
|
|
1863
|
+
/**
|
|
1864
|
+
* Pad the right side of the string with another.
|
|
1865
|
+
*
|
|
1866
|
+
* @param { number } length
|
|
1867
|
+
* @param { string } pad
|
|
1868
|
+
*
|
|
1869
|
+
* @return { Stringable }
|
|
1870
|
+
*/
|
|
1871
|
+
padRight(length: number, pad?: string): Stringable;
|
|
1872
|
+
/**
|
|
1873
|
+
* Call the given callback and return a new string.
|
|
1874
|
+
*
|
|
1875
|
+
* @param { keyof string | ((instance: this) => any) } callback
|
|
1876
|
+
*
|
|
1877
|
+
* @return { Stringable }
|
|
1878
|
+
*/
|
|
1879
|
+
pipe(callback: keyof string | ((instance: this) => any)): Stringable;
|
|
1880
|
+
/**
|
|
1881
|
+
* Get the plural form of an English word.
|
|
1882
|
+
*
|
|
1883
|
+
* @param { number } count
|
|
1884
|
+
*
|
|
1885
|
+
* @return { Stringable }
|
|
1886
|
+
*/
|
|
1887
|
+
plural(count?: number): Stringable;
|
|
1888
|
+
/**
|
|
1889
|
+
* Pluralize the last word of an English, studly caps case string.
|
|
1890
|
+
*
|
|
1891
|
+
* @param { number } count
|
|
1892
|
+
*
|
|
1893
|
+
* @return { Stringable }
|
|
1894
|
+
*/
|
|
1895
|
+
pluralStudly(count?: number): Stringable;
|
|
1896
|
+
/**
|
|
1897
|
+
* Pluralize the last word of an English, Pascal case string.
|
|
1898
|
+
*
|
|
1899
|
+
* @param { number } count
|
|
1900
|
+
*
|
|
1901
|
+
* @return { Stringable }
|
|
1902
|
+
*/
|
|
1903
|
+
pluralPascal(count?: number): Stringable;
|
|
1904
|
+
/**
|
|
1905
|
+
* Find the multibyte safe position of the first occurrence of the given substring.
|
|
1906
|
+
*
|
|
1907
|
+
* @param { string } needle
|
|
1908
|
+
* @param { number } offset
|
|
1909
|
+
*
|
|
1910
|
+
* @return { number | false }
|
|
1911
|
+
*/
|
|
1912
|
+
position(needle: string, offset?: number): number | false;
|
|
1913
|
+
/**
|
|
1914
|
+
* Prepend the given values to the string.
|
|
1915
|
+
*
|
|
1916
|
+
* @param { string | string[] } values
|
|
1917
|
+
*
|
|
1918
|
+
* @return { Stringable }
|
|
1919
|
+
*/
|
|
1920
|
+
prepend(...values: string[]): Stringable;
|
|
1921
|
+
/**
|
|
1922
|
+
* Remove any occurrence of the given string in the subject.
|
|
1923
|
+
*
|
|
1924
|
+
* @param { string } search
|
|
1925
|
+
* @param { boolean } caseSensitive
|
|
1926
|
+
*
|
|
1927
|
+
* @return { Stringable }
|
|
1928
|
+
*/
|
|
1929
|
+
remove(search: string, caseSensitive?: boolean): Stringable;
|
|
1930
|
+
/**
|
|
1931
|
+
* Reverse the string.
|
|
1932
|
+
*
|
|
1933
|
+
* @return { Stringable }
|
|
1934
|
+
*/
|
|
1935
|
+
reverse(): Stringable;
|
|
1936
|
+
/**
|
|
1937
|
+
* Substitute placeholders { key } using object with dot notation.
|
|
1938
|
+
*
|
|
1939
|
+
* @param data
|
|
1940
|
+
* @param def
|
|
1941
|
+
* @returns
|
|
1942
|
+
*/
|
|
1943
|
+
substitute(data?: Record<string, unknown>, def?: string): Stringable;
|
|
1944
|
+
/**
|
|
1945
|
+
* Repeat the string.
|
|
1946
|
+
*
|
|
1947
|
+
* @param { number } times
|
|
1948
|
+
*
|
|
1949
|
+
* @return { Stringable }
|
|
1950
|
+
*/
|
|
1951
|
+
repeat(times: number): Stringable;
|
|
1952
|
+
/**
|
|
1953
|
+
* Replace the given value in the given string.
|
|
1954
|
+
*
|
|
1955
|
+
* @param { string | string[] } search
|
|
1956
|
+
* @param { string } replace
|
|
1957
|
+
* @param { boolean } caseSensitive
|
|
1958
|
+
*
|
|
1959
|
+
* @return { Stringable }
|
|
1960
|
+
*/
|
|
1961
|
+
replace(search: string | string[], replace: string, caseSensitive?: boolean): Stringable;
|
|
1962
|
+
/**
|
|
1963
|
+
* Replace a given value in the string sequentially with an array.
|
|
1964
|
+
*
|
|
1965
|
+
* @param { string } search
|
|
1966
|
+
* @param { string[] } replace
|
|
1967
|
+
*
|
|
1968
|
+
* @return { Stringable }
|
|
1969
|
+
*/
|
|
1970
|
+
replaceArray(search: string, replace: string[]): Stringable;
|
|
1971
|
+
/**
|
|
1972
|
+
* Replace the first occurrence of a given value in the string.
|
|
1973
|
+
*
|
|
1974
|
+
* @param { string } search
|
|
1975
|
+
* @param { string } replace
|
|
1976
|
+
*
|
|
1977
|
+
* @return { Stringable }
|
|
1978
|
+
*/
|
|
1979
|
+
replaceFirst(search: string, replace: string): Stringable;
|
|
1980
|
+
/**
|
|
1981
|
+
* Replace the first occurrence of the given value if it appears at the start of the string.
|
|
1982
|
+
*
|
|
1983
|
+
* @param { string } search
|
|
1984
|
+
* @param { string } replace
|
|
1985
|
+
*
|
|
1986
|
+
* @return { Stringable }
|
|
1987
|
+
*/
|
|
1988
|
+
replaceStart(search: string, replace: string): Stringable;
|
|
1989
|
+
/**
|
|
1990
|
+
* Replace the last occurrence of a given value in the string.
|
|
1991
|
+
*
|
|
1992
|
+
* @param { string } search
|
|
1993
|
+
* @param { string } replace
|
|
1994
|
+
*
|
|
1995
|
+
* @return { Stringable }
|
|
1996
|
+
*/
|
|
1997
|
+
replaceLast(search: string, replace: string): Stringable;
|
|
1998
|
+
/**
|
|
1999
|
+
* Replace the last occurrence of a given value if it appears at the end of the string.
|
|
2000
|
+
*
|
|
2001
|
+
* @param { string } search
|
|
2002
|
+
* @param { string } replace
|
|
2003
|
+
*
|
|
2004
|
+
* @return { Stringable }
|
|
2005
|
+
*/
|
|
2006
|
+
replaceEnd(search: string, replace: string): Stringable;
|
|
2007
|
+
/**
|
|
2008
|
+
* Replace the patterns matching the given regular expression.
|
|
2009
|
+
*
|
|
2010
|
+
* @param { string } pattern
|
|
2011
|
+
* @param { string | function } replace
|
|
2012
|
+
*
|
|
2013
|
+
* @return { Stringable }
|
|
2014
|
+
*/
|
|
2015
|
+
replaceMatches(pattern: string, replace: string | Function): Stringable;
|
|
2016
|
+
/**
|
|
2017
|
+
* Remove all "extra" blank space from the given string.
|
|
2018
|
+
*
|
|
2019
|
+
* @return { Stringable }
|
|
2020
|
+
*/
|
|
2021
|
+
squish(): Stringable;
|
|
2022
|
+
/**
|
|
2023
|
+
* Begin a string with a single instance of a given value.
|
|
2024
|
+
*
|
|
2025
|
+
* @param { string } prefix
|
|
2026
|
+
*
|
|
2027
|
+
* @return { Stringable }
|
|
2028
|
+
*/
|
|
2029
|
+
start(prefix: string): Stringable;
|
|
2030
|
+
/**
|
|
2031
|
+
* Convert the given string to upper-case.
|
|
2032
|
+
*
|
|
2033
|
+
* @return { Stringable }
|
|
2034
|
+
*/
|
|
2035
|
+
upper(): Stringable;
|
|
2036
|
+
/**
|
|
2037
|
+
* Convert the given string to title case.
|
|
2038
|
+
*
|
|
2039
|
+
* @return { Stringable }
|
|
2040
|
+
*/
|
|
2041
|
+
title(): Stringable;
|
|
2042
|
+
/**
|
|
2043
|
+
* Convert the given string to title case for each word.
|
|
2044
|
+
*
|
|
2045
|
+
* @return { Stringable }
|
|
2046
|
+
*/
|
|
2047
|
+
headline(): Stringable;
|
|
2048
|
+
/**
|
|
2049
|
+
* Convert the given string to APA-style title case.
|
|
2050
|
+
*
|
|
2051
|
+
* @see https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
|
|
2052
|
+
*
|
|
2053
|
+
* @return { Stringable }
|
|
2054
|
+
*/
|
|
2055
|
+
apa(): Stringable;
|
|
2056
|
+
/**
|
|
2057
|
+
* Get the singular form of an English word.
|
|
2058
|
+
*
|
|
2059
|
+
* @return { Stringable }
|
|
2060
|
+
*/
|
|
2061
|
+
singular(): Stringable;
|
|
2062
|
+
/**
|
|
2063
|
+
* Generate a URL friendly "slug" from a given string.
|
|
2064
|
+
*
|
|
2065
|
+
* @param { string } separator
|
|
2066
|
+
* @param { object } dictionary
|
|
2067
|
+
*
|
|
2068
|
+
* @return { Stringable }
|
|
2069
|
+
*/
|
|
2070
|
+
slug(separator?: string, dictionary?: {
|
|
2071
|
+
[key: string]: string;
|
|
2072
|
+
}): Stringable;
|
|
2073
|
+
/**
|
|
2074
|
+
* Convert a string to snake case.
|
|
2075
|
+
*
|
|
2076
|
+
* @param { string } delimiter
|
|
2077
|
+
*
|
|
2078
|
+
* @return { Stringable }
|
|
2079
|
+
*/
|
|
2080
|
+
snake(delimiter?: string): Stringable;
|
|
2081
|
+
/**
|
|
2082
|
+
* Determine if a given string starts with a given substring.
|
|
2083
|
+
*
|
|
2084
|
+
* @param { string | string[] } needles
|
|
2085
|
+
*
|
|
2086
|
+
* @return { boolean }
|
|
2087
|
+
*/
|
|
2088
|
+
startsWith(needles: string | string[]): boolean;
|
|
2089
|
+
/**
|
|
2090
|
+
* Determine if a given string doesn't start with a given substring.
|
|
2091
|
+
*
|
|
2092
|
+
* @param { string | string[] } needles
|
|
2093
|
+
*
|
|
2094
|
+
* @return { boolean }
|
|
2095
|
+
*/
|
|
2096
|
+
doesntStartWith(needles: string | string[]): boolean;
|
|
2097
|
+
/**
|
|
2098
|
+
* Convert a value to studly caps case.
|
|
2099
|
+
*
|
|
2100
|
+
* @return { Stringable }
|
|
2101
|
+
*/
|
|
2102
|
+
studly(): Stringable;
|
|
2103
|
+
/**
|
|
2104
|
+
* Convert a value to Pascal case.
|
|
2105
|
+
*
|
|
2106
|
+
* @return { Stringable }
|
|
2107
|
+
*/
|
|
2108
|
+
pascal(): Stringable;
|
|
2109
|
+
/**
|
|
2110
|
+
* Returns the portion of the string specified by the start and length parameters.
|
|
2111
|
+
*
|
|
2112
|
+
* @param { number } start
|
|
2113
|
+
* @param { number | null } length
|
|
2114
|
+
*
|
|
2115
|
+
* @return { Stringable }
|
|
2116
|
+
*/
|
|
2117
|
+
substr(start: number, length?: number | null): Stringable;
|
|
2118
|
+
/**
|
|
2119
|
+
* Returns the number of substring occurrences.
|
|
2120
|
+
*
|
|
2121
|
+
* @param { string } needle
|
|
2122
|
+
* @param { number } offset
|
|
2123
|
+
* @param { number | null } length
|
|
2124
|
+
*
|
|
2125
|
+
* @return { number }
|
|
2126
|
+
*/
|
|
2127
|
+
substrCount(needle: string, offset?: number, length?: number | null): number;
|
|
2128
|
+
/**
|
|
2129
|
+
* Replace text within a portion of a string.
|
|
2130
|
+
*
|
|
2131
|
+
* @param { string } replace
|
|
2132
|
+
* @param { number } offset
|
|
2133
|
+
* @param { number | null } length
|
|
2134
|
+
*
|
|
2135
|
+
* @return { Stringable }
|
|
2136
|
+
*/
|
|
2137
|
+
substrReplace(replace: string, offset?: number, length?: number | null): Stringable;
|
|
2138
|
+
/**
|
|
2139
|
+
* Swap multiple keywords in a string with other keywords.
|
|
2140
|
+
*
|
|
2141
|
+
* @param { Record<string, string> } map
|
|
2142
|
+
*
|
|
2143
|
+
* @return { Stringable }
|
|
2144
|
+
*/
|
|
2145
|
+
swap(map: Record<string, string>): Stringable;
|
|
2146
|
+
/**
|
|
2147
|
+
* Take the first or last {limit} characters.
|
|
2148
|
+
*
|
|
2149
|
+
* @param { number } limit
|
|
2150
|
+
*
|
|
2151
|
+
* @return { Stringable }
|
|
2152
|
+
*/
|
|
2153
|
+
take(limit: number): Stringable;
|
|
2154
|
+
/**
|
|
2155
|
+
* Call the given Closure with this instance then return the instance.
|
|
2156
|
+
*
|
|
2157
|
+
* @param { ((instance: this) => any) } callback
|
|
2158
|
+
*
|
|
2159
|
+
* @return { Stringable }
|
|
2160
|
+
*/
|
|
2161
|
+
tap(callback: ((instance: this) => any)): this;
|
|
2162
|
+
/**
|
|
2163
|
+
* Trim the string of the given characters.
|
|
2164
|
+
*
|
|
2165
|
+
* @param { string | null } characters
|
|
2166
|
+
*
|
|
2167
|
+
* @return { Stringable }
|
|
2168
|
+
*/
|
|
2169
|
+
trim(characters?: string | null): Stringable;
|
|
2170
|
+
/**
|
|
2171
|
+
* Left trim the string of the given characters.
|
|
2172
|
+
*
|
|
2173
|
+
* @param { string | string[]|null } characters
|
|
2174
|
+
*
|
|
2175
|
+
* @return { Stringable }
|
|
2176
|
+
*/
|
|
2177
|
+
ltrim(characters?: string | null): Stringable;
|
|
2178
|
+
/**
|
|
2179
|
+
* Right trim the string of the given characters.
|
|
2180
|
+
*
|
|
2181
|
+
* @param { string | string[]|null } characters
|
|
2182
|
+
*
|
|
2183
|
+
* @return { Stringable }
|
|
2184
|
+
*/
|
|
2185
|
+
rtrim(characters?: string | null): Stringable;
|
|
2186
|
+
/**
|
|
2187
|
+
* Make a string's first character lowercase.
|
|
2188
|
+
*
|
|
2189
|
+
* @return { Stringable }
|
|
2190
|
+
*/
|
|
2191
|
+
lcfirst(): Stringable;
|
|
2192
|
+
/**
|
|
2193
|
+
* Make a string's first character uppercase.
|
|
2194
|
+
*
|
|
2195
|
+
* @return { Stringable }
|
|
2196
|
+
*/
|
|
2197
|
+
ucfirst(): Stringable;
|
|
2198
|
+
/**
|
|
2199
|
+
* Split a string by uppercase characters.
|
|
2200
|
+
*
|
|
2201
|
+
* @return { string[] }
|
|
2202
|
+
*/
|
|
2203
|
+
ucsplit(): string[];
|
|
2204
|
+
/**
|
|
2205
|
+
* Apply the callback if the given "value" is (or resolves to) truthy.
|
|
2206
|
+
*
|
|
2207
|
+
* @param { Value<this> } value
|
|
2208
|
+
* @param { Callback<this> } callback
|
|
2209
|
+
* @param { Fallback<this> } fallback
|
|
2210
|
+
*
|
|
2211
|
+
* @return { Stringable }
|
|
2212
|
+
*/
|
|
2213
|
+
when(value: Value<this>, callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2214
|
+
/**
|
|
2215
|
+
* Apply the callback if the given "value" is (or resolves to) falsy.
|
|
2216
|
+
*
|
|
2217
|
+
* @param { Value<this> } value
|
|
2218
|
+
* @param { Callback<this> } callback
|
|
2219
|
+
* @param { Fallback<this> } fallback
|
|
2220
|
+
*
|
|
2221
|
+
* @return { this }
|
|
2222
|
+
*/
|
|
2223
|
+
unless(value: Value<this>, callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2224
|
+
/**
|
|
2225
|
+
* Execute the given callback if the string contains a given substring.
|
|
2226
|
+
*
|
|
2227
|
+
* @param { string | string[] } needles
|
|
2228
|
+
* @param { Callback<this> } callback
|
|
2229
|
+
* @param { Fallback<this> } fallback
|
|
2230
|
+
*
|
|
2231
|
+
* @return { this }
|
|
2232
|
+
*/
|
|
2233
|
+
whenContains(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2234
|
+
/**
|
|
2235
|
+
* Execute the given callback if the string contains all array values.
|
|
2236
|
+
*
|
|
2237
|
+
* @param { string[] } needles
|
|
2238
|
+
* @param { Callback<this> } callback
|
|
2239
|
+
* @param { Fallback<this> } fallback
|
|
2240
|
+
*
|
|
2241
|
+
* @return { this }
|
|
2242
|
+
*/
|
|
2243
|
+
whenContainsAll(needles: string[], callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2244
|
+
/**
|
|
2245
|
+
* Execute the given callback if the string is empty.
|
|
2246
|
+
*
|
|
2247
|
+
* @param { Callback<this> } callback
|
|
2248
|
+
* @param { Fallback<this> } fallback
|
|
2249
|
+
*
|
|
2250
|
+
* @return { this }
|
|
2251
|
+
*/
|
|
2252
|
+
whenEmpty(callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2253
|
+
/**
|
|
2254
|
+
* Execute the given callback if the string is not empty.
|
|
2255
|
+
*
|
|
2256
|
+
* @param { Callback<this> } callback
|
|
2257
|
+
* @param { Fallback<this> } fallback
|
|
2258
|
+
*
|
|
2259
|
+
* @return { this }
|
|
2260
|
+
*/
|
|
2261
|
+
whenNotEmpty(callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2262
|
+
/**
|
|
2263
|
+
* Execute the given callback if the string ends with a given substring.
|
|
2264
|
+
*
|
|
2265
|
+
* @param { string | string[] } needles
|
|
2266
|
+
* @param { Callback<this> } callback
|
|
2267
|
+
* @param { Fallback<this> } fallback
|
|
2268
|
+
*
|
|
2269
|
+
* @return { this }
|
|
2270
|
+
*/
|
|
2271
|
+
whenEndsWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2272
|
+
/**
|
|
2273
|
+
* Execute the given callback if the string doesn't end with a given substring.
|
|
2274
|
+
*
|
|
2275
|
+
* @param { string | string[] } needles
|
|
2276
|
+
* @param { Callback<this> } callback
|
|
2277
|
+
* @param { Fallback<this> } fallback
|
|
2278
|
+
*
|
|
2279
|
+
* @return { this }
|
|
2280
|
+
*/
|
|
2281
|
+
whenDoesntEndWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2282
|
+
/**
|
|
2283
|
+
* Execute the given callback if the string is an exact match with the given value.
|
|
2284
|
+
*
|
|
2285
|
+
* @param { string } value
|
|
2286
|
+
* @param { Callback<this> } callback
|
|
2287
|
+
* @param { Fallback<this> } fallback
|
|
2288
|
+
*
|
|
2289
|
+
* @return { this }
|
|
2290
|
+
*/
|
|
2291
|
+
whenExactly(value: string, callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2292
|
+
/**
|
|
2293
|
+
* Execute the given callback if the string is not an exact match with the given value.
|
|
2294
|
+
*
|
|
2295
|
+
* @param { string } value
|
|
2296
|
+
* @param { Callback<this> } callback
|
|
2297
|
+
* @param { Fallback<this> } fallback
|
|
2298
|
+
*
|
|
2299
|
+
* @return { this }
|
|
2300
|
+
*/
|
|
2301
|
+
whenNotExactly(value: string, callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2302
|
+
/**
|
|
2303
|
+
* Execute the given callback if the string matches a given pattern.
|
|
2304
|
+
*
|
|
2305
|
+
* @param { string | string[] } pattern
|
|
2306
|
+
* @param { Callback<this> } callback
|
|
2307
|
+
* @param { Fallback<this> } fallback
|
|
2308
|
+
*
|
|
2309
|
+
* @return { this }
|
|
2310
|
+
*/
|
|
2311
|
+
whenIs(pattern: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2312
|
+
/**
|
|
2313
|
+
* Execute the given callback if the string is 7-bit ASCII.
|
|
2314
|
+
*
|
|
2315
|
+
* @param { Callback<this> } callback
|
|
2316
|
+
* @param { Fallback<this> } fallback
|
|
2317
|
+
*
|
|
2318
|
+
* @return { this }
|
|
2319
|
+
*/
|
|
2320
|
+
whenIsAscii(callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2321
|
+
/**
|
|
2322
|
+
* Execute the given callback if the string is a valid UUID.
|
|
2323
|
+
*
|
|
2324
|
+
* @param { Callback<this> } callback
|
|
2325
|
+
* @param { Fallback<this> } fallback
|
|
2326
|
+
*
|
|
2327
|
+
* @return { this }
|
|
2328
|
+
*/
|
|
2329
|
+
whenIsUuid(callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2330
|
+
/**
|
|
2331
|
+
* Execute the given callback if the string is a valid ULID.
|
|
2332
|
+
*
|
|
2333
|
+
* @param { Callback<this> } callback
|
|
2334
|
+
* @param { Fallback<this> } fallback
|
|
2335
|
+
*
|
|
2336
|
+
* @return { this }
|
|
2337
|
+
*/
|
|
2338
|
+
whenIsUlid(callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2339
|
+
/**
|
|
2340
|
+
* Execute the given callback if the string starts with a given substring.
|
|
2341
|
+
*
|
|
2342
|
+
* @param { string | string[] } needles
|
|
2343
|
+
* @param { Callback<this> } callback
|
|
2344
|
+
* @param { Fallback<this> } fallback
|
|
2345
|
+
*
|
|
2346
|
+
* @return { this }
|
|
2347
|
+
*/
|
|
2348
|
+
whenStartsWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2349
|
+
/**
|
|
2350
|
+
* Execute the given callback if the string doesn't start with a given substring.
|
|
2351
|
+
*
|
|
2352
|
+
* @param { string | string[] } needles
|
|
2353
|
+
* @param { Callback<this> } callback
|
|
2354
|
+
* @param { Fallback<this> } fallback
|
|
2355
|
+
*
|
|
2356
|
+
* @return { this }
|
|
2357
|
+
*/
|
|
2358
|
+
whenDoesntStartWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2359
|
+
/**
|
|
2360
|
+
* Execute the given callback if the string matches the given pattern.
|
|
2361
|
+
*
|
|
2362
|
+
* @param { string } pattern
|
|
2363
|
+
* @param { Callback<this> } callback
|
|
2364
|
+
* @param { Fallback<this> } fallback
|
|
2365
|
+
*
|
|
2366
|
+
* @return { this }
|
|
2367
|
+
*/
|
|
2368
|
+
whenTest(pattern: string, callback: Callback<this>, fallback?: Fallback<this>): this;
|
|
2369
|
+
/**
|
|
2370
|
+
* Limit the number of words in a string.
|
|
2371
|
+
*
|
|
2372
|
+
* @param { number } words
|
|
2373
|
+
* @param { string } end
|
|
2374
|
+
*
|
|
2375
|
+
* @return { Stringable }
|
|
2376
|
+
*/
|
|
2377
|
+
words(words?: number, end?: string): Stringable;
|
|
2378
|
+
/**
|
|
2379
|
+
* Get the number of words a string contains.
|
|
2380
|
+
*
|
|
2381
|
+
* @return { number }
|
|
2382
|
+
*/
|
|
2383
|
+
wordCount(): number;
|
|
2384
|
+
/**
|
|
2385
|
+
* Wrap a string to a given number of characters.
|
|
2386
|
+
*
|
|
2387
|
+
* @param { number } characters
|
|
2388
|
+
* @param { string } breakStr
|
|
2389
|
+
* @param { boolean } cutLongWords
|
|
2390
|
+
*
|
|
2391
|
+
* @returns { this }
|
|
2392
|
+
*/
|
|
2393
|
+
wordWrap(characters?: number, breakStr?: string, cutLongWords?: boolean): Stringable;
|
|
2394
|
+
/**
|
|
2395
|
+
* Wrap the string with the given strings.
|
|
2396
|
+
*
|
|
2397
|
+
* @param { string } before
|
|
2398
|
+
* @param { string | null } after
|
|
2399
|
+
*
|
|
2400
|
+
* @return { Stringable }
|
|
2401
|
+
*/
|
|
2402
|
+
wrap(before: string, after?: string | null): Stringable;
|
|
2403
|
+
/**
|
|
2404
|
+
* Unwrap the string with the given strings.
|
|
2405
|
+
*
|
|
2406
|
+
* @param { string } before
|
|
2407
|
+
* @param { string | null } after
|
|
2408
|
+
*
|
|
2409
|
+
* @return { Stringable }
|
|
2410
|
+
*/
|
|
2411
|
+
unwrap(before: string, after?: string | null): Stringable;
|
|
2412
|
+
/**
|
|
2413
|
+
* Convert the string into a `HtmlString` instance.
|
|
2414
|
+
*
|
|
2415
|
+
* @return { HtmlStringType }
|
|
2416
|
+
*/
|
|
2417
|
+
toHtmlString(): HtmlStringType;
|
|
2418
|
+
/**
|
|
2419
|
+
* Convert the string to Base64 encoding.
|
|
2420
|
+
*
|
|
2421
|
+
* @return { Stringable }
|
|
2422
|
+
*/
|
|
2423
|
+
toBase64(): Stringable;
|
|
2424
|
+
/**
|
|
2425
|
+
* Decode the Base64 encoded string.
|
|
2426
|
+
*
|
|
2427
|
+
* @return { Stringable }
|
|
2428
|
+
*/
|
|
2429
|
+
fromBase64(): Stringable;
|
|
2430
|
+
/**
|
|
2431
|
+
* Checks if a string is numeric
|
|
2432
|
+
*
|
|
2433
|
+
* @return { boolean }
|
|
2434
|
+
*/
|
|
2435
|
+
isNumber(): boolean;
|
|
2436
|
+
/**
|
|
2437
|
+
* Checks if a string is an integer
|
|
2438
|
+
*
|
|
2439
|
+
* @return { boolean }
|
|
2440
|
+
*/
|
|
2441
|
+
isInteger(): boolean;
|
|
2442
|
+
/**
|
|
2443
|
+
* ROT-N cipher.
|
|
2444
|
+
*
|
|
2445
|
+
* @param n
|
|
2446
|
+
* @returns
|
|
2447
|
+
*/
|
|
2448
|
+
rot(n?: number): Stringable;
|
|
2449
|
+
/**
|
|
2450
|
+
* Replace trailing punctuation with new format.
|
|
2451
|
+
*
|
|
2452
|
+
* @param newFormat
|
|
2453
|
+
* @returns
|
|
2454
|
+
*/
|
|
2455
|
+
replacePunctuation(newFormat: string): Stringable;
|
|
2456
|
+
/**
|
|
2457
|
+
* Array/object driven text replacement.
|
|
2458
|
+
*
|
|
2459
|
+
* @param replacements
|
|
2460
|
+
* @returns
|
|
2461
|
+
*/
|
|
2462
|
+
translate(replacements: Record<string, string> | Array<[string, string]>): Stringable;
|
|
2463
|
+
/**
|
|
2464
|
+
* Strip slashes recursively.
|
|
2465
|
+
*
|
|
2466
|
+
* @returns
|
|
2467
|
+
*/
|
|
2468
|
+
ss(): Stringable;
|
|
2469
|
+
/**
|
|
2470
|
+
* First and last N lines.
|
|
2471
|
+
*
|
|
2472
|
+
* @param amount
|
|
2473
|
+
* @returns
|
|
2474
|
+
*/
|
|
2475
|
+
firstLines(amount?: number): Stringable;
|
|
2476
|
+
/**
|
|
2477
|
+
* Last and first N lines.
|
|
2478
|
+
*
|
|
2479
|
+
* @param amount
|
|
2480
|
+
* @returns
|
|
2481
|
+
*/
|
|
2482
|
+
lastLines(amount?: number): Stringable;
|
|
2483
|
+
/**
|
|
2484
|
+
* Dump the string.
|
|
2485
|
+
*
|
|
2486
|
+
* @return { void }
|
|
2487
|
+
*/
|
|
2488
|
+
dump(): void;
|
|
2489
|
+
/**
|
|
2490
|
+
* Dump the string and end the script.
|
|
2491
|
+
*
|
|
2492
|
+
* @return { never }
|
|
2493
|
+
*/
|
|
2494
|
+
dd(): never;
|
|
2495
|
+
/**
|
|
2496
|
+
* Get the underlying string value.
|
|
2497
|
+
*
|
|
2498
|
+
* @return { string }
|
|
2499
|
+
*/
|
|
2500
|
+
value(): string;
|
|
2501
|
+
/**
|
|
2502
|
+
* Get the raw string value.
|
|
2503
|
+
*
|
|
2504
|
+
* @return { string }
|
|
2505
|
+
*/
|
|
2506
|
+
toString(): string;
|
|
2507
|
+
/**
|
|
2508
|
+
* Get the underlying string value as an integer.
|
|
2509
|
+
*
|
|
2510
|
+
* @param { number } base
|
|
2511
|
+
*
|
|
2512
|
+
* @return { number }
|
|
2513
|
+
*/
|
|
2514
|
+
toInteger(base?: number): number;
|
|
2515
|
+
/**
|
|
2516
|
+
* Get the underlying string value as a float.
|
|
2517
|
+
*
|
|
2518
|
+
* @return { number }
|
|
2519
|
+
*/
|
|
2520
|
+
toFloat(): number;
|
|
2521
|
+
/**
|
|
2522
|
+
* Get the underlying string value as a boolean.
|
|
2523
|
+
*
|
|
2524
|
+
* Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
|
|
2525
|
+
*
|
|
2526
|
+
* @return { boolean }
|
|
2527
|
+
*/
|
|
2528
|
+
toBoolean(): boolean;
|
|
2529
|
+
/**
|
|
2530
|
+
* Get the underlying string value as a formatted Date string.
|
|
2531
|
+
*
|
|
2532
|
+
* @param { string | null } format
|
|
2533
|
+
* @param { string | null } tz
|
|
2534
|
+
*/
|
|
2535
|
+
toDate(format?: string | null, tz?: string | null): string;
|
|
2536
|
+
}
|
|
2537
|
+
declare class HtmlString {
|
|
2538
|
+
/**
|
|
2539
|
+
* The HTML string.
|
|
2540
|
+
*
|
|
2541
|
+
* @type { string }
|
|
2542
|
+
*/
|
|
2543
|
+
private readonly html;
|
|
2544
|
+
/**
|
|
2545
|
+
* Create a new HTML string instance.
|
|
2546
|
+
*
|
|
2547
|
+
* @param { string } html
|
|
2548
|
+
*
|
|
2549
|
+
* @return void
|
|
2550
|
+
*/
|
|
2551
|
+
constructor(html?: string);
|
|
2552
|
+
/**
|
|
2553
|
+
* Get the HTML string.
|
|
2554
|
+
*
|
|
2555
|
+
* @return { HtmlStringType }
|
|
2556
|
+
*/
|
|
2557
|
+
toHtml(): HtmlStringType;
|
|
2558
|
+
/**
|
|
2559
|
+
* Determine if the given HTML string is empty.
|
|
2560
|
+
*
|
|
2561
|
+
* @return { boolean }
|
|
2562
|
+
*/
|
|
2563
|
+
isEmpty(): boolean;
|
|
2564
|
+
/**
|
|
2565
|
+
* Determine if the given HTML string is not empty.
|
|
2566
|
+
*
|
|
2567
|
+
* @return { boolean }
|
|
2568
|
+
*/
|
|
2569
|
+
isNotEmpty(): boolean;
|
|
2570
|
+
/**
|
|
2571
|
+
* Get the HTML string.
|
|
2572
|
+
*
|
|
2573
|
+
* @return { string }
|
|
2574
|
+
*/
|
|
2575
|
+
toString(): string;
|
|
2576
|
+
}
|
|
180
2577
|
/**
|
|
181
|
-
* Get
|
|
2578
|
+
* Get a new Stringable object from the given string.
|
|
182
2579
|
*
|
|
183
|
-
* @param
|
|
184
|
-
* @param search
|
|
185
|
-
* @returns
|
|
186
|
-
*/
|
|
187
|
-
declare const after: (value: string, search: string) => string;
|
|
188
|
-
/**
|
|
189
|
-
* Get the portion of the string after the last occurrence of the given value.
|
|
2580
|
+
* @param { string } string
|
|
190
2581
|
*
|
|
191
|
-
* @
|
|
192
|
-
* @param search
|
|
193
|
-
* @returns
|
|
2582
|
+
* @return Stringable
|
|
194
2583
|
*/
|
|
195
|
-
declare
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
2584
|
+
declare function str(string?: string): Stringable;
|
|
2585
|
+
//#endregion
|
|
2586
|
+
//#region src/Helpers/Time.d.ts
|
|
2587
|
+
declare function format(date: ConfigType, fmt: string): string;
|
|
2588
|
+
declare const TimeClass: {
|
|
2589
|
+
new (date?: dayjs.ConfigType): Dayjs;
|
|
2590
|
+
} & typeof Dayjs;
|
|
2591
|
+
declare class Time extends TimeClass {
|
|
2592
|
+
private instance;
|
|
2593
|
+
constructor(config?: ConfigType);
|
|
2594
|
+
/**
|
|
2595
|
+
* Start time of a specific unit.
|
|
2596
|
+
*
|
|
2597
|
+
* @returns
|
|
2598
|
+
*/
|
|
2599
|
+
start(unit?: OpUnitType): dayjs.Dayjs;
|
|
2600
|
+
/**
|
|
2601
|
+
* End time of a specific unit.
|
|
2602
|
+
*
|
|
2603
|
+
* @returns
|
|
2604
|
+
*/
|
|
2605
|
+
end(unit?: OpUnitType): dayjs.Dayjs;
|
|
2606
|
+
/**
|
|
2607
|
+
* Get the first day of the month of the given date
|
|
2608
|
+
*
|
|
2609
|
+
* @returns
|
|
2610
|
+
*/
|
|
2611
|
+
firstDayOfMonth(): Time;
|
|
2612
|
+
carbonFormat(template?: string | undefined): string;
|
|
2613
|
+
/**
|
|
2614
|
+
* Get the last day of the month of the given date
|
|
2615
|
+
*
|
|
2616
|
+
* @returns
|
|
2617
|
+
*/
|
|
2618
|
+
lastDayOfMonth(): Time;
|
|
2619
|
+
/**
|
|
2620
|
+
* Get a random time between the specified hour and minute.
|
|
2621
|
+
*
|
|
2622
|
+
* @param startHour
|
|
2623
|
+
* @param startMinute
|
|
2624
|
+
* @param endHour
|
|
2625
|
+
* @param endMinute
|
|
2626
|
+
* @returns
|
|
2627
|
+
*/
|
|
2628
|
+
randomTime(startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): Time;
|
|
2629
|
+
/**
|
|
2630
|
+
* Create a date for a given timestamp.
|
|
2631
|
+
*
|
|
2632
|
+
* @param timestamp - Unix timestamp
|
|
2633
|
+
*
|
|
2634
|
+
* @return {Date} object
|
|
2635
|
+
*/
|
|
2636
|
+
static fromTimestamp(timestamp: number): Date;
|
|
2637
|
+
/**
|
|
2638
|
+
* Get current time instance.
|
|
2639
|
+
*
|
|
2640
|
+
* @returns Current time
|
|
2641
|
+
*/
|
|
2642
|
+
static now(): Time;
|
|
2643
|
+
/**
|
|
2644
|
+
* Parse the time
|
|
2645
|
+
*
|
|
2646
|
+
* @param date
|
|
2647
|
+
* @returns
|
|
2648
|
+
*/
|
|
2649
|
+
static parse(date: dayjs.ConfigType): Time;
|
|
2650
|
+
/**
|
|
2651
|
+
* Get the formatted date according to the string of tokens passed in.
|
|
2652
|
+
*
|
|
2653
|
+
* To escape characters, wrap them in square brackets (e.g. [MM]).
|
|
2654
|
+
*
|
|
2655
|
+
* @param time - current time
|
|
2656
|
+
* @param template - time format
|
|
2657
|
+
*/
|
|
2658
|
+
static format(time?: ConfigType, template?: string | undefined): string;
|
|
2659
|
+
/**
|
|
2660
|
+
* Get the difference in days from today.
|
|
2661
|
+
*
|
|
2662
|
+
* @param time
|
|
2663
|
+
* @param startHour
|
|
2664
|
+
* @param startMinute
|
|
2665
|
+
* @param endHour
|
|
2666
|
+
* @param endMinute
|
|
2667
|
+
* @returns
|
|
2668
|
+
*/
|
|
2669
|
+
static randomTime(time?: ConfigType, startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): Time;
|
|
2670
|
+
/**
|
|
2671
|
+
* Get the first day of the month of the given date
|
|
2672
|
+
*
|
|
2673
|
+
* @param time
|
|
2674
|
+
*
|
|
2675
|
+
* @returns
|
|
2676
|
+
*/
|
|
2677
|
+
static firstDayOfMonth(time: ConfigType): Time;
|
|
2678
|
+
/**
|
|
2679
|
+
* Get the last day of the month of the given date
|
|
2680
|
+
*
|
|
2681
|
+
* @param time
|
|
2682
|
+
*
|
|
2683
|
+
* @returns
|
|
2684
|
+
*/
|
|
2685
|
+
static lastDayOfMonth(time: ConfigType): Time;
|
|
2686
|
+
}
|
|
2687
|
+
//#endregion
|
|
2688
|
+
//#region src/GlobalBootstrap.d.ts
|
|
2689
|
+
type CollapseStatics<T extends Record<string, any>> = { [K in keyof T]: T[K] };
|
|
2690
|
+
type Omitables = 'start' | 'take' | 'reverse' | 'chunk' | 'find' | 'pop' | 'end' | 'shift' | 'push' | 'at' | 'prototype' | 'concat' | 'join' | 'slice' | 'sort' | 'splice' | 'includes' | 'indexOf' | 'lastIndexOf' | 'findIndex' | 'every' | 'some' | 'forEach' | 'map' | 'filter' | 'reduce' | 'unshift' | 'flat' | 'flatMap' | 'keys' | 'fill' | 'copyWithin' | 'entries' | 'values' | 'reduceRight' | 'length' | 'of' | typeof Symbol.unscopables | typeof Symbol.iterator;
|
|
2691
|
+
type TakeTime = Pick<typeof Time, 'now' | 'format' | 'fromTimestamp' | 'randomTime' | 'firstDayOfMonth' | 'lastDayOfMonth' | 'parse'>;
|
|
2692
|
+
type TakeString = Pick<typeof Str, 'after' | 'afterLast' | 'apa' | 'ascii' | 'before' | 'beforeLast' | 'between' | 'betweenFirst' | 'capitalize' | 'plural' | 'singular' | 'title'>;
|
|
227
2693
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
* @param word - The word to singularize
|
|
231
|
-
* @returns The singular form of the word
|
|
2694
|
+
* Global helpers interface that mirrors Laravel's helpers
|
|
2695
|
+
* and provides convenient access to all utility functions
|
|
232
2696
|
*/
|
|
233
|
-
|
|
2697
|
+
interface GlobalHelpers extends Omit<CollapseStatics<typeof Arr_d_exports>, Omitables>, Omit<CollapseStatics<TakeString>, Omitables | 'random' | 'uuid'>, Omit<CollapseStatics<TakeTime>, Omitables>, Omit<CollapseStatics<typeof Obj_d_exports>, Omitables>, Omit<CollapseStatics<typeof Crypto_d_exports>, Omitables>, Omit<CollapseStatics<typeof Number_d_exports>, Omitables>, Omit<CollapseStatics<typeof DumpDie_d_exports>, Omitables> {
|
|
2698
|
+
Arr: typeof Arr_d_exports;
|
|
2699
|
+
Str: typeof Str;
|
|
2700
|
+
Obj: typeof Obj_d_exports;
|
|
2701
|
+
Crypto: typeof Crypto_d_exports;
|
|
2702
|
+
Time: typeof Time;
|
|
2703
|
+
Number: typeof Number_d_exports;
|
|
2704
|
+
DumpDie: typeof DumpDie_d_exports;
|
|
2705
|
+
}
|
|
234
2706
|
/**
|
|
235
|
-
*
|
|
236
|
-
*
|
|
2707
|
+
* Bootstrap the global helpers into the global scope.
|
|
2708
|
+
* This enables optional global access to all helper functions.
|
|
237
2709
|
*
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*/
|
|
242
|
-
declare const slugify: (str: string, joiner?: string) => string;
|
|
243
|
-
/**
|
|
244
|
-
* Truncates a string to a specified length and appends an ellipsis if needed.
|
|
2710
|
+
* Example usage:
|
|
2711
|
+
* ```typescript
|
|
2712
|
+
* import { loadHelpers } from '@h3ravel/support'
|
|
245
2713
|
*
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
* @param ellipsis - String to append if truncated (default: "...")
|
|
249
|
-
* @returns The truncated string
|
|
250
|
-
*/
|
|
251
|
-
declare const subString: (str: string, len: number, ellipsis?: string) => string;
|
|
252
|
-
/**
|
|
253
|
-
* Replaces placeholders in a string with corresponding values from a data object.
|
|
2714
|
+
* // Make helpers globally available
|
|
2715
|
+
* loadHelpers()
|
|
254
2716
|
*
|
|
255
|
-
*
|
|
256
|
-
*
|
|
257
|
-
* //
|
|
2717
|
+
* // Now you can use:
|
|
2718
|
+
* Arr.chunk([1, 2, 3, 4], 2)
|
|
2719
|
+
* // or directly:
|
|
2720
|
+
* chunk([1, 2, 3, 4], 2)
|
|
2721
|
+
* Str.capitalize('hello world')
|
|
2722
|
+
* // or directly:
|
|
2723
|
+
* capitalize('hello world')
|
|
2724
|
+
* ```
|
|
258
2725
|
*
|
|
259
|
-
* @param
|
|
260
|
-
* @param data - Object containing values to substitute. Supports nested keys via dot notation.
|
|
261
|
-
* @param def - Default value to use if a key is missing. (Optional)
|
|
262
|
-
* @returns The substituted string or undefined if the input string or data is invalid.
|
|
2726
|
+
* @param target - The target object to attach helpers to (default: globalThis)
|
|
263
2727
|
*/
|
|
264
|
-
declare
|
|
2728
|
+
declare function loadHelpers(target?: any): void;
|
|
265
2729
|
/**
|
|
266
|
-
*
|
|
267
|
-
*
|
|
2730
|
+
* Clean up global helpers by removing them from the global scope.
|
|
2731
|
+
* This function removes all global helper attachments.
|
|
268
2732
|
*
|
|
269
|
-
* @param
|
|
270
|
-
* @param len - Maximum length (default: 20)
|
|
271
|
-
* @param suffix - Suffix to append if truncated (default: "...")
|
|
272
|
-
* @returns The truncated string
|
|
2733
|
+
* @param target - The target object to clean up (default: globalThis)
|
|
273
2734
|
*/
|
|
274
|
-
declare
|
|
2735
|
+
declare function cleanHelpers(target?: any): void;
|
|
275
2736
|
//#endregion
|
|
276
|
-
export { CamelToSnakeCase, KeysToSnakeCase, SnakeToCamelCase, SnakeToTitleCase, TGeneric, XGeneric, abbreviate,
|
|
2737
|
+
export { Arr_d_exports as Arr, Callback, CamelToSnakeCase, Crypto_d_exports as Crypto, DumpDie_d_exports as DumpDie, ExcerptOptions, Fallback, Function, GlobalHelpers, HtmlString, HtmlStringType, KeysToSnakeCase, Mode, Number_d_exports as Number, Obj_d_exports as Obj, SnakeToCamelCase, SnakeToTitleCase, Str, Stringable, TGeneric, Time, Value, XGeneric, abbreviate, alternate, base64Decode, base64Encode, caesarCipher, checksum, chunk, cleanHelpers, collapse, combine, dd, dot, dump, extractProperties, find, first, flatten, forget, format, getValue, hash, hmac, humanize, isEmpty, isNotEmpty, last, loadHelpers, modObj, pop, prepend, random, randomColor, randomPassword, randomSecure, range, reverse, safeDot, secureToken, setNested, shift, slugifyKeys, str, take, toBytes, toHumanTime, uuid, verifyChecksum, xor };
|
|
277
2738
|
//# sourceMappingURL=index.d.ts.map
|