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