@h3ravel/support 0.14.3 → 0.14.5

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