@h3ravel/support 0.15.3 → 0.15.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts DELETED
@@ -1,3219 +0,0 @@
1
- /// <reference path="./app.globals.d.ts" />
2
- import dayjs, { ConfigType, Dayjs, OpUnitType } from "dayjs";
3
- import { DotFlatten, DotNestedKeys, DotNestedValue } from "@h3ravel/shared";
4
-
5
- //#region src/Contracts/StrContract.d.ts
6
- /**
7
- * Converts CamelCased strings to snake_case
8
- */
9
- type CamelToSnakeCase<S extends string> = S extends `${infer T}${infer U}` ? U extends Uncapitalize<U> ? `${Uncapitalize<T>}${CamelToSnakeCase<U>}` : `${Uncapitalize<T>}_${CamelToSnakeCase<U>}` : S;
10
- /**
11
- * Converts snake_cased strings to camelCase
12
- */
13
- type SnakeToCamelCase<S extends string> = S extends `${infer T}_${infer U}` ? `${T}${Capitalize<SnakeToCamelCase<U>>}` : S;
14
- /**
15
- * Converts snake_cased strings to TitleCasea
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$1> = boolean | ((instance: T$1) => boolean);
24
- type Callback<T$1> = (instance: T$1, value: boolean) => T$1 | void | undefined;
25
- type Fallback<T$1> = Callback<T$1> | null;
26
- interface Function {
27
- (...args: any[]): any;
28
- }
29
- //#endregion
30
- //#region src/Contracts/ObjContract.d.ts
31
- /**
32
- * Convert CamelCased Object keys to snake_case
33
- */
34
- type KeysToSnakeCase<T$1> = { [K in keyof T$1 as CamelToSnakeCase<string & K>]: T$1[K] };
35
- type TGeneric<V = any, K$1 extends string = string> = Record<K$1, V>;
36
- type XGeneric<V = TGeneric, T$1 = any> = {
37
- [key: string]: T$1;
38
- } & V;
39
- type DotPath<T$1> = T$1 extends object ? { [K in keyof T$1 & (string | number)]: T$1[K] extends object ? `${K}` | `${K}.${DotPath<T$1[K]>}` : `${K}` }[keyof T$1 & (string | number)] : never;
40
- //#endregion
41
- //#region src/Contracts/TypeCast.d.ts
42
- type Arrayable = {
43
- [key: string]: any;
44
- toArray(): any[];
45
- };
46
- type Jsonable = {
47
- [key: string]: any;
48
- toJSON(): any;
49
- };
50
- type JsonSerializable = {
51
- [key: string]: any;
52
- jsonSerialize(): any;
53
- };
54
- //#endregion
55
- //#region src/Exceptions/InvalidArgumentException.d.ts
56
- /**
57
- * Custom error for invalid type coercion
58
- */
59
- declare class InvalidArgumentException extends Error {
60
- constructor(message: string);
61
- }
62
- //#endregion
63
- //#region src/Exceptions/RuntimeException.d.ts
64
- /**
65
- * Custom error for invalid type coercion
66
- */
67
- declare class RuntimeException extends Error {
68
- constructor(message: string);
69
- }
70
- declare namespace Crypto_d_exports {
71
- export { base64Decode, base64Encode, caesarCipher, checksum, hash, hmac, random, randomColor, randomPassword, randomSecure, secureToken, uuid, verifyChecksum, xor };
72
- }
73
- /**
74
- * Generate a random UUID string.
75
- *
76
- * @returns A random UUID string
77
- */
78
- declare const uuid: () => string;
79
- /**
80
- * Generate a random string of specified length.
81
- *
82
- * @param length - Length of the random string (default: 16)
83
- * @param charset - Character set to use (default: alphanumeric)
84
- * @returns A random string
85
- */
86
- declare const random: (length?: number, charset?: string) => string;
87
- /**
88
- * Secure random string generator that uses crypto.randomBytes.
89
- *
90
- * @param length - Length of the random string (default: 32)
91
- * @returns A cryptographically secure random string
92
- */
93
- declare const randomSecure: (length?: number) => string;
94
- /**
95
- * Hash a string using the specified algorithm.
96
- *
97
- * @param data - Data to hash
98
- * @param algorithm - Hash algorithm (default: 'sha256')
99
- * @returns Hexadecimal hash string
100
- */
101
- declare const hash: (data: string, algorithm?: string) => string;
102
- /**
103
- * Hash a string with salt using HMAC.
104
- *
105
- * @param data - Data to hash
106
- * @param key - Secret key for HMAC
107
- * @param algorithm - Hash algorithm (default: 'sha256')
108
- * @returns Hexadecimal hash string
109
- */
110
- declare const hmac: (data: string, key: string, algorithm?: string) => string;
111
- /**
112
- * Encode data to base64.
113
- *
114
- * @param data - Data to encode
115
- * @returns Base64 encoded string
116
- */
117
- declare const base64Encode: (data: string) => string;
118
- /**
119
- * Decode base64 data.
120
- *
121
- * @param data - Base64 string to decode
122
- * @returns Decoded string
123
- */
124
- declare const base64Decode: (data: string) => string;
125
- /**
126
- * Simple XOR encryption/decryption.
127
- *
128
- * @param data - Data to encrypt/decrypt
129
- * @param key - Encryption key
130
- * @returns Encrypted/decrypted string
131
- */
132
- declare const xor: (data: string, key: string) => string;
133
- /**
134
- * Generate a random hex color code.
135
- *
136
- * @returns A hex color code string (e.g., '#a3b2f3')
137
- */
138
- declare const randomColor: () => string;
139
- /**
140
- * Generate a secure password using configurable parameters.
141
- *
142
- * @param length - Password length (default: 16)
143
- * @param options - Character options
144
- * @returns A secure password string
145
- */
146
- interface PasswordOptions {
147
- useUppercase?: boolean;
148
- useLowercase?: boolean;
149
- useNumbers?: boolean;
150
- useSymbols?: boolean;
151
- }
152
- declare const randomPassword: (length?: number, options?: PasswordOptions) => string;
153
- /**
154
- * Generate a cryptographically secure token for APIs, sessions, etc.
155
- *
156
- * @param strength - Token strength (bytes) (default: 32)
157
- * @returns A secure token string
158
- */
159
- declare const secureToken: (strength?: number) => string;
160
- /**
161
- * Create a checksum for data integrity verification.
162
- *
163
- * @param data - Data to create checksum for
164
- * @param algorithm - Hash algorithm (default: 'sha256')
165
- * @returns SHA256 checksum
166
- */
167
- declare const checksum: (data: string, algorithm?: string) => string;
168
- /**
169
- * Verify data integrity using checksum.
170
- *
171
- * @param data - Data to verify
172
- * @param expectedChecksum - Expected checksum
173
- * @param algorithm - Hash algorithm (default: 'sha256')
174
- * @returns True if checksums match
175
- */
176
- declare const verifyChecksum: (data: string, expectedChecksum: string, algorithm?: string) => boolean;
177
- /**
178
- * Simple Caesar cipher implementation.
179
- *
180
- * @param text - Text to encrypt/decrypt
181
- * @param shift - Number of positions to shift (default: 13)
182
- * @returns Encrypted/decrypted text
183
- */
184
- declare const caesarCipher: (text: string, shift?: number) => string;
185
- declare namespace DumpDie_d_exports {
186
- export { dd, dump };
187
- }
188
- /**
189
- * Dump something and kill the process for quick debugging. Based on Laravel's dd()
190
- *
191
- * @param args
192
- */
193
- declare const dd: (...args: unknown[]) => never;
194
- /**
195
- * Dump something but keep the process for quick debugging. Based on Laravel's dump()
196
- *
197
- * @param args
198
- */
199
- declare const dump: (...args: unknown[]) => void;
200
- declare namespace Number_d_exports {
201
- export { abbreviate, humanize, toBytes, toHumanTime };
202
- }
203
- /**
204
- * Abbreviates large numbers using SI symbols (K, M, B...)
205
- * and formats the output according to the given locale.
206
- *
207
- * @param value - The number to abbreviate
208
- * @param locale - Optional locale string (default: "en-US")
209
- * @returns A localized, abbreviated number string
210
- */
211
- declare const abbreviate: (value?: number, locale?: string) => string;
212
- /**
213
- * Concverts a number into human readable string
214
- *
215
- * @param num The number to convert
216
- * @param slugify convert the ouput into a slug using this as a separator
217
- * @returns
218
- */
219
- declare const humanize: (num: number, slugify?: "-" | "_") => string;
220
- /**
221
- * Converts a number of bytes into a human-readable string.
222
- *
223
- * @param bytes - The size in bytes to convert
224
- * @param decimals - Number of decimal places to display (default: 2)
225
- * @param bits - If true, uses 1000-based (SI) units (B, KB, MB...);
226
- * otherwise uses 1024-based binary units (Bytes, KiB...)
227
- * @returns A formatted string with the appropriate unit
228
- */
229
- declare const toBytes: (bytes?: number, decimals?: number, bits?: boolean) => string;
230
- /**
231
- * Formats a duration (in seconds) into a human-readable string.
232
- *
233
- * @param seconds - Duration in seconds
234
- * @param worded - If true, outputs worded format (e.g., "1hr 2min 3sec"),
235
- * otherwise HH:MM:SS (e.g., "01:02:03")
236
- * @returns A formatted time string
237
- */
238
- declare const toHumanTime: (seconds?: number, worded?: boolean) => string;
239
- declare namespace Obj_d_exports {
240
- export { Obj, data_fill, data_forget, data_get, data_set, dot, extractProperties, getValue, isPlainObject, modObj, safeDot, setNested, slugifyKeys, toCssClasses, toCssStyles, undot };
241
- }
242
- /**
243
- * Flattens a nested object into a single-level object
244
- * with dot-separated keys.
245
- *
246
- * Example:
247
- * doter({
248
- * user: { name: "John", address: { city: "NY" } },
249
- * active: true
250
- * })
251
- *
252
- * Output:
253
- * {
254
- * "user.name": "John",
255
- * "user.address.city": "NY",
256
- * "active": true
257
- * }
258
- *
259
- * @template T - The type of the input object
260
- * @param obj - The nested object to flatten
261
- * @returns A flattened object with dotted keys and inferred types
262
- */
263
- declare const dot: <T$1 extends Record<string, any>>(obj: T$1) => DotFlatten<T$1>;
264
- /**
265
- * Extracts a subset of properties from an object.
266
- *
267
- * @template T - Type of the source object
268
- * @template K - Keys of T to extract
269
- * @param obj - The source object
270
- * @param keys - Array of keys to extract
271
- * @returns A new object with only the specified keys
272
- */
273
- declare const extractProperties: <T$1 extends object, K$1 extends keyof T$1>(obj: T$1, keys?: readonly K$1[]) => Pick<T$1, K$1>;
274
- /**
275
- * Safely retrieves a value from an object by key or nested keys.
276
- *
277
- * @template T - Type of the source object
278
- * @param key - Single key or tuple [parentKey, childKey]
279
- * @param item - The source object
280
- * @returns The found value as a string or the key itself if not found
281
- */
282
- declare const getValue: <T$1 extends Record<string, any>>(key: string | [keyof T$1, keyof T$1[string]], item: T$1) => string;
283
- /**
284
- * Maps over an object's entries and returns a new object
285
- * with transformed keys and/or values.
286
- *
287
- * @template T - Type of the input object
288
- * @template R - Type of the new values
289
- * @param obj - The object to transform
290
- * @param callback - Function that receives [key, value] and returns [newKey, newValue]
291
- * @returns A new object with transformed entries
292
- */
293
- declare const modObj: <T$1 extends object, R>(obj: T$1, callback: (_entry: [keyof T$1 & string, T$1[keyof T$1]]) => [string, R]) => Record<string, R>;
294
- declare function safeDot<T$1 extends Record<string, any>>(_data: T$1): T$1;
295
- declare function safeDot<T$1 extends Record<string, any>, K$1 extends DotNestedKeys<T$1>>(_data: T$1, _key?: K$1): DotNestedValue<T$1, K$1>;
296
- /**
297
- * Sets a nested property on an object using dot notation.
298
- *
299
- * @example
300
- * const obj = {}
301
- * setNested(obj, 'app.user.name', 'Legacy')
302
- * console.log(obj)
303
- * // Output: { app: { user: { name: 'Legacy' } } }
304
- *
305
- * @param obj - The target object to modify.
306
- * @param key - The dot-separated key (e.g., 'app.user.name').
307
- * @param value - The value to set at the specified path.
308
- */
309
- declare const setNested: (obj: Record<string, any>, key: string, value: any) => void;
310
- /**
311
- * Converts object keys to a slugified format (e.g., snake_case).
312
- *
313
- * @template T - Type of the input object
314
- * @param obj - The object whose keys will be slugified
315
- * @param only - Optional array of keys to slugify (others remain unchanged)
316
- * @param separator - Separator for slugified keys (default: "_")
317
- * @returns A new object with slugified keys
318
- */
319
- declare const slugifyKeys: <T$1 extends object>(obj: T$1, only?: string[], separator?: string) => KeysToSnakeCase<T$1>;
320
- /**
321
- * toCssClasses
322
- *
323
- * Convert array/object/string input into a CSS class string.
324
- * - Arrays: included if truthy
325
- * - Objects: keys included if value is truthy
326
- * - Strings: included as-is
327
- */
328
- declare function toCssClasses<T$1 extends string | Record<string, boolean> | Array<string | false | null | undefined>>(input: T$1): string;
329
- /**
330
- * toCssStyles
331
- *
332
- * Convert object input into CSS style string.
333
- * - Only includes truthy values (ignores null/undefined/false)
334
- */
335
- declare function toCssStyles<T$1 extends Record<string, string | number | boolean | null | undefined>>(styles: T$1): string;
336
- /**
337
- * undot
338
- *
339
- * Convert a dot-notated object back into nested structure.
340
- *
341
- * Example:
342
- * undot({ 'a.b': 1, 'c.0': 2 }) -> { a: { b: 1 }, c: [2] }
343
- */
344
- declare function undot(obj: Record<string, any>): Record<string, any>;
345
- /**
346
- * data_get
347
- *
348
- * Get a value from an object using dot notation.
349
- */
350
- declare function data_get<T$1 extends object, P extends DotPath<T$1> | DotPath<T$1>[], D = undefined>(obj: T$1, path: P, defaultValue?: D): T$1 | any;
351
- /**
352
- * data_set
353
- *
354
- * Set a value in an object using dot notation. Mutates the object.
355
- */
356
- declare function data_set<T$1 extends Record<string, any>, P extends string | string[], V>(obj: T$1, path: P, value: V): asserts obj is T$1 & Record<P extends string ? P : P[0], V>;
357
- /**
358
- * data_fill
359
- *
360
- * Like data_set, but only sets the value if the key does NOT exist.
361
- */
362
- declare function data_fill(obj: Record<string, any>, path: string | string[], value: any): void;
363
- /**
364
- * data_forget
365
- *
366
- * Remove a key from an object using dot notation.
367
- */
368
- declare function data_forget(obj: Record<string, any>, path: string | string[]): void;
369
- /**
370
- * Checks if a value is a plain object (not array, function, etc.)
371
- *
372
- * @param value
373
- * @returns
374
- */
375
- declare function isPlainObject(value: any): value is Record<string, any>;
376
- declare class Obj {
377
- /**
378
- * Check if the value is a non-null object (associative/accessible).
379
- */
380
- static accessible(value: unknown): value is Record<string, any>;
381
- /**
382
- * Add a key-value pair to an object only if the key does not already exist.
383
- *
384
- * Returns a new object (does not mutate original).
385
- */
386
- static add<T$1 extends Record<string, any>, K$1 extends string, V>(obj: T$1, key: K$1, value: V): T$1 & Record<K$1, V>;
387
- /**
388
- * Deeply merges two or more objects.
389
- * - Arrays are replaced (not concatenated)
390
- * - Objects are merged recursively
391
- * - Non-object values overwrite previous ones
392
- *
393
- * @param objects
394
- * @returns
395
- */
396
- static deepMerge<T$1 extends Record<string, any>>(...objects: (Partial<T$1> | undefined | null)[]): T$1;
397
- /**
398
- * Split object into [keys, values]
399
- */
400
- static divide<T$1 extends Record<string, any>>(obj: T$1): [string[], any[]];
401
- /**
402
- * Check if a key exists in the object.
403
- */
404
- static exists<T$1 extends Record<string, any>>(obj: T$1, key: string | number): boolean;
405
- /**
406
- * Get a value from an object using dot notation.
407
- *
408
- * Example:
409
- * Obj.get({a:{b:1}}, 'a.b') -> 1
410
- */
411
- static get<T$1 extends object, P extends DotPath<T$1>, D = undefined>(obj: T$1, path: P, defaultValue?: D): any;
412
- /**
413
- * Check if the object has a given key or keys (dot notation supported).
414
- */
415
- static has<T$1 extends object, P extends DotPath<T$1>>(obj: T$1, keys: P | P[]): boolean;
416
- /**
417
- * Check if an object is associative (has at least one non-numeric key).
418
- */
419
- static isAssoc(obj: unknown): obj is Record<string, any>;
420
- /**
421
- * Add a prefix to all keys of the object.
422
- */
423
- static prependKeysWith<T$1 extends Record<string, any>>(obj: T$1, prefix: string): Record<string, any>;
424
- /**
425
- * Convert an object into a URL query string.
426
- *
427
- * Nested objects/arrays are flattened using bracket notation.
428
- */
429
- static query(obj: Record<string, any>): string;
430
- }
431
- //#endregion
432
- //#region src/Helpers/Arr.d.ts
433
- /**
434
- * Arr — Laravel-like array helpers for JavaScript.
435
- *
436
- * - Methods aim for clear, predictable JS behavior.
437
- * - Inputs are validated where useful; functions try not to mutate arguments.
438
- */
439
- declare class Arr {
440
- /**
441
- * Helper: is a value an object (but not null).
442
- */
443
- static _isObject(value: any): boolean;
444
- /**
445
- * Helper: deep clone for safety (simple).
446
- * Uses JSON methods — good for typical data shapes (no functions, Dates, Maps).
447
- */
448
- static _clone<A = any>(value: A): A;
449
- /**
450
- * Retrieve a value using dot notation
451
- * Throws if value is not an array
452
- */
453
- static array(obj: any, path: string, defaultValue?: number): any[];
454
- /**
455
- * Retrieve a value using dot notation
456
- * Throws if value is not a boolean
457
- */
458
- static boolean(obj: any, path: string, defaultValue?: boolean): boolean;
459
- /**
460
- * Flatten an array of arrays by one level.
461
- *
462
- * Example:
463
- * Arr.collapse([[1,2], [3], 4]) -> [1,2,3,4]
464
- */
465
- static collapse<X>(array: X[][] | X[]): X[];
466
- /**
467
- * Cartesian product of arrays.
468
- *
469
- * Example:
470
- * Arr.crossJoin([1,2], ['a','b']) -> [[1,'a'], [1,'b'], [2,'a'], [2,'b']]
471
- *
472
- * Accepts any number of array arguments (or single array-of-arrays).
473
- */
474
- static crossJoin<A>(...arrays: A[][]): A[][];
475
- /**
476
- * Split an array (or object) into two arrays: [keys, values].
477
- *
478
- * For arrays, keys are numeric indices. For objects, keys are property names.
479
- *
480
- * Example:
481
- * Arr.divide(['a','b']) -> [[0,1], ['a','b']]
482
- * Arr.divide({x:1,y:2}) -> [['x','y'], [1,2]]
483
- */
484
- static divide<A>(input: A[] | Record<string, A>): (A[] | number[])[] | (A[] | string[])[];
485
- /**
486
- * Flatten a nested array/object structure into a single-level object
487
- * with dot-notated keys.
488
- *
489
- * Example:
490
- * Arr.dot({ a: { b: 1 }, c: [2,3] }) -> { 'a.b': 1, 'c.0': 2, 'c.1': 3 }
491
- *
492
- * Works for arrays and plain objects.
493
- */
494
- static dot<A>(input: A[] | Record<string, A>, prefix?: string): Record<string, A>;
495
- /**
496
- * Checks if all elements satisfy the predicate
497
- */
498
- static every<T$1>(array: T$1[], predicate: (item: T$1) => boolean): boolean;
499
- /**
500
- * Remove items by keys/indices from an array or properties from an object.
501
- *
502
- * For arrays: keys are numeric indices (single number or array of numbers).
503
- *
504
- * Returns a shallow-copied result (does not mutate input).
505
- *
506
- * Example:
507
- * Arr.except([10,20,30], [1]) -> [10,30]
508
- */
509
- static except<A extends any[] | Record<string, any>, X>(input: A, keys: X[]): A;
510
- /**
511
- * Return the first element of an array that satisfies the predicate,
512
- * or the first element if no predicate is provided, otherwise the defaultValue.
513
- *
514
- * Predicate can be true (boolean), a function or a value to match (strict equality).
515
- *
516
- * When predicate is true (boolean), the first element will be removed and a tuple will be returned [el, rest].
517
- *
518
- * @param array
519
- * @param predicate
520
- * @param defaultValue
521
- *
522
- * @returns
523
- */
524
- static first<A, P extends (((arg: A) => true) | true)>(array: A[], predicate?: P | undefined, defaultValue?: A | undefined): P extends true ? [A, A[]] : A | undefined;
525
- /**
526
- * Recursively flatten an array up to `depth` levels (default: Infinity).
527
- *
528
- * Example:
529
- * Arr.flatten([1, [2, [3]]], 1) -> [1,2,[3]]
530
- */
531
- static flatten<A>(array: A[], depth?: number): A[];
532
- /**
533
- * Retrieve a value from an array/object using dot notation
534
- * Throws if value is not a float
535
- */
536
- static float(obj: any, path: string, defaultValue?: number): number;
537
- /**
538
- * Remove element(s) by index or dot-notated path from an array/object.
539
- *
540
- * For arrays: accepts numeric index or array of indices. Returns a new array.
541
- *
542
- * For objects: supports dot notation to remove nested keys.
543
- *
544
- * Example:
545
- * Arr.forget([1,2,3], 1) -> [1,3]
546
- * Arr.forget({a:{b:1}}, 'a.b') -> { a: {} }
547
- */
548
- static forget<A extends any[] | Record<string, any>>(input: A, keys: any): A;
549
- /**
550
- * Converts various input types into a plain array
551
- * Supports Arrays, Objects, Iterables, Map, WeakMap, and custom toArray/toJSON/jsonSerialize methods
552
- */
553
- static from<T$1>(value: T$1 | Iterable<T$1> | Arrayable | Jsonable | JsonSerializable | null | undefined): any[];
554
- /**
555
- * Checks if an object has all the specified keys
556
- */
557
- static hasAll<T$1 extends object>(obj: T$1, keys: (keyof T$1)[]): boolean;
558
- /**
559
- * For arrays: check if the array contains any of the provided values.
560
- *
561
- * values can be single value or array of values.
562
- *
563
- * Example:
564
- * Arr.hasAny([1,2,3], [4,2]) -> true
565
- */
566
- static hasAny<A>(array: A[], values: A[] | A): boolean;
567
- /**
568
- * Retrieve a value using dot notation
569
- * Throws if value is not an integer
570
- */
571
- static integer(obj: any, path: string, defaultValue?: number): number;
572
- /**
573
- * Determine if the input is a "list-like" array: an Array with
574
- * contiguous numeric indices starting at 0 (no gaps).
575
- *
576
- * Example:
577
- * Arr.isList([1,2,3]) -> true
578
- * const a = []; a[2] = 5; Arr.isList(a) -> false
579
- */
580
- static isList<A>(value: A[]): boolean;
581
- /**
582
- * Join array elements into a string using the given separator.
583
- *
584
- * Example:
585
- * Arr.join([1,2,3], '-') -> '1-2-3'
586
- */
587
- static join(array: any[], separator?: string): string;
588
- /**
589
- * Create an object indexed by a key or callback function.
590
- *
591
- * Example:
592
- * Arr.keyBy([{id:1},{id:2}], 'id') -> { '1': {id:1}, '2': {id:2} }
593
- */
594
- static keyBy<T$1>(array: T$1[], key: keyof T$1 | ((item: T$1) => string | number)): Record<string, T$1>;
595
- /**
596
- * Get the last element of an array, optionally matching a predicate,
597
- * or the last element if no predicate is provided, otherwise the defaultValue.
598
- *
599
- * Predicate can be a true (boolean), a function or a value to match (strict equality).
600
- *
601
- * When predicate is true (boolean), the last element will be removed and a tuple will be returned [el, rest].
602
- *
603
- * @param array
604
- * @param predicate
605
- * @param defaultValue
606
- *
607
- * @returns
608
- */
609
- static last<T$1, P extends ((item: T$1) => boolean) | true>(array: T$1[], predicate?: P | T$1, defaultValue?: T$1): P extends true ? [T$1, T$1[]] : T$1 | undefined;
610
- /**
611
- * Transform each element in an array using a callback.
612
- */
613
- static map<T$1, U$1>(array: T$1[], callback: (item: T$1, index: number) => U$1): U$1[];
614
- /**
615
- * Maps a multi-dimensional array with a spread callback
616
- */
617
- static mapSpread<T$1 extends any[], U$1>(array: T$1[], callback: (...items: T$1) => U$1): U$1[];
618
- /**
619
- * Map each element to a key-value pair.
620
- *
621
- * Example:
622
- * Arr.mapWithKeys([{id:1, name:'A'}], x => [x.id, x.name])
623
- * -> { '1': 'A' }
624
- */
625
- static mapWithKeys<T$1, K$1 extends string | number, V>(array: T$1[], callback: (item: T$1, index: number) => [K$1, V]): Record<string, V>;
626
- /**
627
- * Return only elements at the given indices.
628
- *
629
- * Example:
630
- * Arr.only([10,20,30], [0,2]) -> [10,30]
631
- */
632
- static only<T$1>(array: T$1[], keys: number | number[]): T$1[];
633
- /**
634
- * Split an array into two arrays based on a predicate
635
- */
636
- static partition<T$1>(array: T$1[], predicate: (item: T$1) => boolean): [T$1[], T$1[]];
637
- /**
638
- * Extract a property from each element in an array of objects.
639
- *
640
- * Example:
641
- * Arr.pluck([{name:'A'},{name:'B'}], 'name') -> ['A','B']
642
- */
643
- static pluck<T$1, K$1 extends keyof T$1>(array: T$1[], key: K$1): T$1[K$1][];
644
- /**
645
- * Add elements to the beginning of an array and return a new array.
646
- *
647
- * @param array
648
- * @param value
649
- * @returns
650
- */
651
- static prepend<T$1>(array: T$1[], ...value: T$1[]): T$1[];
652
- /**
653
- * Remove a value from an array by index and return it.
654
- * Returns a tuple: [newArray, removedValue]
655
- */
656
- static pull<T$1>(array: T$1[], key: number): [T$1[], T$1 | undefined];
657
- /**
658
- * Append values to an array (mutable)
659
- */
660
- static push<T$1>(array: T$1[], ...values: T$1[]): T$1[];
661
- /**
662
- * Pick one or more random elements from an array.
663
- */
664
- static random<T$1>(array: T$1[], count?: number): T$1 | T$1[] | undefined;
665
- /**
666
- * Returns array elements that do NOT satisfy the predicate
667
- */
668
- static reject<T$1>(array: T$1[], predicate: (item: T$1) => boolean): T$1[];
669
- /**
670
- * Pick keys from an array of objects or an object
671
- */
672
- static select<T$1 extends object, K$1 extends keyof T$1>(obj: T$1, keys: K$1[]): Pick<T$1, K$1>;
673
- /**
674
- * Returns the only element that passes a callback, throws if none or multiple
675
- */
676
- static sole<T$1>(array: T$1[], predicate: (item: T$1) => boolean): T$1;
677
- /**
678
- * Checks if at least one element satisfies the predicate
679
- */
680
- static some<T$1>(array: T$1[], predicate: (item: T$1) => boolean): boolean;
681
- /**
682
- * Randomly shuffle an array and return a new array.
683
- */
684
- static shuffle<T$1>(array: T$1[]): T$1[];
685
- /**
686
- * Sort an array ascending using optional comparator.
687
- */
688
- static sort<T$1>(array: T$1[], comparator?: (a: T$1, b: T$1) => number): T$1[];
689
- /**
690
- * Sort an array descending using optional comparator.
691
- */
692
- static sortDesc<T$1>(array: T$1[], comparator?: (a: T$1, b: T$1) => number): T$1[];
693
- /**
694
- * Recursively sort arrays inside an array.
695
- */
696
- static sortRecursive<T$1>(array: T$1[]): T$1[];
697
- /**
698
- * Recursively sort arrays inside an array descending.
699
- */
700
- static sortRecursiveDesc<T$1>(array: T$1[]): T$1[];
701
- /**
702
- * Retrieve a value using dot notation
703
- * Throws if value is not a string
704
- */
705
- static string(obj: any, path: string, defaultValue?: string): string;
706
- /**
707
- * Return the first N elements of an array.
708
- *
709
- * @param array
710
- * @param count
711
- * @returns
712
- */
713
- static take<T$1>(array: T$1[], count: number): T$1[];
714
- /**
715
- * Filter an array based on a predicate function or key-value match.
716
- */
717
- static where<T$1>(array: T$1[], predicate: ((item: T$1) => boolean) | Partial<T$1>): T$1[];
718
- /**
719
- * Filter an array of objects, keeping elements where the given key is not null/undefined.
720
- */
721
- static whereNotNull<T$1>(array: T$1[], key: keyof T$1): T$1[];
722
- /**
723
- * If the given value is not an array and not null, wrap it in one.
724
- *
725
- * Non-array values become [value]; null/undefined becomes [].
726
- *
727
- * @param value
728
- * @returns
729
- */
730
- static wrap<T$1>(value: T$1 | T$1[] | null | undefined): T$1[];
731
- /**
732
- * Return the first element of an array, undefined if empty.
733
- */
734
- static head<T$1>(array: T$1[]): T$1 | undefined;
735
- /**
736
- * Splits an array into chunks of a specified size.
737
- *
738
- * @template T - Type of elements in the array
739
- * @param arr - The input array
740
- * @param size - Size of each chunk (default: 2)
741
- * @returns An array of chunks (arrays)
742
- */
743
- static chunk: <T$1>(arr: T$1[], size?: number) => T$1[][];
744
- /**
745
- * Alternates between two arrays, creating a zipped result.
746
- *
747
- * @param a
748
- * @param b
749
- * @returns
750
- */
751
- static alternate<T$1>(a: T$1[], b: T$1[]): T$1[];
752
- /**
753
- * Combine arrays and sum their values element by element.
754
- *
755
- * @param arr
756
- * @returns
757
- */
758
- static combine(...arr: number[][]): number[];
759
- /**
760
- * Find the value associated with a given key.
761
- *
762
- * @param key
763
- * @param arr
764
- * @returns
765
- */
766
- static find<T$1>(key: T$1, arr: T$1[]): T$1 | null;
767
- /**
768
- * Check if array is empty.
769
- *
770
- * @param arr
771
- * @returns
772
- */
773
- static isEmpty<T$1>(arr: T$1[]): boolean;
774
- /**
775
- * Check if array is empty.
776
- *
777
- * @param arr
778
- * @returns
779
- */
780
- static isNotEmpty<T$1>(arr: T$1[]): boolean;
781
- /**
782
- * Pop the element off the end of array.
783
- *
784
- * @param arr
785
- * @returns
786
- */
787
- static pop<T$1>(arr: T$1[]): T$1[];
788
- /**
789
- * Create a new array in reverse order.
790
- *
791
- * @param arr
792
- * @returns
793
- */
794
- static reverse<T$1>(arr: T$1[]): T$1[];
795
- /**
796
- * Return the first element of an array that satisfies the predicate,
797
- * or the first element if no predicate is provided, otherwise the defaultValue.
798
- *
799
- * Predicate can be true (boolean), a function or a value to match (strict equality).
800
- *
801
- * When predicate is true (boolean), the first element will be removed and a tuple will be returned [el, rest].
802
- *
803
- * @param array
804
- * @param predicate
805
- * @param defaultValue
806
- *
807
- * @alias Arr.first()
808
- * @returns
809
- */
810
- static shift<A, P extends (((arg: A) => true) | true)>(array: A[], predicate?: P | undefined, defaultValue?: A | undefined): P extends true ? [A, A[]] : A | undefined;
811
- /**
812
- * Generates an array of sequential numbers.
813
- *
814
- * @param size - Number of elements in the range
815
- * @param startAt - Starting number (default: 0)
816
- * @returns An array of numbers from startAt to startAt + size - 1
817
- */
818
- static range(size: number, startAt?: number): number[];
819
- }
820
- //#endregion
821
- //#region src/Helpers/Time.d.ts
822
- declare function format(date: ConfigType, fmt: string): string;
823
- declare const TimeClass: {
824
- new (date?: dayjs.ConfigType): Dayjs;
825
- } & typeof Dayjs;
826
- declare class DateTime extends TimeClass {
827
- private instance;
828
- constructor(config?: ConfigType);
829
- /**
830
- * Start time of a specific unit.
831
- *
832
- * @returns
833
- */
834
- start(unit?: OpUnitType): dayjs.Dayjs;
835
- /**
836
- * Set the timezone for the instance
837
- *
838
- * @param timezone
839
- * @returns
840
- */
841
- setTimezone(timezone?: string | undefined, keepLocalTime?: boolean | undefined): DateTime;
842
- /**
843
- * End time of a specific unit.
844
- *
845
- * @returns
846
- */
847
- end(unit?: OpUnitType): dayjs.Dayjs;
848
- /**
849
- * Get the first day of the month of the given date
850
- *
851
- * @returns
852
- */
853
- firstDayOfMonth(): DateTime;
854
- carbonFormat(template?: string | undefined): string;
855
- /**
856
- * Get the last day of the month of the given date
857
- *
858
- * @returns
859
- */
860
- lastDayOfMonth(): DateTime;
861
- /**
862
- * Get a random time between the specified hour and minute.
863
- *
864
- * @param startHour
865
- * @param startMinute
866
- * @param endHour
867
- * @param endMinute
868
- * @returns
869
- */
870
- randomTime(startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): DateTime;
871
- /**
872
- * Create a date for a given timestamp.
873
- *
874
- * @param timestamp - Unix timestamp
875
- *
876
- * @return {Date} object
877
- */
878
- static fromTimestamp(timestamp: number): DateTime;
879
- /**
880
- * Get current time instance.
881
- *
882
- * @returns Current time
883
- */
884
- static now(): DateTime;
885
- /**
886
- * Parse the time
887
- *
888
- * @param date
889
- * @returns
890
- */
891
- static parse(date: dayjs.ConfigType): DateTime;
892
- /**
893
- * Get the formatted date according to the string of tokens passed in.
894
- *
895
- * To escape characters, wrap them in square brackets (e.g. [MM]).
896
- *
897
- * @param time - current time
898
- * @param template - time format
899
- */
900
- static format(time?: ConfigType, template?: string | undefined): string;
901
- /**
902
- * Get the difference in days from today.
903
- *
904
- * @param time
905
- * @param startHour
906
- * @param startMinute
907
- * @param endHour
908
- * @param endMinute
909
- * @returns
910
- */
911
- static randomTime(time?: ConfigType, startHour?: number, startMinute?: number, endHour?: number, endMinute?: number): DateTime;
912
- /**
913
- * Get the first day of the month of the given date
914
- *
915
- * @param time
916
- *
917
- * @returns
918
- */
919
- static firstDayOfMonth(time: ConfigType): DateTime;
920
- /**
921
- * Get the last day of the month of the given date
922
- *
923
- * @param time
924
- *
925
- * @returns
926
- */
927
- static lastDayOfMonth(time: ConfigType): DateTime;
928
- }
929
- //#endregion
930
- //#region src/Helpers/Str.d.ts
931
- declare enum Mode {
932
- MB_CASE_UPPER = 0,
933
- MB_CASE_LOWER = 1,
934
- MB_CASE_TITLE = 2,
935
- MB_CASE_FOLD = 3,
936
- MB_CASE_UPPER_SIMPLE = 4,
937
- MB_CASE_LOWER_SIMPLE = 5,
938
- MB_CASE_TITLE_SIMPLE = 6,
939
- MB_CASE_FOLD_SIMPLE = 7,
940
- }
941
- declare class Str {
942
- /**
943
- * The callback that should be used to generate UUIDs.
944
- *
945
- * @type { Function | null }
946
- */
947
- protected static uuidFactory: Function | null;
948
- /**
949
- * The callback that should be used to generate ULIDs.
950
- *
951
- * @type { Function | null }
952
- */
953
- protected static ulidFactory: Function | null;
954
- /**
955
- * The callback that should be used to generate random strings.
956
- *
957
- * @type { Function | null }
958
- */
959
- protected static randomStringFactory: Function | null;
960
- /**
961
- * Get a new Stringable object from the given string.
962
- *
963
- * @param { string } string
964
- */
965
- static of(string: string): Stringable;
966
- /**
967
- * Return the remainder of a string after the first occurrence of a given value.
968
- *
969
- * @param { string } subject
970
- * @param { string } search
971
- *
972
- * @return { string }
973
- */
974
- static after(subject: string, search: string): string;
975
- /**
976
- * Return the remainder of a string after the last occurrence of a given value.
977
- *
978
- * @param { string } subject
979
- * @param { string } search
980
- *
981
- * @return { string }
982
- */
983
- static afterLast(subject: string, search: string): string;
984
- /**
985
- * Transliterate a UTF-8 value to ASCII.
986
- *
987
- * @param { string } value
988
- *
989
- * @return { string }
990
- */
991
- static ascii(value: string): string;
992
- /**
993
- * Get the portion of a string before the first occurrence of a given value.
994
- *
995
- * @param { string } subject
996
- * @param { string } search
997
- *
998
- * @return { string }
999
- */
1000
- static before(subject: string, search: string): string;
1001
- /**
1002
- * Get the portion of a string before the last occurrence of a given value.
1003
- *
1004
- * @param { string } subject
1005
- * @param { string } search
1006
- *
1007
- * @return { string }
1008
- */
1009
- static beforeLast(subject: string, search: string): string;
1010
- /**
1011
- * Get the portion of a string between two given values.
1012
- *
1013
- * @param { string } subject
1014
- * @param { string } from
1015
- * @param { string } to
1016
- *
1017
- * @return { string }
1018
- */
1019
- static between(subject: string, from: string, to: string): string;
1020
- /**
1021
- * Get the smallest possible portion of a string between two given values.
1022
- *
1023
- * @param { string } subject
1024
- * @param { string } from
1025
- * @param { string } to
1026
- *
1027
- * @return { string }
1028
- */
1029
- static betweenFirst(subject: string, from: string, to: string): string;
1030
- /**
1031
- * Convert a value to camel case.
1032
- *
1033
- * @param { string } value
1034
- *
1035
- * @return { string }
1036
- */
1037
- static camel(value: string): string;
1038
- /**
1039
- * Get the character at the specified index.
1040
- *
1041
- * @param { string } subject
1042
- * @param { number } index
1043
- *
1044
- * @return { string | false }
1045
- */
1046
- static charAt(subject: string, index: number): string | false;
1047
- /**
1048
- * Remove the given string(s) if it exists at the start of the haystack.
1049
- *
1050
- * @param { string } subject
1051
- * @param { string | string[] } needle
1052
- *
1053
- * @return string
1054
- */
1055
- static chopStart(subject: string, needle: string | string[]): string;
1056
- /**
1057
- * Remove the given string(s) if it exists at the end of the haystack.
1058
- *
1059
- * @param { string } subject
1060
- * @param { string | string[] } needle
1061
- *
1062
- * @return string
1063
- *
1064
- */
1065
- static chopEnd(subject: string, needle: string | string[]): string;
1066
- /**
1067
- * Determine if a given string contains a given substring.
1068
- *
1069
- * @param { string } haystack
1070
- * @param { string | string[] } needles
1071
- * @param { boolean } ignoreCase
1072
- *
1073
- * @return { boolean }
1074
- */
1075
- static contains(haystack: string, needles: string | string[], ignoreCase?: boolean): boolean;
1076
- /**
1077
- * Determine if a given string contains all array values.
1078
- *
1079
- * @param { string } haystack
1080
- * @param { string[] } needles
1081
- * @param { boolean } ignoreCase
1082
- *
1083
- * @return { boolean }
1084
- */
1085
- static containsAll(haystack: string, needles: string[], ignoreCase?: boolean): boolean;
1086
- /**
1087
- * Determine if a given string doesn't contain a given substring.
1088
- *
1089
- * @param { string } haystack
1090
- * @param { string | string[] } needles
1091
- * @param { boolean } ignoreCase
1092
- *
1093
- * @return { boolean }
1094
- */
1095
- static doesntContain(haystack: string, needles: string | string[], ignoreCase?: boolean): boolean;
1096
- /**
1097
- * Convert the case of a string.
1098
- *
1099
- * @param { string } string
1100
- * @param { Mode | number } mode
1101
- *
1102
- * @return { string }
1103
- */
1104
- static convertCase(string: string, mode?: Mode | number): string;
1105
- /**
1106
- * Replace consecutive instances of a given character with a single character in the given string.
1107
- *
1108
- * @param { string } string
1109
- * @param { string | string[] } characters
1110
- *
1111
- * @return { string }
1112
- */
1113
- static deduplicate(string: string, characters?: string | string[]): string;
1114
- /**
1115
- * Determine if a given string ends with a given substring.
1116
- *
1117
- * @param { string } haystack
1118
- * @param { string | string[] } needles
1119
- *
1120
- * @return { boolean }
1121
- */
1122
- static endsWith(haystack: string, needles: string | string[]): boolean;
1123
- /**
1124
- * Determine if a given string doesn't end with a given substring.
1125
- *
1126
- * @param { string } haystack
1127
- * @param { string | string[] } needles
1128
- *
1129
- * @return { boolean }
1130
- */
1131
- static doesntEndWith(haystack: string, needles: string | string[]): boolean;
1132
- /**
1133
- * Returns all the characters except the last.
1134
- *
1135
- * @param string
1136
- * @returns
1137
- */
1138
- static chop(string: string): string;
1139
- /**
1140
- * Escape string for JSON encoding (returns string without quotes).
1141
- *
1142
- * @param string
1143
- * @returns
1144
- */
1145
- static esc(string: string): string;
1146
- /**
1147
- * Extracts an excerpt from text that matches the first instance of a phrase.
1148
- *
1149
- * @param { string } text
1150
- * @param { string } phrase
1151
- * @param { ExcerptOptions } options
1152
- *
1153
- * @return { string | null }
1154
- */
1155
- static excerpt(text: string, phrase?: string, options?: ExcerptOptions): string | null;
1156
- /**
1157
- * Explode the string into an array.
1158
- *
1159
- * @param { string } string
1160
- * @param { string } delimiter
1161
- * @param { number } limit
1162
- *
1163
- * @return { string[] }
1164
- */
1165
- static explode(string: string, delimiter: string, limit?: number): string[];
1166
- /**
1167
- * Cap a string with a single instance of a given value.
1168
- *
1169
- * @param { string } value
1170
- * @param { string } cap
1171
- *
1172
- * @return { string }
1173
- */
1174
- static finish(value: string, cap: string): string;
1175
- /**
1176
- * Wrap the string with the given strings.
1177
- *
1178
- * @param { string } value
1179
- * @param { string } before
1180
- * @param { string | null } after
1181
- *
1182
- * @return string
1183
- */
1184
- static wrap(value: string, before: string, after?: string | null): string;
1185
- /**
1186
- * Unwrap the string with the given strings.
1187
- *
1188
- * @param { string } value
1189
- * @param { string } before
1190
- * @param { string | null } after
1191
- *
1192
- * @return { string }
1193
- */
1194
- static unwrap(value: string, before: string, after?: string | null): string;
1195
- /**
1196
- * Determine if a given string matches a given pattern.
1197
- *
1198
- * @param { string | string[] } pattern
1199
- * @param { string } value
1200
- * @param { boolean } ignoreCase
1201
- *
1202
- * @return { boolean }
1203
- */
1204
- static is(pattern: string | string[], value: string, ignoreCase?: boolean): boolean;
1205
- /**
1206
- * Determine if a given string is 7-bit ASCII.
1207
- *
1208
- * @param { string } value
1209
- *
1210
- * @return { boolean }
1211
- */
1212
- static isAscii(value: string): boolean;
1213
- /**
1214
- * Determine if a given string is valid JSON.
1215
- *
1216
- * @param { string } value
1217
- *
1218
- * @return { boolean }
1219
- */
1220
- static isJson(value: string): boolean;
1221
- /**
1222
- * Determine if a given value is a valid URL.
1223
- *
1224
- * @param { string } value
1225
- * @param { string[] } protocols
1226
- *
1227
- * @return { boolean }
1228
- */
1229
- static isUrl(value: string, protocols?: string[]): boolean;
1230
- /**
1231
- * Determine if a given string is a valid UUID.
1232
- *
1233
- * @param { string } value
1234
- *
1235
- * @return { boolean }
1236
- */
1237
- static isUuid(value: string): boolean;
1238
- /**
1239
- * Determine if a given string is a valid ULID.
1240
- *
1241
- * @param { string } value
1242
- *
1243
- * @return { boolean }
1244
- */
1245
- static isUlid(value: string): boolean;
1246
- /**
1247
- * Convert a string to kebab case.
1248
- *
1249
- * @param { string } value
1250
- *
1251
- * @return { string }
1252
- */
1253
- static kebab(value: string): string;
1254
- /**
1255
- * Return the length of the given string.
1256
- *
1257
- * @param { string } value
1258
- *
1259
- * @return { number }
1260
- */
1261
- static length(value: string): number;
1262
- /**
1263
- * Limit the number of characters in a string.
1264
- *
1265
- * @param { string } value
1266
- * @param { number } limit
1267
- * @param { string } end
1268
- * @param { boolean } preserveWords
1269
- *
1270
- * @return { string }
1271
- */
1272
- static limit(value: string, limit?: number, end?: string, preserveWords?: boolean): string;
1273
- /**
1274
- * Limit the number of characters in a string.
1275
- *
1276
- * @param { string } value
1277
- * @param { number } limit
1278
- * @param { string } end
1279
- * @param { boolean } preserveWords
1280
- *
1281
- * @alias limit
1282
- * @return { string }
1283
- */
1284
- static truncate(value: string, limit?: number, end?: string, preserveWords?: boolean): string;
1285
- /**
1286
- * Convert the given string to lower-case.
1287
- *
1288
- * @param { string } value
1289
- *
1290
- * @return { string }
1291
- */
1292
- static lower(value: string): string;
1293
- /**
1294
- * Get substring by start/stop indexes.
1295
- *
1296
- * @param string
1297
- * @param start
1298
- * @param stop
1299
- * @returns
1300
- */
1301
- static sub(string: string, start: number, stop: number): string;
1302
- /**
1303
- * Limit the number of words in a string.
1304
- *
1305
- * @param { string } value
1306
- * @param { number } words
1307
- * @param { string } end
1308
- *
1309
- * @return { string }
1310
- */
1311
- static words(value: string, words?: number, end?: string): string;
1312
- /**
1313
- * Masks a portion of a string with a repeated character.
1314
- *
1315
- * @param { string } string
1316
- * @param { string } character
1317
- * @param { number } index
1318
- * @param { number | null } length
1319
- *
1320
- * @return { string }
1321
- */
1322
- static mask(string: string, character: string, index: number, length?: number | null): string;
1323
- /**
1324
- * Get the string matching the given pattern.
1325
- *
1326
- * @param { string } pattern
1327
- * @param { string } subject
1328
- *
1329
- * @return { string }
1330
- */
1331
- static match(pattern: string, subject: string): string;
1332
- /**
1333
- * Determine if a given string matches a given pattern.
1334
- *
1335
- * @param { string | string[] } pattern
1336
- * @param { string } value
1337
- *
1338
- * @return { boolean }
1339
- */
1340
- static isMatch(pattern: string | string[], value: string): boolean;
1341
- /**
1342
- * Get the string matching the given pattern.
1343
- *
1344
- * @param { string } pattern
1345
- * @param { string } subject
1346
- *
1347
- * @return { string[] }
1348
- */
1349
- static matchAll(pattern: string, subject: string): string[];
1350
- /**
1351
- * Remove all non-numeric characters from a string.
1352
- *
1353
- * @param { string } value
1354
- *
1355
- * @return { string }
1356
- */
1357
- static numbers(value: string): string;
1358
- /**
1359
- * Pad both sides of a string with another.
1360
- *
1361
- * @param { string } value
1362
- * @param { number } length
1363
- * @param { string } pad
1364
- *
1365
- * @return { string }
1366
- */
1367
- static padBoth(value: string, length: number, pad?: string): string;
1368
- /**
1369
- * Pad the left side of a string with another.
1370
- *
1371
- * @param { string } value
1372
- * @param { number } length
1373
- * @param { string } pad
1374
- *
1375
- * @return { string }
1376
- */
1377
- static padLeft(value: string, length: number, pad?: string): string;
1378
- /**
1379
- * Pad the right side of a string with another.
1380
- *
1381
- * @param { string } value
1382
- * @param { number } length
1383
- * @param { string } pad
1384
- *
1385
- * @return { string }
1386
- */
1387
- static padRight(value: string, length: number, pad?: string): string;
1388
- /**
1389
- * Get the plural form of an English word.
1390
- *
1391
- * @param { string } value
1392
- * @param { number | array } count
1393
- *
1394
- * @return { string }
1395
- */
1396
- static plural(value: string, count?: number | number[]): string;
1397
- /**
1398
- * Get the plural form of an English word.
1399
- *
1400
- * @param { string } value
1401
- * @param { number | array } count
1402
- *
1403
- * @alias plural
1404
- *
1405
- * @return { string }
1406
- */
1407
- static pluralize: (value: string, count?: number | number[]) => string;
1408
- /**
1409
- * Pluralize the last word of an English, studly caps case string.
1410
- *
1411
- * @param { string } value
1412
- * @param { number | array } count
1413
- *
1414
- * @return { string }
1415
- */
1416
- static pluralStudly(value: string, count?: number | number[]): string;
1417
- /**
1418
- * Pluralize the last word of an English, Pascal case string.
1419
- *
1420
- * @param { string } value
1421
- * @param { number | array } count
1422
- *
1423
- * @return { string }
1424
- */
1425
- static pluralPascal(value: string, count?: number | number[]): string;
1426
- /**
1427
- * Generate a random, secure password.
1428
- *
1429
- * @param { number } length
1430
- * @param { boolean } letters
1431
- * @param { boolean } numbers
1432
- * @param { boolean } symbols
1433
- * @param { boolean } spaces
1434
- *
1435
- * @return { string }
1436
- */
1437
- static password(length?: number, letters?: boolean, numbers?: boolean, symbols?: boolean, spaces?: boolean): string;
1438
- /**
1439
- * Find the position of the first occurrence of a given substring in a string.
1440
- *
1441
- * @param { string } haystack
1442
- * @param { string } needle
1443
- * @param { number } offset
1444
- *
1445
- * @return { number | false }
1446
- */
1447
- static position(haystack: string, needle: string, offset?: number): number | false;
1448
- /**
1449
- * Generate a more truly "random" alpha-numeric string.
1450
- *
1451
- * @param { number } length
1452
- *
1453
- * @return { string }
1454
- */
1455
- static random(length?: number): string;
1456
- /**
1457
- * Set the callable that will be used to generate random strings.
1458
- *
1459
- * @param { ((length: number) => string) | null } factory
1460
- *
1461
- * @return { void }
1462
- */
1463
- static createRandomStringsUsing(factory?: ((length: number) => string) | null): void;
1464
- /**
1465
- * Set the sequence that will be used to generate random strings.
1466
- *
1467
- * @param { (string | undefined)[] } sequence
1468
- * @param { Function | null } whenMissing
1469
- *
1470
- * @return { void }
1471
- */
1472
- static createRandomStringsUsingSequence(sequence: (string | undefined)[], whenMissing?: Function | null): void;
1473
- /**
1474
- * Indicate that random strings should be created normally and not using a custom factory.
1475
- *
1476
- * @return { void }
1477
- */
1478
- static createRandomStringsNormally(): void;
1479
- /**
1480
- * Repeat the given string.
1481
- *
1482
- * @param { string } string
1483
- * @param { number } times
1484
- *
1485
- * @return { string }
1486
- */
1487
- static repeat(string: string, times?: number): string;
1488
- /**
1489
- * Replace a given value in the string sequentially with an array.
1490
- *
1491
- * @param { string[] } replace
1492
- * @param { string } subject
1493
- * @param { string } search
1494
- *
1495
- * @return { string }
1496
- */
1497
- static replaceArray(search: string, replace: string[], subject: string): string;
1498
- /**
1499
- * Convert the given value to a string or return the given fallback on failure.
1500
- *
1501
- * @param { * } value
1502
- * @param { string } fallback
1503
- *
1504
- * @return { string }
1505
- */
1506
- static toStringOr(value: any, fallback: string): string;
1507
- /**
1508
- * Replace the given value in the given string.
1509
- *
1510
- * @param { string | string[] } search
1511
- * @param { string } replace
1512
- * @param { string } subject
1513
- * @param { boolean } caseSensitive
1514
- *
1515
- * @return { string }
1516
- */
1517
- static replace(search: string | string[], replace: string, subject: string, caseSensitive?: boolean): string;
1518
- /**
1519
- * Replace the first occurrence of a given value in the string.
1520
- *
1521
- * @param { string } search
1522
- * @param { string } replace
1523
- * @param { string } subject
1524
- *
1525
- * @return { string }
1526
- */
1527
- static replaceFirst(search: string, replace: string, subject: string): string;
1528
- /**
1529
- * Replace the first occurrence of the given value if it appears at the start of the string.
1530
- *
1531
- * @param { string } search
1532
- * @param { string } replace
1533
- * @param { string } subject
1534
- *
1535
- * @return { string }
1536
- */
1537
- static replaceStart(search: string, replace: string, subject: string): string;
1538
- /**
1539
- * Replace the last occurrence of a given value in the string.
1540
- *
1541
- * @param { string } search
1542
- * @param { string } replace
1543
- * @param { string } subject
1544
- *
1545
- * @return { string }
1546
- */
1547
- static replaceLast(search: string, replace: string, subject: string): string;
1548
- /**
1549
- * Replace the last occurrence of a given value if it appears at the end of the string.
1550
- *
1551
- * @param { string } search
1552
- * @param { string } replace
1553
- * @param { string } subject
1554
- *
1555
- * @return { string }
1556
- */
1557
- static replaceEnd(search: string, replace: string, subject: string): string;
1558
- /**
1559
- * Replace the patterns matching the given regular expression.
1560
- *
1561
- * @param { string } pattern
1562
- * @param { string | function } replace
1563
- * @param { string } subject
1564
- *
1565
- * @return { string }
1566
- */
1567
- static replaceMatches(pattern: string, replace: string | Function, subject: string): string;
1568
- /**
1569
- * Remove any occurrence of the given string in the subject.
1570
- *
1571
- * @param { string } search
1572
- * @param { string } subject
1573
- * @param { boolean } caseSensitive
1574
- *
1575
- * @return { string }
1576
- */
1577
- static remove(search: string, subject: string, caseSensitive?: boolean): string;
1578
- /**
1579
- * Reverse the given string.
1580
- *
1581
- * @param { string } value
1582
- *
1583
- * @return { string }
1584
- */
1585
- static reverse(value: string): string;
1586
- /**
1587
- * Begin a string with a single instance of a given value.
1588
- *
1589
- * @param { string } value
1590
- * @param { string } prefix
1591
- *
1592
- * @return { string }
1593
- */
1594
- static start(value: string, prefix: string): string;
1595
- /**
1596
- * Substitute placeholders { key } using object with dot notation.
1597
- *
1598
- * @param str
1599
- * @param data
1600
- * @param def
1601
- * @returns
1602
- */
1603
- static substitute(str: string, data?: Record<string, unknown>, def?: string): string | undefined;
1604
- /**
1605
- * Convert the given string to upper-case.
1606
- *
1607
- * @param { string } value
1608
- *
1609
- * @return { string }
1610
- */
1611
- static upper(value: string): string;
1612
- /**
1613
- * Convert the given string to title case.
1614
- *
1615
- * @param { string } value
1616
- *
1617
- * @return { string }
1618
- */
1619
- static title(value: string): string;
1620
- /**
1621
- * Convert the given string to title case for each word.
1622
- *
1623
- * @param { string } value
1624
- *
1625
- * @return { string }
1626
- */
1627
- static headline(value: string): string;
1628
- /**
1629
- * Convert the given string to APA-style title case.
1630
- *
1631
- * @see https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
1632
- *
1633
- * @param { string } value
1634
- *
1635
- * @return { string }
1636
- */
1637
- static apa(value: string): string;
1638
- /**
1639
- * Get the singular form of an English word.
1640
- *
1641
- * @param { string } value
1642
- *
1643
- * @return { string }
1644
- */
1645
- static singular(value: string): string;
1646
- /**
1647
- * Get the singular form of an English word.
1648
- *
1649
- * @param { string } value
1650
- *
1651
- * @alias singular
1652
- *
1653
- * @return { string }
1654
- */
1655
- static singularize(value: string): string;
1656
- /**
1657
- * Generate a URL friendly "slug" from a given string.
1658
- *
1659
- * @param { string } title
1660
- * @param { string } separator
1661
- * @param { object } dictionary
1662
- *
1663
- * @return { string }
1664
- */
1665
- static slug(title: string, separator?: string, dictionary?: {
1666
- [key: string]: string;
1667
- }): string;
1668
- /**
1669
- * Generate a URL friendly "slug" from a given string.
1670
- *
1671
- * @param { string } separator
1672
- * @param { string } title
1673
- * @param { object } dictionary
1674
- *
1675
- * @alias singular
1676
- *
1677
- * @return { string }
1678
- */
1679
- static slugify(title: string, separator?: string, dictionary?: {
1680
- [key: string]: string;
1681
- }): string;
1682
- /**
1683
- * Convert a string to snake case.
1684
- *
1685
- * @param { string } value
1686
- * @param { string } delimiter
1687
- *
1688
- * @return { string }
1689
- */
1690
- static snake(value: string, delimiter?: string): string;
1691
- /**
1692
- * Uppercase the first character of each word in a string
1693
- *
1694
- * @param { string } string The input string.
1695
- * @param { string } separators The optional separators contains the word separator characters.
1696
-
1697
- * @return { string } String the modified string.
1698
- */
1699
- static capitalize(string: string, separators?: string): string;
1700
- /**
1701
- * Uppercase the first character of each word in a string
1702
- *
1703
- * @param { string } string The input string.
1704
- * @param { string } separators The optional separators contains the word separator characters.
1705
-
1706
- * @return { string } String the modified string.
1707
- */
1708
- static ucwords(string: string, separators?: string): string;
1709
- /**
1710
- * Remove all whitespace from both ends of a string.
1711
- *
1712
- * @param { string } value
1713
- * @param { string | null } characters
1714
- *
1715
- * @return { string }
1716
- */
1717
- static trim(value: string, characters?: string | null): string;
1718
- /**
1719
- * Remove all whitespace from the beginning of a string.
1720
- *
1721
- * @param { string } value
1722
- * @param { string | null } characters
1723
- *
1724
- * @return { string }
1725
- */
1726
- static ltrim(value: string, characters?: string | null): string;
1727
- /**
1728
- * Remove all whitespace from the end of a string.
1729
- *
1730
- * @param { string } value
1731
- * @param { string | null } characters
1732
- *
1733
- * @return { string }
1734
- */
1735
- static rtrim(value: string, characters?: string | null): string;
1736
- /**
1737
- * Remove all "extra" blank space from the given string.
1738
- *
1739
- * @param { string } value
1740
- *
1741
- * @return { string }
1742
- */
1743
- static squish(value: string): string;
1744
- /**
1745
- * Determine if a given string starts with a given substring.
1746
- *
1747
- * @param { string } haystack
1748
- * @param { string | string[] } needles
1749
- *
1750
- * @return { boolean }
1751
- */
1752
- static startsWith(haystack: string, needles: string | string[]): boolean;
1753
- /**
1754
- * Determine if a given string doesn't start with a given substring.
1755
- *
1756
- * @param { string } haystack
1757
- * @param { string | string[] } needles
1758
- *
1759
- * @return { boolean }
1760
- */
1761
- static doesntStartWith(haystack: string, needles: string | string[]): boolean;
1762
- /**
1763
- * Convert a value to studly caps case.
1764
- *
1765
- * @param { string } value
1766
- *
1767
- * @return { string }
1768
- */
1769
- static studly(value: string): string;
1770
- /**
1771
- * Convert a value to Pascal case.
1772
- *
1773
- * @param { string } value
1774
- *
1775
- * @return { string }
1776
- */
1777
- static pascal(value: string): string;
1778
- /**
1779
- * Returns the portion of the string specified by the start and length parameters.
1780
- *
1781
- * @param { string } string
1782
- * @param { number } start
1783
- * @param { number | null } length
1784
- *
1785
- * @return { string }
1786
- */
1787
- static substr(string: string, start: number, length?: number | null): string;
1788
- /**
1789
- * Returns the number of substring occurrences.
1790
- *
1791
- * @param { string } haystack
1792
- * @param { string } needle
1793
- * @param { number } offset
1794
- * @param { number | null } length
1795
- *
1796
- * @return { number }
1797
- */
1798
- static substrCount(haystack: string, needle: string, offset?: number, length?: number | null): number;
1799
- /**
1800
- * Replace text within a portion of a string.
1801
- *
1802
- * @param { string } string
1803
- * @param { string } replace
1804
- * @param { number } offset
1805
- * @param { number | null } length
1806
- *
1807
- * @return { string }
1808
- */
1809
- static substrReplace(string: string, replace: string, offset?: number, length?: number | null): string;
1810
- /**
1811
- * Swap multiple keywords in a string with other keywords.
1812
- *
1813
- * @param { object } map
1814
- * @param { string } subject
1815
- *
1816
- * @return { string }
1817
- */
1818
- static swap(map: Record<string, string>, subject: string): string;
1819
- /**
1820
- * Take the first or last {limit} characters of a string.
1821
- *
1822
- * @param { string } string
1823
- * @param { number } limit
1824
- *
1825
- * @return { string }
1826
- */
1827
- static take(string: string, limit: number): string;
1828
- /**
1829
- * Convert the given string to Base64 encoding.
1830
- *
1831
- * @param { string } string
1832
- *
1833
- * @return { string }
1834
- */
1835
- static toBase64(string: string): string;
1836
- /**
1837
- * Decode the given Base64 encoded string.
1838
- *
1839
- * @param { string } string
1840
- *
1841
- * @return { string }
1842
- */
1843
- static fromBase64(string: string): string;
1844
- /**
1845
- * Checks if a string is numeric
1846
- *
1847
- * @param string
1848
- * @returns
1849
- */
1850
- static isNumber(string: string): boolean;
1851
- /**
1852
- * Checks if a string is an integer
1853
- *
1854
- * @param string
1855
- * @returns
1856
- */
1857
- static isInteger(string: string): boolean;
1858
- /**
1859
- * ROT-N cipher.
1860
- *
1861
- * @param string
1862
- * @param n
1863
- * @returns
1864
- */
1865
- static rot(string: string, n?: number): string;
1866
- /**
1867
- * Replace trailing punctuation with new format.
1868
- *
1869
- * @param string
1870
- * @param newFormat
1871
- * @returns
1872
- */
1873
- static replacePunctuation(string: string, newFormat: string): string;
1874
- /**
1875
- * Array/object driven text replacement.
1876
- *
1877
- * @param string
1878
- * @param replacements
1879
- * @returns
1880
- */
1881
- static translate(string: string, replacements: Record<string, string> | Array<[string, string]>): string;
1882
- /**
1883
- * Strip slashes recursively.
1884
- *
1885
- * @param string
1886
- * @returns
1887
- */
1888
- static ss(string: string): string;
1889
- /**
1890
- * First and last N lines.
1891
- *
1892
- * @param string
1893
- * @param amount
1894
- * @returns
1895
- */
1896
- static firstLines(string: string, amount?: number): string;
1897
- /**
1898
- * Last and first N lines.
1899
- *
1900
- * @param string
1901
- * @param amount
1902
- * @returns
1903
- */
1904
- static lastLines(string: string, amount?: number): string;
1905
- /**
1906
- * Make a string's first character lowercase.
1907
- *
1908
- * @param { string } string
1909
- *
1910
- * @return { string }
1911
- */
1912
- static lcfirst(string: string): string;
1913
- /**
1914
- * Make a string's first character uppercase.
1915
- *
1916
- * @param { string } string
1917
- *
1918
- * @return { string }
1919
- */
1920
- static ucfirst(string: string): string;
1921
- /**
1922
- * Split a string into pieces by uppercase characters.
1923
- *
1924
- * @param { string } string
1925
- *
1926
- * @return { string[] }
1927
- */
1928
- static ucsplit(string: string): string[];
1929
- /**
1930
- * Get the number of words a string contains.
1931
- *
1932
- * @param { string } string
1933
- *
1934
- * @return { number }
1935
- */
1936
- static wordCount(string: string): number;
1937
- /**
1938
- * Wrap a string to a given number of characters.
1939
- *
1940
- * @param { string } string
1941
- * @param { number } characters
1942
- * @param { string } breakStr
1943
- * @param { boolean } cutLongWords
1944
- *
1945
- * @returns { string }
1946
- */
1947
- static wordWrap(string: string, characters?: number, breakStr?: string, cutLongWords?: boolean): string;
1948
- /**
1949
- * Generate a UUID (version 4).
1950
- *
1951
- * @return { string }
1952
- */
1953
- static uuid(): string;
1954
- /**
1955
- * Generate a UUID (version 7).
1956
- *
1957
- * @return { string }
1958
- */
1959
- static uuid7(time?: Date | null): string;
1960
- /**
1961
- * Generate a time-ordered UUID (version 4).
1962
- *
1963
- * @return { string }
1964
- */
1965
- static orderedUuid(): string;
1966
- /**
1967
- * Set the callable that will be used to generate UUIDs.
1968
- *
1969
- * @param { Function | null } factory
1970
- *
1971
- * @return { void }
1972
- */
1973
- static createUuidsUsing(factory?: Function | null): void;
1974
- /**
1975
- * Set the sequence that will be used to generate random strings.
1976
- *
1977
- * @param { (string | undefined)[] } sequence
1978
- * @param { Function | null } whenMissing
1979
- *
1980
- * @return { void }
1981
- */
1982
- static createUuidsUsingSequence(sequence: (string | undefined)[], whenMissing?: Function | null): void;
1983
- /**
1984
- * Always return the same UUID when generating new UUIDs.
1985
- *
1986
- * @param { Function | null } callback
1987
- *
1988
- * @return { string }
1989
- */
1990
- static freezeUuids(callback?: Function | null): string;
1991
- /**
1992
- * Indicate that UUIDs should be created normally and not using a custom factory.
1993
- *
1994
- * @return { void }
1995
- */
1996
- static createUuidsNormally(): void;
1997
- /**
1998
- * Generate a ULID.
1999
- *
2000
- * @return { string }
2001
- */
2002
- static ulid(): string;
2003
- /**
2004
- * Set the callable that will be used to generate ULIDs.
2005
- *
2006
- * @param { Function | null } factory
2007
- *
2008
- * @return { void }
2009
- */
2010
- static createUlidsUsing(factory?: Function | null): void;
2011
- /**
2012
- * Set the sequence that will be used to generate ULIDs.
2013
- *
2014
- * @param { (string | undefined)[] } sequence
2015
- * @param { Function | null } whenMissing
2016
- *
2017
- * @return { void }
2018
- */
2019
- static createUlidsUsingSequence(sequence: (string | undefined)[], whenMissing?: Function | null): void;
2020
- /**
2021
- * Always return the same UUID when generating new UUIDs.
2022
- *
2023
- * @param { Function | null } callback
2024
- *
2025
- * @return { string }
2026
- */
2027
- static freezeUlids(callback?: Function | null): string;
2028
- /**
2029
- * Indicate that ULIDs should be created normally and not using a custom factory.
2030
- *
2031
- * @return { void }
2032
- */
2033
- static createUlidsNormally(): void;
2034
- }
2035
- declare class Stringable {
2036
- #private;
2037
- /**
2038
- * Create a new instance of the class.
2039
- *
2040
- * @param { string } value
2041
- */
2042
- constructor(value?: string);
2043
- /**
2044
- * Return the remainder of a string after the first occurrence of a given value.
2045
- *
2046
- * @param { string } search
2047
- *
2048
- * @return { Stringable }
2049
- */
2050
- after(search: string): Stringable;
2051
- /**
2052
- * Return the remainder of a string after the last occurrence of a given value.
2053
- *
2054
- * @param { string } search
2055
- *
2056
- * @return { Stringable }
2057
- */
2058
- afterLast(search: string): Stringable;
2059
- /**
2060
- * Append the given values to the string.
2061
- *
2062
- * @param { string | string[] } values
2063
- *
2064
- * @return { Stringable }
2065
- */
2066
- append(...values: string[]): Stringable;
2067
- /**
2068
- * Append a new line to the string.
2069
- *
2070
- * @param { number } count
2071
- *
2072
- * @return { Stringable }
2073
- */
2074
- newLine(count?: number): Stringable;
2075
- /**
2076
- * Transliterate a UTF-8 value to ASCII.
2077
- *
2078
- * @return { Stringable }
2079
- */
2080
- ascii(): Stringable;
2081
- /**
2082
- * Get the trailing name component of the path.
2083
- *
2084
- * @param { string } suffix
2085
- *
2086
- * @return { Stringable }
2087
- */
2088
- basename(suffix?: string): Stringable;
2089
- /**
2090
- * Get the character at the specified index.
2091
- *
2092
- * @param { number } index
2093
- *
2094
- * @return { string | false }
2095
- */
2096
- charAt(index: number): string | false;
2097
- /**
2098
- * Remove the given string if it exists at the start of the current string.
2099
- *
2100
- * @param { string | string[] } needle
2101
- *
2102
- * @return { Stringable }
2103
- */
2104
- chopStart(needle: string | string[]): Stringable;
2105
- /**
2106
- * Remove the given string if it exists at the end of the current string.
2107
- *
2108
- * @param { string | string[] } needle
2109
- *
2110
- * @return { Stringable }
2111
- */
2112
- chopEnd(needle: string | string[]): Stringable;
2113
- /**
2114
- * Get the basename of the class path.
2115
- *
2116
- * @return { Stringable }
2117
- */
2118
- classBasename(): Stringable;
2119
- /**
2120
- * Get the portion of a string before the first occurrence of a given value.
2121
- *
2122
- * @param { string } search
2123
- *
2124
- * @return { Stringable }
2125
- */
2126
- before(search: string): Stringable;
2127
- /**
2128
- * Get the portion of a string before the last occurrence of a given value.
2129
- *
2130
- * @param { string } search
2131
- *
2132
- * @return { Stringable }
2133
- */
2134
- beforeLast(search: string): Stringable;
2135
- /**
2136
- * Get the portion of a string between two given values.
2137
- *
2138
- * @param { string } from
2139
- * @param { string } to
2140
- *
2141
- * @return { Stringable }
2142
- */
2143
- between(from: string, to: string): Stringable;
2144
- /**
2145
- * Get the smallest possible portion of a string between two given values.
2146
- *
2147
- * @param { string } from
2148
- * @param { string } to
2149
- *
2150
- * @return { Stringable }
2151
- */
2152
- betweenFirst(from: string, to: string): Stringable;
2153
- /**
2154
- * Convert a value to camel case.
2155
- *
2156
- * @return { Stringable }
2157
- */
2158
- camel(): Stringable;
2159
- /**
2160
- * Determine if a given string contains a given substring.
2161
- *
2162
- * @param { string | string[] } needles
2163
- * @param { boolean } ignoreCase
2164
- *
2165
- * @return { boolean }
2166
- */
2167
- contains(needles: string | string[], ignoreCase?: boolean): boolean;
2168
- /**
2169
- * Determine if a given string contains all array values.
2170
- *
2171
- * @param { string[] } needles
2172
- * @param { boolean } ignoreCase
2173
- *
2174
- * @return { boolean }
2175
- */
2176
- containsAll(needles: string[], ignoreCase?: boolean): boolean;
2177
- /**
2178
- * Determine if a given string doesn't contain a given substring.
2179
- *
2180
- * @param { string | string[] } needles
2181
- * @param { boolean } ignoreCase
2182
- *
2183
- * @return { boolean }
2184
- */
2185
- doesntContain(needles: string | string[], ignoreCase?: boolean): boolean;
2186
- /**
2187
- * Convert the case of a string.
2188
- *
2189
- * @param { Mode | number } mode
2190
- *
2191
- * @return { Stringable }
2192
- */
2193
- convertCase(mode?: Mode | number): Stringable;
2194
- /**
2195
- * Replace consecutive instances of a given character with a single character in the given string.
2196
- *
2197
- * @param { string | string[] } characters
2198
- *
2199
- * @return { string }
2200
- */
2201
- deduplicate(characters?: string | string[]): Stringable;
2202
- /**
2203
- * Get the parent directory's path.
2204
- *
2205
- * @param { number } levels
2206
- *
2207
- * @return { Stringable }
2208
- */
2209
- dirname(levels?: number): Stringable;
2210
- /**
2211
- * Determine if a given string ends with a given substring.
2212
- *
2213
- * @param { string | string[] } needles
2214
- *
2215
- * @return { boolean }
2216
- */
2217
- endsWith(needles: string | string[]): boolean;
2218
- /**
2219
- * Determine if a given string doesn't end with a given substring.
2220
- *
2221
- * @param { string | string[] } needles
2222
- *
2223
- * @return { boolean }
2224
- */
2225
- doesntEndWith(needles: string | string[]): boolean;
2226
- /**
2227
- * Returns all the characters except the last.
2228
- *
2229
- * @returns
2230
- */
2231
- chop(): Stringable;
2232
- /**
2233
- * Escape string for JSON encoding (returns string without quotes).
2234
- *
2235
- * @param string
2236
- * @returns
2237
- */
2238
- esc(): Stringable;
2239
- /**
2240
- * Determine if the string is an exact match with the given value.
2241
- *
2242
- * @param { Stringable | string } value
2243
- *
2244
- * @return { boolean }
2245
- */
2246
- exactly(value: Stringable | string): boolean;
2247
- /**
2248
- * Extracts an excerpt from text that matches the first instance of a phrase.
2249
- *
2250
- * @param { string } phrase
2251
- * @param { ExcerptOptions } options
2252
- *
2253
- * @return { string | null }
2254
- */
2255
- excerpt(phrase?: string, options?: ExcerptOptions): string | null;
2256
- /**
2257
- * Explode the string into an array.
2258
- *
2259
- * @param { string } delimiter
2260
- * @param { number } limit
2261
- *
2262
- * @return { string[] }
2263
- */
2264
- explode(delimiter: string, limit?: number): string[];
2265
- /**
2266
- * Split a string using a regular expression or by length.
2267
- *
2268
- * @param { string } pattern
2269
- * @param { number } limit
2270
- *
2271
- * @return { string[] }
2272
- */
2273
- split(pattern: string, limit?: number): string[];
2274
- /**
2275
- * Cap a string with a single instance of a given value.
2276
- *
2277
- * @param { string } cap
2278
- *
2279
- * @return { Stringable }
2280
- */
2281
- finish(cap: string): Stringable;
2282
- /**
2283
- * Determine if a given string matches a given pattern.
2284
- *
2285
- * @param { string | string[] } pattern
2286
- * @param { boolean } ignoreCase
2287
- *
2288
- * @return { boolean }
2289
- */
2290
- is(pattern: string | string[], ignoreCase?: boolean): boolean;
2291
- /**
2292
- * Determine if a given string is 7-bit ASCII.
2293
- *
2294
- * @return { boolean }
2295
- */
2296
- isAscii(): boolean;
2297
- /**
2298
- * Determine if a given string is valid JSON.
2299
- *
2300
- * @return { boolean }
2301
- */
2302
- isJson(): boolean;
2303
- /**
2304
- * Determine if a given value is a valid URL.
2305
- *
2306
- * @return { boolean }
2307
- */
2308
- isUrl(): boolean;
2309
- /**
2310
- * Determine if a given string is a valid UUID.
2311
- *
2312
- * @return { boolean }
2313
- */
2314
- isUuid(): boolean;
2315
- /**
2316
- * Determine if a given string is a valid ULID.
2317
- *
2318
- * @return { boolean }
2319
- */
2320
- isUlid(): boolean;
2321
- /**
2322
- * Determine if the given string is empty.
2323
- *
2324
- * @return { boolean }
2325
- */
2326
- isEmpty(): boolean;
2327
- /**
2328
- * Determine if the given string is not empty.
2329
- *
2330
- * @return { boolean }
2331
- */
2332
- isNotEmpty(): boolean;
2333
- /**
2334
- * Convert a string to kebab case.
2335
- *
2336
- * @return { Stringable }
2337
- */
2338
- kebab(): Stringable;
2339
- /**
2340
- * Return the length of the given string.
2341
- *
2342
- * @return { number }
2343
- */
2344
- length(): number;
2345
- /**
2346
- * Limit the number of characters in a string.
2347
- *
2348
- * @param { number } limit
2349
- * @param { string } end
2350
- * @param { boolean } preserveWords
2351
- *
2352
- * @return { Stringable }
2353
- */
2354
- limit(limit?: number, end?: string, preserveWords?: boolean): Stringable;
2355
- /**
2356
- * Get substring by start/stop indexes.
2357
- *
2358
- * @param start
2359
- * @param stop
2360
- * @returns
2361
- */
2362
- sub(start: number, stop: number): Stringable;
2363
- /**
2364
- * Limit the number of characters in a string.
2365
- *
2366
- * @param { number } limit
2367
- * @param { string } end
2368
- * @param { boolean } preserveWords
2369
- *
2370
- * @alias limit
2371
- *
2372
- * @return { Stringable }
2373
- */
2374
- truncate(limit?: number, end?: string, preserveWords?: boolean): Stringable;
2375
- /**
2376
- * Convert the given string to lower-case.
2377
- *
2378
- * @return { Stringable }
2379
- */
2380
- lower(): Stringable;
2381
- /**
2382
- * Masks a portion of a string with a repeated character.
2383
- *
2384
- * @param { string } character
2385
- * @param { number } index
2386
- * @param { number | null }length
2387
- *
2388
- * @return { Stringable }
2389
- */
2390
- mask(character: string, index: number, length?: number | null): Stringable;
2391
- /**
2392
- * Get the string matching the given pattern.
2393
- *
2394
- * @param { string } pattern
2395
- *
2396
- * @return { Stringable }
2397
- */
2398
- match(pattern: string): Stringable;
2399
- /**
2400
- * Determine if a given string matches a given pattern.
2401
- *
2402
- * @param { string | string[] } pattern
2403
- *
2404
- * @return { boolean }
2405
- */
2406
- isMatch(...pattern: string[]): boolean;
2407
- /**
2408
- * Get the string matching the given pattern.
2409
- *
2410
- * @param { string } pattern
2411
- *
2412
- * @return { string[] }
2413
- */
2414
- matchAll(pattern: string): string[];
2415
- /**
2416
- * Determine if the string matches the given pattern.
2417
- *
2418
- * @param { string } pattern
2419
- *
2420
- * @return { boolean }
2421
- */
2422
- test(pattern: string): boolean;
2423
- /**
2424
- * Remove all non-numeric characters from a string.
2425
- *
2426
- * @return { Stringable }
2427
- */
2428
- numbers(): Stringable;
2429
- /**
2430
- * Pad both sides of the string with another.
2431
- *
2432
- * @param { number } length
2433
- * @param { string } pad
2434
- *
2435
- * @return { Stringable }
2436
- */
2437
- padBoth(length: number, pad?: string): Stringable;
2438
- /**
2439
- * Pad the left side of the string with another.
2440
- *
2441
- * @param { number } length
2442
- * @param { string } pad
2443
- *
2444
- * @return { Stringable }
2445
- */
2446
- padLeft(length: number, pad?: string): Stringable;
2447
- /**
2448
- * Pad the right side of the string with another.
2449
- *
2450
- * @param { number } length
2451
- * @param { string } pad
2452
- *
2453
- * @return { Stringable }
2454
- */
2455
- padRight(length: number, pad?: string): Stringable;
2456
- /**
2457
- * Call the given callback and return a new string.
2458
- *
2459
- * @param { keyof string | ((instance: this) => any) } callback
2460
- *
2461
- * @return { Stringable }
2462
- */
2463
- pipe(callback: keyof string | ((instance: this) => any)): Stringable;
2464
- /**
2465
- * Get the plural form of an English word.
2466
- *
2467
- * @param { number } count
2468
- *
2469
- * @return { Stringable }
2470
- */
2471
- plural(count?: number): Stringable;
2472
- /**
2473
- * Pluralize the last word of an English, studly caps case string.
2474
- *
2475
- * @param { number } count
2476
- *
2477
- * @return { Stringable }
2478
- */
2479
- pluralStudly(count?: number): Stringable;
2480
- /**
2481
- * Pluralize the last word of an English, Pascal case string.
2482
- *
2483
- * @param { number } count
2484
- *
2485
- * @return { Stringable }
2486
- */
2487
- pluralPascal(count?: number): Stringable;
2488
- /**
2489
- * Find the multibyte safe position of the first occurrence of the given substring.
2490
- *
2491
- * @param { string } needle
2492
- * @param { number } offset
2493
- *
2494
- * @return { number | false }
2495
- */
2496
- position(needle: string, offset?: number): number | false;
2497
- /**
2498
- * Prepend the given values to the string.
2499
- *
2500
- * @param { string | string[] } values
2501
- *
2502
- * @return { Stringable }
2503
- */
2504
- prepend(...values: string[]): Stringable;
2505
- /**
2506
- * Remove any occurrence of the given string in the subject.
2507
- *
2508
- * @param { string } search
2509
- * @param { boolean } caseSensitive
2510
- *
2511
- * @return { Stringable }
2512
- */
2513
- remove(search: string, caseSensitive?: boolean): Stringable;
2514
- /**
2515
- * Reverse the string.
2516
- *
2517
- * @return { Stringable }
2518
- */
2519
- reverse(): Stringable;
2520
- /**
2521
- * Substitute placeholders { key } using object with dot notation.
2522
- *
2523
- * @param data
2524
- * @param def
2525
- * @returns
2526
- */
2527
- substitute(data?: Record<string, unknown>, def?: string): Stringable;
2528
- /**
2529
- * Repeat the string.
2530
- *
2531
- * @param { number } times
2532
- *
2533
- * @return { Stringable }
2534
- */
2535
- repeat(times: number): Stringable;
2536
- /**
2537
- * Replace the given value in the given string.
2538
- *
2539
- * @param { string | string[] } search
2540
- * @param { string } replace
2541
- * @param { boolean } caseSensitive
2542
- *
2543
- * @return { Stringable }
2544
- */
2545
- replace(search: string | string[], replace: string, caseSensitive?: boolean): Stringable;
2546
- /**
2547
- * Replace a given value in the string sequentially with an array.
2548
- *
2549
- * @param { string } search
2550
- * @param { string[] } replace
2551
- *
2552
- * @return { Stringable }
2553
- */
2554
- replaceArray(search: string, replace: string[]): Stringable;
2555
- /**
2556
- * Replace the first occurrence of a given value in the string.
2557
- *
2558
- * @param { string } search
2559
- * @param { string } replace
2560
- *
2561
- * @return { Stringable }
2562
- */
2563
- replaceFirst(search: string, replace: string): Stringable;
2564
- /**
2565
- * Replace the first occurrence of the given value if it appears at the start of the string.
2566
- *
2567
- * @param { string } search
2568
- * @param { string } replace
2569
- *
2570
- * @return { Stringable }
2571
- */
2572
- replaceStart(search: string, replace: string): Stringable;
2573
- /**
2574
- * Replace the last occurrence of a given value in the string.
2575
- *
2576
- * @param { string } search
2577
- * @param { string } replace
2578
- *
2579
- * @return { Stringable }
2580
- */
2581
- replaceLast(search: string, replace: string): Stringable;
2582
- /**
2583
- * Replace the last occurrence of a given value if it appears at the end of the string.
2584
- *
2585
- * @param { string } search
2586
- * @param { string } replace
2587
- *
2588
- * @return { Stringable }
2589
- */
2590
- replaceEnd(search: string, replace: string): Stringable;
2591
- /**
2592
- * Replace the patterns matching the given regular expression.
2593
- *
2594
- * @param { string } pattern
2595
- * @param { string | function } replace
2596
- *
2597
- * @return { Stringable }
2598
- */
2599
- replaceMatches(pattern: string, replace: string | Function): Stringable;
2600
- /**
2601
- * Remove all "extra" blank space from the given string.
2602
- *
2603
- * @return { Stringable }
2604
- */
2605
- squish(): Stringable;
2606
- /**
2607
- * Begin a string with a single instance of a given value.
2608
- *
2609
- * @param { string } prefix
2610
- *
2611
- * @return { Stringable }
2612
- */
2613
- start(prefix: string): Stringable;
2614
- /**
2615
- * Convert the given string to upper-case.
2616
- *
2617
- * @return { Stringable }
2618
- */
2619
- upper(): Stringable;
2620
- /**
2621
- * Convert the given string to title case.
2622
- *
2623
- * @return { Stringable }
2624
- */
2625
- title(): Stringable;
2626
- /**
2627
- * Convert the given string to title case for each word.
2628
- *
2629
- * @return { Stringable }
2630
- */
2631
- headline(): Stringable;
2632
- /**
2633
- * Convert the given string to APA-style title case.
2634
- *
2635
- * @see https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
2636
- *
2637
- * @return { Stringable }
2638
- */
2639
- apa(): Stringable;
2640
- /**
2641
- * Get the singular form of an English word.
2642
- *
2643
- * @return { Stringable }
2644
- */
2645
- singular(): Stringable;
2646
- /**
2647
- * Generate a URL friendly "slug" from a given string.
2648
- *
2649
- * @param { string } separator
2650
- * @param { object } dictionary
2651
- *
2652
- * @return { Stringable }
2653
- */
2654
- slug(separator?: string, dictionary?: {
2655
- [key: string]: string;
2656
- }): Stringable;
2657
- /**
2658
- * Convert a string to snake case.
2659
- *
2660
- * @param { string } delimiter
2661
- *
2662
- * @return { Stringable }
2663
- */
2664
- snake(delimiter?: string): Stringable;
2665
- /**
2666
- * Determine if a given string starts with a given substring.
2667
- *
2668
- * @param { string | string[] } needles
2669
- *
2670
- * @return { boolean }
2671
- */
2672
- startsWith(needles: string | string[]): boolean;
2673
- /**
2674
- * Determine if a given string doesn't start with a given substring.
2675
- *
2676
- * @param { string | string[] } needles
2677
- *
2678
- * @return { boolean }
2679
- */
2680
- doesntStartWith(needles: string | string[]): boolean;
2681
- /**
2682
- * Convert a value to studly caps case.
2683
- *
2684
- * @return { Stringable }
2685
- */
2686
- studly(): Stringable;
2687
- /**
2688
- * Convert a value to Pascal case.
2689
- *
2690
- * @return { Stringable }
2691
- */
2692
- pascal(): Stringable;
2693
- /**
2694
- * Returns the portion of the string specified by the start and length parameters.
2695
- *
2696
- * @param { number } start
2697
- * @param { number | null } length
2698
- *
2699
- * @return { Stringable }
2700
- */
2701
- substr(start: number, length?: number | null): Stringable;
2702
- /**
2703
- * Returns the number of substring occurrences.
2704
- *
2705
- * @param { string } needle
2706
- * @param { number } offset
2707
- * @param { number | null } length
2708
- *
2709
- * @return { number }
2710
- */
2711
- substrCount(needle: string, offset?: number, length?: number | null): number;
2712
- /**
2713
- * Replace text within a portion of a string.
2714
- *
2715
- * @param { string } replace
2716
- * @param { number } offset
2717
- * @param { number | null } length
2718
- *
2719
- * @return { Stringable }
2720
- */
2721
- substrReplace(replace: string, offset?: number, length?: number | null): Stringable;
2722
- /**
2723
- * Swap multiple keywords in a string with other keywords.
2724
- *
2725
- * @param { Record<string, string> } map
2726
- *
2727
- * @return { Stringable }
2728
- */
2729
- swap(map: Record<string, string>): Stringable;
2730
- /**
2731
- * Take the first or last {limit} characters.
2732
- *
2733
- * @param { number } limit
2734
- *
2735
- * @return { Stringable }
2736
- */
2737
- take(limit: number): Stringable;
2738
- /**
2739
- * Call the given Closure with this instance then return the instance.
2740
- *
2741
- * @param { ((instance: this) => any) } callback
2742
- *
2743
- * @return { Stringable }
2744
- */
2745
- tap(callback: ((instance: this) => any)): this;
2746
- /**
2747
- * Trim the string of the given characters.
2748
- *
2749
- * @param { string | null } characters
2750
- *
2751
- * @return { Stringable }
2752
- */
2753
- trim(characters?: string | null): Stringable;
2754
- /**
2755
- * Left trim the string of the given characters.
2756
- *
2757
- * @param { string | string[]|null } characters
2758
- *
2759
- * @return { Stringable }
2760
- */
2761
- ltrim(characters?: string | null): Stringable;
2762
- /**
2763
- * Right trim the string of the given characters.
2764
- *
2765
- * @param { string | string[]|null } characters
2766
- *
2767
- * @return { Stringable }
2768
- */
2769
- rtrim(characters?: string | null): Stringable;
2770
- /**
2771
- * Make a string's first character lowercase.
2772
- *
2773
- * @return { Stringable }
2774
- */
2775
- lcfirst(): Stringable;
2776
- /**
2777
- * Make a string's first character uppercase.
2778
- *
2779
- * @return { Stringable }
2780
- */
2781
- ucfirst(): Stringable;
2782
- /**
2783
- * Split a string by uppercase characters.
2784
- *
2785
- * @return { string[] }
2786
- */
2787
- ucsplit(): string[];
2788
- /**
2789
- * Apply the callback if the given "value" is (or resolves to) truthy.
2790
- *
2791
- * @param { Value<this> } value
2792
- * @param { Callback<this> } callback
2793
- * @param { Fallback<this> } fallback
2794
- *
2795
- * @return { Stringable }
2796
- */
2797
- when(value: Value<this>, callback: Callback<this>, fallback?: Fallback<this>): this;
2798
- /**
2799
- * Apply the callback if the given "value" is (or resolves to) falsy.
2800
- *
2801
- * @param { Value<this> } value
2802
- * @param { Callback<this> } callback
2803
- * @param { Fallback<this> } fallback
2804
- *
2805
- * @return { this }
2806
- */
2807
- unless(value: Value<this>, callback: Callback<this>, fallback?: Fallback<this>): this;
2808
- /**
2809
- * Execute the given callback if the string contains a given substring.
2810
- *
2811
- * @param { string | string[] } needles
2812
- * @param { Callback<this> } callback
2813
- * @param { Fallback<this> } fallback
2814
- *
2815
- * @return { this }
2816
- */
2817
- whenContains(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
2818
- /**
2819
- * Execute the given callback if the string contains all array values.
2820
- *
2821
- * @param { string[] } needles
2822
- * @param { Callback<this> } callback
2823
- * @param { Fallback<this> } fallback
2824
- *
2825
- * @return { this }
2826
- */
2827
- whenContainsAll(needles: string[], callback: Callback<this>, fallback?: Fallback<this>): this;
2828
- /**
2829
- * Execute the given callback if the string is empty.
2830
- *
2831
- * @param { Callback<this> } callback
2832
- * @param { Fallback<this> } fallback
2833
- *
2834
- * @return { this }
2835
- */
2836
- whenEmpty(callback: Callback<this>, fallback?: Fallback<this>): this;
2837
- /**
2838
- * Execute the given callback if the string is not empty.
2839
- *
2840
- * @param { Callback<this> } callback
2841
- * @param { Fallback<this> } fallback
2842
- *
2843
- * @return { this }
2844
- */
2845
- whenNotEmpty(callback: Callback<this>, fallback?: Fallback<this>): this;
2846
- /**
2847
- * Execute the given callback if the string ends with a given substring.
2848
- *
2849
- * @param { string | string[] } needles
2850
- * @param { Callback<this> } callback
2851
- * @param { Fallback<this> } fallback
2852
- *
2853
- * @return { this }
2854
- */
2855
- whenEndsWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
2856
- /**
2857
- * Execute the given callback if the string doesn't end with a given substring.
2858
- *
2859
- * @param { string | string[] } needles
2860
- * @param { Callback<this> } callback
2861
- * @param { Fallback<this> } fallback
2862
- *
2863
- * @return { this }
2864
- */
2865
- whenDoesntEndWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
2866
- /**
2867
- * Execute the given callback if the string is an exact match with the given value.
2868
- *
2869
- * @param { string } value
2870
- * @param { Callback<this> } callback
2871
- * @param { Fallback<this> } fallback
2872
- *
2873
- * @return { this }
2874
- */
2875
- whenExactly(value: string, callback: Callback<this>, fallback?: Fallback<this>): this;
2876
- /**
2877
- * Execute the given callback if the string is not an exact match with the given value.
2878
- *
2879
- * @param { string } value
2880
- * @param { Callback<this> } callback
2881
- * @param { Fallback<this> } fallback
2882
- *
2883
- * @return { this }
2884
- */
2885
- whenNotExactly(value: string, callback: Callback<this>, fallback?: Fallback<this>): this;
2886
- /**
2887
- * Execute the given callback if the string matches a given pattern.
2888
- *
2889
- * @param { string | string[] } pattern
2890
- * @param { Callback<this> } callback
2891
- * @param { Fallback<this> } fallback
2892
- *
2893
- * @return { this }
2894
- */
2895
- whenIs(pattern: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
2896
- /**
2897
- * Execute the given callback if the string is 7-bit ASCII.
2898
- *
2899
- * @param { Callback<this> } callback
2900
- * @param { Fallback<this> } fallback
2901
- *
2902
- * @return { this }
2903
- */
2904
- whenIsAscii(callback: Callback<this>, fallback?: Fallback<this>): this;
2905
- /**
2906
- * Execute the given callback if the string is a valid UUID.
2907
- *
2908
- * @param { Callback<this> } callback
2909
- * @param { Fallback<this> } fallback
2910
- *
2911
- * @return { this }
2912
- */
2913
- whenIsUuid(callback: Callback<this>, fallback?: Fallback<this>): this;
2914
- /**
2915
- * Execute the given callback if the string is a valid ULID.
2916
- *
2917
- * @param { Callback<this> } callback
2918
- * @param { Fallback<this> } fallback
2919
- *
2920
- * @return { this }
2921
- */
2922
- whenIsUlid(callback: Callback<this>, fallback?: Fallback<this>): this;
2923
- /**
2924
- * Execute the given callback if the string starts with a given substring.
2925
- *
2926
- * @param { string | string[] } needles
2927
- * @param { Callback<this> } callback
2928
- * @param { Fallback<this> } fallback
2929
- *
2930
- * @return { this }
2931
- */
2932
- whenStartsWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
2933
- /**
2934
- * Execute the given callback if the string doesn't start with a given substring.
2935
- *
2936
- * @param { string | string[] } needles
2937
- * @param { Callback<this> } callback
2938
- * @param { Fallback<this> } fallback
2939
- *
2940
- * @return { this }
2941
- */
2942
- whenDoesntStartWith(needles: string | string[], callback: Callback<this>, fallback?: Fallback<this>): this;
2943
- /**
2944
- * Execute the given callback if the string matches the given pattern.
2945
- *
2946
- * @param { string } pattern
2947
- * @param { Callback<this> } callback
2948
- * @param { Fallback<this> } fallback
2949
- *
2950
- * @return { this }
2951
- */
2952
- whenTest(pattern: string, callback: Callback<this>, fallback?: Fallback<this>): this;
2953
- /**
2954
- * Limit the number of words in a string.
2955
- *
2956
- * @param { number } words
2957
- * @param { string } end
2958
- *
2959
- * @return { Stringable }
2960
- */
2961
- words(words?: number, end?: string): Stringable;
2962
- /**
2963
- * Get the number of words a string contains.
2964
- *
2965
- * @return { number }
2966
- */
2967
- wordCount(): number;
2968
- /**
2969
- * Wrap a string to a given number of characters.
2970
- *
2971
- * @param { number } characters
2972
- * @param { string } breakStr
2973
- * @param { boolean } cutLongWords
2974
- *
2975
- * @returns { this }
2976
- */
2977
- wordWrap(characters?: number, breakStr?: string, cutLongWords?: boolean): Stringable;
2978
- /**
2979
- * Wrap the string with the given strings.
2980
- *
2981
- * @param { string } before
2982
- * @param { string | null } after
2983
- *
2984
- * @return { Stringable }
2985
- */
2986
- wrap(before: string, after?: string | null): Stringable;
2987
- /**
2988
- * Unwrap the string with the given strings.
2989
- *
2990
- * @param { string } before
2991
- * @param { string | null } after
2992
- *
2993
- * @return { Stringable }
2994
- */
2995
- unwrap(before: string, after?: string | null): Stringable;
2996
- /**
2997
- * Convert the string into a `HtmlString` instance.
2998
- *
2999
- * @return { HtmlStringType }
3000
- */
3001
- toHtmlString(): HtmlStringType;
3002
- /**
3003
- * Convert the string to Base64 encoding.
3004
- *
3005
- * @return { Stringable }
3006
- */
3007
- toBase64(): Stringable;
3008
- /**
3009
- * Decode the Base64 encoded string.
3010
- *
3011
- * @return { Stringable }
3012
- */
3013
- fromBase64(): Stringable;
3014
- /**
3015
- * Checks if a string is numeric
3016
- *
3017
- * @return { boolean }
3018
- */
3019
- isNumber(): boolean;
3020
- /**
3021
- * Checks if a string is an integer
3022
- *
3023
- * @return { boolean }
3024
- */
3025
- isInteger(): boolean;
3026
- /**
3027
- * ROT-N cipher.
3028
- *
3029
- * @param n
3030
- * @returns
3031
- */
3032
- rot(n?: number): Stringable;
3033
- /**
3034
- * Replace trailing punctuation with new format.
3035
- *
3036
- * @param newFormat
3037
- * @returns
3038
- */
3039
- replacePunctuation(newFormat: string): Stringable;
3040
- /**
3041
- * Array/object driven text replacement.
3042
- *
3043
- * @param replacements
3044
- * @returns
3045
- */
3046
- translate(replacements: Record<string, string> | Array<[string, string]>): Stringable;
3047
- /**
3048
- * Strip slashes recursively.
3049
- *
3050
- * @returns
3051
- */
3052
- ss(): Stringable;
3053
- /**
3054
- * First and last N lines.
3055
- *
3056
- * @param amount
3057
- * @returns
3058
- */
3059
- firstLines(amount?: number): Stringable;
3060
- /**
3061
- * Last and first N lines.
3062
- *
3063
- * @param amount
3064
- * @returns
3065
- */
3066
- lastLines(amount?: number): Stringable;
3067
- /**
3068
- * Dump the string.
3069
- *
3070
- * @return { void }
3071
- */
3072
- dump(): void;
3073
- /**
3074
- * Dump the string and end the script.
3075
- *
3076
- * @return { never }
3077
- */
3078
- dd(): never;
3079
- /**
3080
- * Get the underlying string value.
3081
- *
3082
- * @return { string }
3083
- */
3084
- value(): string;
3085
- /**
3086
- * Get the raw string value.
3087
- *
3088
- * @return { string }
3089
- */
3090
- toString(): string;
3091
- /**
3092
- * Get the underlying string value as an integer.
3093
- *
3094
- * @param { number } base
3095
- *
3096
- * @return { number }
3097
- */
3098
- toInteger(base?: number): number;
3099
- /**
3100
- * Get the underlying string value as a float.
3101
- *
3102
- * @return { number }
3103
- */
3104
- toFloat(): number;
3105
- /**
3106
- * Get the underlying string value as a boolean.
3107
- *
3108
- * Returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
3109
- *
3110
- * @return { boolean }
3111
- */
3112
- toBoolean(): boolean;
3113
- /**
3114
- * Get the underlying string value as a formatted Date string.
3115
- *
3116
- * @param { string | null } format
3117
- * @param { string | null } tz
3118
- */
3119
- toDate(format?: string | null, tz?: string | null): string;
3120
- }
3121
- declare class HtmlString {
3122
- /**
3123
- * The HTML string.
3124
- *
3125
- * @type { string }
3126
- */
3127
- private readonly html;
3128
- /**
3129
- * Create a new HTML string instance.
3130
- *
3131
- * @param { string } html
3132
- *
3133
- * @return void
3134
- */
3135
- constructor(html?: string);
3136
- /**
3137
- * Get the HTML string.
3138
- *
3139
- * @return { HtmlStringType }
3140
- */
3141
- toHtml(): HtmlStringType;
3142
- /**
3143
- * Determine if the given HTML string is empty.
3144
- *
3145
- * @return { boolean }
3146
- */
3147
- isEmpty(): boolean;
3148
- /**
3149
- * Determine if the given HTML string is not empty.
3150
- *
3151
- * @return { boolean }
3152
- */
3153
- isNotEmpty(): boolean;
3154
- /**
3155
- * Get the HTML string.
3156
- *
3157
- * @return { string }
3158
- */
3159
- toString(): string;
3160
- }
3161
- /**
3162
- * Get a new Stringable object from the given string.
3163
- *
3164
- * @param { string } string
3165
- *
3166
- * @return Stringable
3167
- */
3168
- declare function str(string?: string): Stringable;
3169
- //#endregion
3170
- //#region src/GlobalBootstrap.d.ts
3171
- type CollapseStatics<T$1 extends Record<string, any>> = { [K in keyof T$1]: T$1[K] };
3172
- 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' | '_isObject' | '_clone' | 'crossJoin' | 'divide' | 'wrap' | 'except' | 'hasAny' | 'isList' | 'keyBy' | 'mapWithKeys' | 'only' | 'pluck' | 'pull' | 'shuffle' | 'sortDesc' | 'sortRecursive' | 'sortRecursiveDesc' | 'where' | 'whereNotNull' | 'head' | 'string' | 'boolean' | 'array' | 'float' | 'from' | 'hasAll' | 'integer' | 'mapSpread' | 'partition' | 'reject' | 'select' | 'sole' | 'alternate' | 'combine' | 'isEmpty' | 'isNotEmpty' | 'range' | typeof Symbol.unscopables | typeof Symbol.iterator;
3173
- type TakeTime = Pick<typeof DateTime, 'now' | 'format' | 'fromTimestamp' | 'randomTime' | 'firstDayOfMonth' | 'lastDayOfMonth' | 'parse'>;
3174
- type TakeString = Pick<typeof Str, 'after' | 'afterLast' | 'apa' | 'ascii' | 'before' | 'beforeLast' | 'between' | 'betweenFirst' | 'capitalize' | 'plural' | 'singular' | 'title'>;
3175
- /**
3176
- * Global helpers interface that mirrors Laravel's helpers
3177
- * and provides convenient access to all utility functions
3178
- */
3179
- interface GlobalHelpers extends Omit<CollapseStatics<typeof Arr>, Omitables | 'random' | 'dot'>, Omit<CollapseStatics<TakeString>, Omitables | 'random' | 'uuid'>, Omit<CollapseStatics<TakeTime>, Omitables>, Omit<CollapseStatics<typeof Obj_d_exports>, Omitables | 'Obj'>, Omit<CollapseStatics<typeof Crypto_d_exports>, Omitables>, Omit<CollapseStatics<typeof Number_d_exports>, Omitables>, Omit<CollapseStatics<typeof DumpDie_d_exports>, Omitables> {
3180
- Arr: typeof Arr;
3181
- Str: typeof Str;
3182
- Obj: typeof Obj;
3183
- Crypto: typeof Crypto_d_exports;
3184
- Number: typeof Number_d_exports;
3185
- DumpDie: typeof DumpDie_d_exports;
3186
- DateTime: typeof DateTime;
3187
- }
3188
- /**
3189
- * Bootstrap the global helpers into the global scope.
3190
- * This enables optional global access to all helper functions.
3191
- *
3192
- * Example usage:
3193
- * ```typescript
3194
- * import { loadHelpers } from '@h3ravel/support'
3195
- *
3196
- * // Make helpers globally available
3197
- * loadHelpers()
3198
- *
3199
- * // Now you can use:
3200
- * Arr.chunk([1, 2, 3, 4], 2)
3201
- * // or directly:
3202
- * chunk([1, 2, 3, 4], 2)
3203
- * Str.capitalize('hello world')
3204
- * // or directly:
3205
- * capitalize('hello world')
3206
- * ```
3207
- *
3208
- * @param target - The target object to attach helpers to (default: globalThis)
3209
- */
3210
- declare function loadHelpers(target?: any): void;
3211
- /**
3212
- * Clean up global helpers by removing them from the global scope.
3213
- * This function removes all global helper attachments.
3214
- *
3215
- * @param target - The target object to clean up (default: globalThis)
3216
- */
3217
- declare function cleanHelpers(target?: any): void;
3218
- //#endregion
3219
- export { Arr, Arrayable, Callback, CamelToSnakeCase, Crypto_d_exports as Crypto, DateTime, DotPath, ExcerptOptions, Fallback, Function, GlobalHelpers, HtmlString, HtmlStringType, InvalidArgumentException, JsonSerializable, Jsonable, KeysToSnakeCase, Mode, Number_d_exports as Number, Obj, RuntimeException, SnakeToCamelCase, SnakeToTitleCase, Str, Stringable, TGeneric, Value, XGeneric, abbreviate, base64Decode, base64Encode, caesarCipher, checksum, cleanHelpers, data_fill, data_forget, data_get, data_set, dd, dot, dump, extractProperties, format, getValue, hash, hmac, humanize, isPlainObject, loadHelpers, modObj, random, randomColor, randomPassword, randomSecure, safeDot, secureToken, setNested, slugifyKeys, str, toBytes, toCssClasses, toCssStyles, toHumanTime, undot, uuid, verifyChecksum, xor };