@h3ravel/support 0.11.0 → 0.13.0

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