@tolki/str 1.0.8 → 1.0.10

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/README.md CHANGED
@@ -8,7 +8,7 @@ The full documentation for the string utilities can be found at [https://tolki.a
8
8
 
9
9
  <!-- AUTO-GENERATED-DOCS:START -->
10
10
 
11
- # String Utilities Installation
11
+ ## String Utilities Installation
12
12
 
13
13
  The [`@tolki/str`](https://www.npmjs.com/package/@tolki/str) package provides a variety of string manipulation utilities inspired by Laravel's Str class. You can install it via npm, yarn, or pnpm:
14
14
 
@@ -24,7 +24,7 @@ yarn add @tolki/str
24
24
  pnpm add @tolki/str
25
25
  ```
26
26
 
27
- ## Importing the Package
27
+ ### Importing the Package
28
28
 
29
29
  You can import individual functions for better tree-shaking or the entire package (not recommended).:
30
30
 
@@ -54,17 +54,17 @@ The reason that importing the entire package is not recommended is that it will
54
54
 
55
55
  However, if you are working on a backend project where bundle size is not a concern, importing the entire package can be more convenient.
56
56
 
57
- # Tolki String Utilities List
57
+ ## Tolki String Utilities List
58
58
 
59
- ## String Utilities List
59
+ ### String Utilities List
60
60
 
61
61
  These are the string utilities that can be used independently as single functions.
62
62
 
63
- [after](#after) [afterLast](#afterlast) [apa](#apa) [ascii](#ascii) [before](#before) [beforeLast](#beforelast) [between](#between) [betweenFirst](#betweenfirst) [camel](#camel) [charAt](#charat) [chopEnd](#chopend) [chopStart](#chopstart) [contains](#contains) [containsAll](#containsall) [doesntContain](#doesntcontain) [deduplicate](#deduplicate) [doesntEndWith](#doesntendwith) [doesntStartWith](#doesntstartwith) [endsWith](#endswith) [excerpt](#excerpt) [finish](#finish) [fromBase64](#frombase64) [headline](#headline) [inlineMarkdown](#inlinemarkdown) [is](#is) [isAscii](#isascii) [isJson](#isjson) [isUrl](#isurl) [isUlid](#isulid) [isUuid](#isuuid) [kebab](#kebab) [lcfirst](#lcfirst) [length](#length) [limit](#limit) [lower](#lower) [markdown](#markdown) [mask](#mask) [match](#match) [matchAll](#matchall) [isMatch](#ismatch) [numbers](#numbers) [padBoth](#padboth) [padLeft](#padleft) [padRight](#padright) [pascal](#pascal) [pluralPascal](#pluralpascal) [password](#password) [plural](#plural) [pluralStudly](#pluralstudly) [position](#position) [random](#random) [remove](#remove) [repeat](#repeat) [replace](#replace) [replaceArray](#replacearray) [replaceFirst](#replacefirst) [replaceLast](#replacelast) [replaceMatches](#replacematches) [replaceStart](#replacestart) [replaceEnd](#replaceend) [reverse](#reverse) [singular](#singular) [slug](#slug) [snake](#snake) [squish](#squish) [start](#start) [startsWith](#startswith) [stripTags](#striptags) [studly](#studly) [substr](#substr) [substrCount](#substrcount) [substrReplace](#substrreplace) [swap](#swap) [take](#take) [title](#title) [toBase64](#tobase64) [transliterate](#transliterate) [trim](#trim) [ltrim](#ltrim) [rtrim](#rtrim) [ucfirst](#ucfirst) [ucsplit](#ucsplit) [ucwords](#ucwords) [upper](#upper) [ulid](#ulid) [unwrap](#unwrap) [uuid](#uuid) [uuid7](#uuid7) [wordCount](#wordcount) [wordWrap](#wordwrap) [words](#words) [wrap](#wrap) [str](#str) [of](#of)
63
+ [after](#after) [afterLast](#afterlast) [apa](#apa) [ascii](#ascii) [before](#before) [beforeLast](#beforelast) [between](#between) [betweenFirst](#betweenfirst) [camel](#camel) [charAt](#charat) [chopEnd](#chopend) [chopStart](#chopstart) [contains](#contains) [containsAll](#containsall) [doesntContain](#doesntcontain) [deduplicate](#deduplicate) [doesntEndWith](#doesntendwith) [doesntStartWith](#doesntstartwith) [endsWith](#endswith) [excerpt](#excerpt) [finish](#finish) [fromBase64](#frombase64) [headline](#headline) [initials](#initials) [inlineMarkdown](#inlinemarkdown) [is](#is) [isAscii](#isascii) [isJson](#isjson) [isUrl](#isurl) [isUlid](#isulid) [isUuid](#isuuid) [kebab](#kebab) [lcfirst](#lcfirst) [length](#length) [limit](#limit) [lower](#lower) [markdown](#markdown) [mask](#mask) [match](#match) [matchAll](#matchall) [isMatch](#ismatch) [numbers](#numbers) [padBoth](#padboth) [padLeft](#padleft) [padRight](#padright) [pascal](#pascal) [pluralPascal](#pluralpascal) [password](#password) [plural](#plural) [pluralStudly](#pluralstudly) [position](#position) [random](#random) [remove](#remove) [repeat](#repeat) [replace](#replace) [replaceArray](#replacearray) [replaceFirst](#replacefirst) [replaceLast](#replacelast) [replaceMatches](#replacematches) [replaceStart](#replacestart) [replaceEnd](#replaceend) [reverse](#reverse) [singular](#singular) [slug](#slug) [snake](#snake) [squish](#squish) [start](#start) [startsWith](#startswith) [stripTags](#striptags) [studly](#studly) [substr](#substr) [substrCount](#substrcount) [substrReplace](#substrreplace) [swap](#swap) [take](#take) [title](#title) [toBase64](#tobase64) [transliterate](#transliterate) [trim](#trim) [ltrim](#ltrim) [rtrim](#rtrim) [ucfirst](#ucfirst) [ucsplit](#ucsplit) [ucwords](#ucwords) [upper](#upper) [ulid](#ulid) [unwrap](#unwrap) [uuid](#uuid) [uuid7](#uuid7) [wordCount](#wordcount) [wordWrap](#wordwrap) [words](#words) [wrap](#wrap) [str](#str) [of](#of)
64
64
 
65
- ## String Utilities Details
65
+ ### String Utilities Details
66
66
 
67
- ### after
67
+ #### after
68
68
 
69
69
  Return the remainder of a string after the first occurrence of a given value.
70
70
 
@@ -76,7 +76,7 @@ const result = after("This is my name", "This is");
76
76
  // result is " my name"
77
77
  ```
78
78
 
79
- ### afterLast
79
+ #### afterLast
80
80
 
81
81
  Return the remainder of a string after the last occurrence of a given value.
82
82
 
@@ -88,7 +88,7 @@ const result = afterLast("App\Http\Controllers\Controller", "\\");
88
88
  // result is "Controller"
89
89
  ```
90
90
 
91
- ### apa
91
+ #### apa
92
92
 
93
93
  Convert the given string to [APA-style](https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case) title case.
94
94
 
@@ -100,7 +100,7 @@ const result = apa("Creating A Project");
100
100
  // result is "Creating a Project"
101
101
  ```
102
102
 
103
- ### ascii
103
+ #### ascii
104
104
 
105
105
  Transliterate a UTF-8 value to ASCII.
106
106
 
@@ -114,7 +114,7 @@ const result = ascii("û");
114
114
  // result is "u"
115
115
  ```
116
116
 
117
- ### before
117
+ #### before
118
118
 
119
119
  Get the portion of a string before the first occurrence of a given value.
120
120
 
@@ -126,7 +126,7 @@ const result = before("This is my name", "my");
126
126
  // result is "This is "
127
127
  ```
128
128
 
129
- ### beforeLast
129
+ #### beforeLast
130
130
 
131
131
  Get the portion of a string before the last occurrence of a given value.
132
132
 
@@ -138,7 +138,7 @@ const result = beforeLast("This is my name", "is");
138
138
  // result is "This "
139
139
  ```
140
140
 
141
- ### between
141
+ #### between
142
142
 
143
143
  Get the portion of a string between two given values.
144
144
 
@@ -150,7 +150,7 @@ const result = between("This is my name", "This", "name");
150
150
  // result is " is my "
151
151
  ```
152
152
 
153
- ### betweenFirst
153
+ #### betweenFirst
154
154
 
155
155
  Get the smallest possible portion of a string between two given values.
156
156
 
@@ -162,7 +162,7 @@ const result = betweenFirst("[a] bc [d]", "[", "]");
162
162
  // result is "a"
163
163
  ```
164
164
 
165
- ### camel
165
+ #### camel
166
166
 
167
167
  Convert a value to camel case.
168
168
 
@@ -174,7 +174,7 @@ const result = camel("foo_bar");
174
174
  // result is "fooBar"
175
175
  ```
176
176
 
177
- ### charAt
177
+ #### charAt
178
178
 
179
179
  Get the character at the specified index.
180
180
 
@@ -186,7 +186,7 @@ const result = charAt("This is my name.", 6);
186
186
  // result is "s"
187
187
  ```
188
188
 
189
- ### chopStart
189
+ #### chopStart
190
190
 
191
191
  Remove the given string(s) if it exists at the start of the haystack.
192
192
 
@@ -208,7 +208,7 @@ const result = chopStart("http://laravel.com", ["https://", "http://"]);
208
208
  // result is "laravel.com"
209
209
  ```
210
210
 
211
- ### chopEnd
211
+ #### chopEnd
212
212
 
213
213
  Remove the given string(s) if it exists at the end of the haystack.
214
214
 
@@ -230,7 +230,7 @@ const result = chopEnd("laravel.com/index.php", ["/index.html", "/index.php"]);
230
230
  // result is "laravel.com"
231
231
  ```
232
232
 
233
- ### contains
233
+ #### contains
234
234
 
235
235
  Determine if a given string contains a given substring.
236
236
 
@@ -262,7 +262,7 @@ const result = contains("This is my name", "MY", true);
262
262
  // result is true
263
263
  ```
264
264
 
265
- ### containsAll
265
+ #### containsAll
266
266
 
267
267
  Determine if a given string contains all array values.
268
268
 
@@ -284,7 +284,7 @@ const result = containsAll("This is my name", ["MY", "NAME"], true);
284
284
  // result is true
285
285
  ```
286
286
 
287
- ### doesntContain
287
+ #### doesntContain
288
288
 
289
289
  Determine if a given string doesn't contain a given substring.
290
290
 
@@ -316,7 +316,7 @@ const result = doesntContain("This is name", "MY", true);
316
316
  // result is true
317
317
  ```
318
318
 
319
- ### deduplicate
319
+ #### deduplicate
320
320
 
321
321
  Replace consecutive instances of a given character with a single character in the given string.
322
322
 
@@ -348,7 +348,7 @@ const result = deduplicate("The---Laravel Framework", ["-", " "]);
348
348
  // result is "The-Laravel Framework"
349
349
  ```
350
350
 
351
- ### doesntEndWith
351
+ #### doesntEndWith
352
352
 
353
353
  Determine if a given string doesn't end with a given substring.
354
354
 
@@ -374,7 +374,7 @@ const result2 = doesntEndWith("This is my name", ["name", "foo"]);
374
374
  // result2 is false
375
375
  ```
376
376
 
377
- ### doesntStartWith
377
+ #### doesntStartWith
378
378
 
379
379
  Determine if a given string doesn't start with a given substring.
380
380
 
@@ -400,7 +400,7 @@ const result2 = doesntStartWith("This is my name", ["name", "foo"]);
400
400
  // result2 is true
401
401
  ```
402
402
 
403
- ### endsWith
403
+ #### endsWith
404
404
 
405
405
  Determine if a given string ends with a given substring.
406
406
 
@@ -426,7 +426,7 @@ const result2 = endsWith("This is my name", ["this", "foo"]);
426
426
  // result2 is false
427
427
  ```
428
428
 
429
- ### excerpt
429
+ #### excerpt
430
430
 
431
431
  Extracts an excerpt from text that matches the first instance of a phrase.
432
432
 
@@ -453,7 +453,7 @@ const result = excerpt("This is my name", "name", {
453
453
  // result is "(...) my name"
454
454
  ```
455
455
 
456
- ### finish
456
+ #### finish
457
457
 
458
458
  Cap a string with a single instance of a given value.
459
459
 
@@ -469,7 +469,7 @@ const result2 = finish("this/string/", "/");
469
469
  // result2 is also 'this/string/'
470
470
  ```
471
471
 
472
- ### fromBase64
472
+ #### fromBase64
473
473
 
474
474
  Decode the given Base64 encoded string.
475
475
 
@@ -481,7 +481,7 @@ const result = fromBase64("TGFyYXZlbA==");
481
481
  // result is 'Laravel'
482
482
  ```
483
483
 
484
- ### headline
484
+ #### headline
485
485
 
486
486
  Convert the given string to proper case for each word.
487
487
 
@@ -497,7 +497,23 @@ const result2 = headline("EmailNotificationSent");
497
497
  // result2 is "Email Notification Sent"
498
498
  ```
499
499
 
500
- ### inlineMarkdown
500
+ #### initials
501
+
502
+ Get the "initials" representing each word in the provided string, optionally capitalizing.
503
+
504
+ ```javascript
505
+ import { initials } from "@tolki/str";
506
+
507
+ const result = initials("taylor otwell");
508
+
509
+ // result is "to"
510
+
511
+ const result2 = initials("taylor otwell", true);
512
+
513
+ // result2 is "TO"
514
+ ```
515
+
516
+ #### inlineMarkdown
501
517
 
502
518
  Converts inline Markdown into HTML.
503
519
 
@@ -511,7 +527,7 @@ const result = inlineMarkdown("This is **bold** and this is *italic*.");
511
527
  // result is 'This is <strong>bold</strong> and this is <em>italic</em>.'
512
528
  ```
513
529
 
514
- #### Inline Markdown Security
530
+ ##### Inline Markdown Security
515
531
 
516
532
  By default, the `inlineMarkdown` function disables raw HTML and unsafe links (e.g., `javascript:` URLs) to prevent XSS attacks. You can enable raw HTML by passing `{ html: true }` in the options.
517
533
 
@@ -538,7 +554,7 @@ const result = inlineMarkdown("[click me](javascript:alert(1))", {
538
554
  // result is '<a href="javascript:alert(1)">click me</a>'
539
555
  ```
540
556
 
541
- ### is
557
+ #### is
542
558
 
543
559
  Determine if a given string matches a given pattern.
544
560
 
@@ -564,7 +580,7 @@ const result = is("*.jpg", "photo.JPG", true);
564
580
  // result is true
565
581
  ```
566
582
 
567
- ### isAscii
583
+ #### isAscii
568
584
 
569
585
  Determine if a given string is 7 bit ASCII.
570
586
 
@@ -580,7 +596,7 @@ const result2 = isAscii("û");
580
596
  // result2 is false
581
597
  ```
582
598
 
583
- ### isJson
599
+ #### isJson
584
600
 
585
601
  Determine if a given value is valid JSON.
586
602
 
@@ -600,7 +616,7 @@ const result3 = isJson('{first: "John", last: "Doe"}');
600
616
  // result3 is false
601
617
  ```
602
618
 
603
- ### isUrl
619
+ #### isUrl
604
620
 
605
621
  Determine if a given value is a valid URL.
606
622
 
@@ -630,7 +646,7 @@ const result2 = isUrl("http://example.com", ["https"]);
630
646
  // result2 is false
631
647
  ```
632
648
 
633
- ### isUlid
649
+ #### isUlid
634
650
 
635
651
  Determine if a given value is a valid ULID.
636
652
 
@@ -646,7 +662,7 @@ const result2 = isUlid("tolkijs");
646
662
  // result2 is false
647
663
  ```
648
664
 
649
- ### isUuid
665
+ #### isUuid
650
666
 
651
667
  Determine if a given value is a valid UUID.
652
668
 
@@ -678,7 +694,7 @@ const result2 = isUuid("a0a2a2d2-0b87-4a18-83f2-2529882be2de", 5);
678
694
  // result2 is false
679
695
  ```
680
696
 
681
- ### kebab
697
+ #### kebab
682
698
 
683
699
  Convert a string to kebab case.
684
700
 
@@ -690,7 +706,7 @@ const result = kebab("fooBar");
690
706
  // result is "foo-bar"
691
707
  ```
692
708
 
693
- ### lcfirst
709
+ #### lcfirst
694
710
 
695
711
  Make a string's first character lowercase.
696
712
 
@@ -702,7 +718,7 @@ const result = lcfirst("Foo Bar");
702
718
  // result is "foo Bar"
703
719
  ```
704
720
 
705
- ### length
721
+ #### length
706
722
 
707
723
  Return the length of the given string.
708
724
 
@@ -714,7 +730,7 @@ const result = length("Tolki JS");
714
730
  // result is 8
715
731
  ```
716
732
 
717
- ### limit
733
+ #### limit
718
734
 
719
735
  Limit the number of characters in a string.
720
736
 
@@ -751,7 +767,7 @@ const result = limit(
751
767
  // result is "The quick..."
752
768
  ```
753
769
 
754
- ### lower
770
+ #### lower
755
771
 
756
772
  Convert the given string to lower-case.
757
773
 
@@ -763,7 +779,7 @@ const result = lower("LARAVEL");
763
779
  // result is "laravel"
764
780
  ```
765
781
 
766
- ### markdown
782
+ #### markdown
767
783
 
768
784
  Converts GitHub flavored Markdown into HTML.
769
785
 
@@ -777,7 +793,7 @@ const result = markdown("# Laravel");
777
793
  // result is "<h1>Laravel</h1>"
778
794
  ```
779
795
 
780
- #### Markdown Security
796
+ ##### Markdown Security
781
797
 
782
798
  By default, the `markdown` function disables raw HTML and unsafe links (e.g., `javascript:` URLs) to prevent XSS attacks. You can enable raw HTML by passing `{ html: true }` in the options.
783
799
 
@@ -804,7 +820,7 @@ const result = markdown("[click me](javascript:alert(1))", {
804
820
  // result is '<p><a href="javascript:alert(1)">click me</a></p>'
805
821
  ```
806
822
 
807
- ### mask
823
+ #### mask
808
824
 
809
825
  Masks a portion of a string with a repeated character.
810
826
 
@@ -826,7 +842,7 @@ const result = mask("taylor@example.com", "*", -15, 3);
826
842
  // result is "tay***@example.com"
827
843
  ```
828
844
 
829
- ### match
845
+ #### match
830
846
 
831
847
  Get the string matching the given pattern.
832
848
 
@@ -842,7 +858,7 @@ const result2 = match("/foo (.*)/", "foo bar");
842
858
  // result2 is "bar"
843
859
  ```
844
860
 
845
- ### matchAll
861
+ #### matchAll
846
862
 
847
863
  Get the string(s) matching the given pattern.
848
864
 
@@ -856,7 +872,7 @@ const result = matchAll("/bar/", "bar foo bar");
856
872
 
857
873
  If no matches are found, an empty array will be returned.
858
874
 
859
- ### isMatch
875
+ #### isMatch
860
876
 
861
877
  Determine if a given string matches a given pattern.
862
878
 
@@ -872,13 +888,13 @@ const result2 = isMatch("/foo (.*)/", "laravel");
872
888
  // result2 is false
873
889
  ```
874
890
 
875
- ### orderedUuid
891
+ #### orderedUuid
876
892
 
877
893
  This function is purposely not implemented. Use the `uuid7()` function instead to generate a UUIDv7, which is a time-ordered UUID.
878
894
 
879
895
  See more details on this [StackOverflow discussion](https://stackoverflow.com/a/79196945).
880
896
 
881
- ### numbers
897
+ #### numbers
882
898
 
883
899
  Remove all non-numeric characters from a string.
884
900
 
@@ -894,7 +910,7 @@ const result2 = numbers("L4r4v3l!");
894
910
  // result2 is "443"
895
911
  ```
896
912
 
897
- ### padBoth
913
+ #### padBoth
898
914
 
899
915
  Pad both sides of a string with another string to a certain length.
900
916
 
@@ -910,7 +926,7 @@ const result2 = padBoth("James", 10);
910
926
  // result2 is " James "
911
927
  ```
912
928
 
913
- ### padLeft
929
+ #### padLeft
914
930
 
915
931
  Pad the left side of a string with another string to a certain length.
916
932
 
@@ -926,7 +942,7 @@ const result2 = padLeft("James", 10);
926
942
  // result2 is " James"
927
943
  ```
928
944
 
929
- ### padRight
945
+ #### padRight
930
946
 
931
947
  Pad the right side of a string with another string to a certain length.
932
948
 
@@ -942,7 +958,7 @@ const result2 = padRight("James", 10);
942
958
  // result2 is "James "
943
959
  ```
944
960
 
945
- ### pascal
961
+ #### pascal
946
962
 
947
963
  Convert a value to Pascal case.
948
964
 
@@ -954,7 +970,7 @@ const result = pascal("hello world");
954
970
  // result is "HelloWorld"
955
971
  ```
956
972
 
957
- ### pluralPascal
973
+ #### pluralPascal
958
974
 
959
975
  Pluralize the last word of an English, Pascal caps case string.
960
976
 
@@ -966,7 +982,7 @@ const result = pluralPascal("HelloWorld");
966
982
  // result is "HelloWorlds"
967
983
  ```
968
984
 
969
- ### password
985
+ #### password
970
986
 
971
987
  Generate a random, secure password.
972
988
 
@@ -978,7 +994,7 @@ const result = password();
978
994
  // result is a random, secure password
979
995
  ```
980
996
 
981
- ### plural
997
+ #### plural
982
998
 
983
999
  Get the plural form of an English word.
984
1000
 
@@ -1018,7 +1034,7 @@ const result = plural("car", 1000, true);
1018
1034
  // result is "1,000 cars"
1019
1035
  ```
1020
1036
 
1021
- ### pluralStudly
1037
+ #### pluralStudly
1022
1038
 
1023
1039
  Pluralize the last word of an English, studly caps case string.
1024
1040
 
@@ -1034,7 +1050,7 @@ const result2 = pluralStudly("UserFeedback");
1034
1050
  // result2 is "UserFeedback"
1035
1051
  ```
1036
1052
 
1037
- ### position
1053
+ #### position
1038
1054
 
1039
1055
  Find the multi-byte safe position of the first occurrence of a given substring in a string.
1040
1056
 
@@ -1050,7 +1066,7 @@ const result2 = position("Hello, World!", "W");
1050
1066
  // result2 is 7
1051
1067
  ```
1052
1068
 
1053
- ### random
1069
+ #### random
1054
1070
 
1055
1071
  Generate a more truly "random" alpha-numeric string.
1056
1072
 
@@ -1096,7 +1112,7 @@ const result2 = random(5);
1096
1112
  // result is a random 5-character alpha-numeric string
1097
1113
  ```
1098
1114
 
1099
- ### remove
1115
+ #### remove
1100
1116
 
1101
1117
  Remove any occurrence of the given string in the subject.
1102
1118
 
@@ -1122,7 +1138,7 @@ const result = remove(
1122
1138
  // result is "Ptr Pipr pickd a pck of pickld ppprs."
1123
1139
  ```
1124
1140
 
1125
- ### repeat
1141
+ #### repeat
1126
1142
 
1127
1143
  Repeat the given string.
1128
1144
 
@@ -1134,7 +1150,7 @@ const result = repeat("a", 5);
1134
1150
  // result is "aaaaa"
1135
1151
  ```
1136
1152
 
1137
- ### replace
1153
+ #### replace
1138
1154
 
1139
1155
  Replace the given value in the given string.
1140
1156
 
@@ -1161,7 +1177,7 @@ const result = replace(
1161
1177
  // result is "Laravel Framework for Web Artisans"
1162
1178
  ```
1163
1179
 
1164
- ### replaceArray
1180
+ #### replaceArray
1165
1181
 
1166
1182
  Replace a given value in the string sequentially with an array.
1167
1183
 
@@ -1177,7 +1193,7 @@ const result = replaceArray(
1177
1193
  // result is "The event will take place between 8:30 and 9:00"
1178
1194
  ```
1179
1195
 
1180
- ### replaceFirst
1196
+ #### replaceFirst
1181
1197
 
1182
1198
  Replace the first occurrence of a given value in the string.
1183
1199
 
@@ -1193,7 +1209,7 @@ const result = replaceFirst(
1193
1209
  // result is "a quick brown fox jumps over the lazy dog"
1194
1210
  ```
1195
1211
 
1196
- ### replaceLast
1212
+ #### replaceLast
1197
1213
 
1198
1214
  Replace the last occurrence of a given value in the string.
1199
1215
 
@@ -1209,7 +1225,7 @@ const result = replaceLast(
1209
1225
  // result is "the quick brown fox jumps over a lazy dog"
1210
1226
  ```
1211
1227
 
1212
- ### replaceMatches
1228
+ #### replaceMatches
1213
1229
 
1214
1230
  Replace the patterns matching the given regular expression.
1215
1231
 
@@ -1235,7 +1251,7 @@ const result = replaceMatches(
1235
1251
  // result is "My numbers are number 123 and number 456."
1236
1252
  ```
1237
1253
 
1238
- ### replaceStart
1254
+ #### replaceStart
1239
1255
 
1240
1256
  Replace the first occurrence of the given value if it appears at the start of the string.
1241
1257
 
@@ -1251,7 +1267,7 @@ const result2 = replaceStart("World", "Laravel", "Hello World");
1251
1267
  // result2 is "Hello World"
1252
1268
  ```
1253
1269
 
1254
- ### replaceEnd
1270
+ #### replaceEnd
1255
1271
 
1256
1272
  Replace the last occurrence of a given value if it appears at the end of the string.
1257
1273
 
@@ -1267,7 +1283,7 @@ const result2 = replaceEnd("Hello", "Laravel", "Hello World");
1267
1283
  // result2 is "Hello World"
1268
1284
  ```
1269
1285
 
1270
- ### reverse
1286
+ #### reverse
1271
1287
 
1272
1288
  Reverse the given string.
1273
1289
 
@@ -1279,7 +1295,7 @@ const result = reverse("Hello World");
1279
1295
  // result is "dlroW olleH"
1280
1296
  ```
1281
1297
 
1282
- ### singular
1298
+ #### singular
1283
1299
 
1284
1300
  Get the singular form of an English word.
1285
1301
 
@@ -1297,7 +1313,7 @@ const result2 = singular("children");
1297
1313
  // result2 is "child"
1298
1314
  ```
1299
1315
 
1300
- ### slug
1316
+ #### slug
1301
1317
 
1302
1318
  Generate a URL friendly "slug" from a given string.
1303
1319
 
@@ -1309,7 +1325,7 @@ const result = slug("Laravel 5 Framework", "-");
1309
1325
  // result is "laravel-5-framework"
1310
1326
  ```
1311
1327
 
1312
- ### snake
1328
+ #### snake
1313
1329
 
1314
1330
  Convert a string to snake case.
1315
1331
 
@@ -1325,7 +1341,7 @@ const result2 = snake("fooBar", "-");
1325
1341
  // result2 is "foo-bar"
1326
1342
  ```
1327
1343
 
1328
- ### squish
1344
+ #### squish
1329
1345
 
1330
1346
  Remove all "extra" blank space from the given string.
1331
1347
 
@@ -1337,7 +1353,7 @@ const result = squish(" laravel framework ");
1337
1353
  // result is "laravel framework"
1338
1354
  ```
1339
1355
 
1340
- ### start
1356
+ #### start
1341
1357
 
1342
1358
  Begin a string with a single instance of a given value.
1343
1359
 
@@ -1353,7 +1369,7 @@ const result2 = start("/this/string", "/");
1353
1369
  // result2 is also '/this/string'
1354
1370
  ```
1355
1371
 
1356
- ### startsWith
1372
+ #### startsWith
1357
1373
 
1358
1374
  Determine if a given string starts with a given substring.
1359
1375
 
@@ -1375,7 +1391,7 @@ const result = startsWith("This is my name", ["This", "That", "There"]);
1375
1391
  // result is true
1376
1392
  ```
1377
1393
 
1378
- ### stripTags
1394
+ #### stripTags
1379
1395
 
1380
1396
  Strip HTML tags from a string.
1381
1397
 
@@ -1387,7 +1403,7 @@ const result = stripTags("<p>Hello <strong>World</strong></p>");
1387
1403
  // result is "Hello World"
1388
1404
  ```
1389
1405
 
1390
- ### studly
1406
+ #### studly
1391
1407
 
1392
1408
  Convert a value to studly caps case.
1393
1409
 
@@ -1399,7 +1415,7 @@ const result = studly("foo_bar");
1399
1415
  // result is "FooBar"
1400
1416
  ```
1401
1417
 
1402
- ### substr
1418
+ #### substr
1403
1419
 
1404
1420
  Returns the portion of the string specified by the start and length parameters.
1405
1421
 
@@ -1411,7 +1427,7 @@ const result = substr("The Laravel Framework", 4, 7);
1411
1427
  // result is "Laravel"
1412
1428
  ```
1413
1429
 
1414
- ### substrCount
1430
+ #### substrCount
1415
1431
 
1416
1432
  Returns the number of substring occurrences.
1417
1433
 
@@ -1426,7 +1442,7 @@ const result = substrCount(
1426
1442
  // result is 2
1427
1443
  ```
1428
1444
 
1429
- ### substrReplace
1445
+ #### substrReplace
1430
1446
 
1431
1447
  Replace text within a portion of a string.
1432
1448
 
@@ -1442,7 +1458,7 @@ const result2 = substrReplace("1300", ":", 2, 0);
1442
1458
  // result2 is also "13:00"
1443
1459
  ```
1444
1460
 
1445
- ### swap
1461
+ #### swap
1446
1462
 
1447
1463
  Swap multiple keywords in a string with other keywords.
1448
1464
 
@@ -1460,7 +1476,7 @@ const result = swap(
1460
1476
  // result is "Burritos are fantastic"
1461
1477
  ```
1462
1478
 
1463
- ### take
1479
+ #### take
1464
1480
 
1465
1481
  Take the first or last {$limit} characters of a string.
1466
1482
 
@@ -1476,7 +1492,7 @@ const result2 = take("Build something amazing!", -5);
1476
1492
  // result2 is "zing!"
1477
1493
  ```
1478
1494
 
1479
- ### title
1495
+ #### title
1480
1496
 
1481
1497
  Convert the given string to proper case.
1482
1498
 
@@ -1488,7 +1504,7 @@ const result = title("a nice title uses the correct case");
1488
1504
  // result is "A Nice Title Uses The Correct Case"
1489
1505
  ```
1490
1506
 
1491
- ### toBase64
1507
+ #### toBase64
1492
1508
 
1493
1509
  Convert the given string to Base64 encoding.
1494
1510
 
@@ -1500,7 +1516,7 @@ const result = toBase64("Laravel");
1500
1516
  // result is "TGFyYXZlbA=="
1501
1517
  ```
1502
1518
 
1503
- ### transliterate
1519
+ #### transliterate
1504
1520
 
1505
1521
  Transliterate a string to its closest ASCII representation.
1506
1522
 
@@ -1518,7 +1534,7 @@ const result2 = transliterate("ⓣⓔⓢⓣ@ⓛⓐⓡⓐⓥⓔⓛ.ⓒⓞⓜ");
1518
1534
  // result2 is "test@laravel.com"
1519
1535
  ```
1520
1536
 
1521
- ### trim
1537
+ #### trim
1522
1538
 
1523
1539
  Remove all whitespace from both ends of a string.
1524
1540
 
@@ -1530,7 +1546,7 @@ const result = trim(" foo bar ");
1530
1546
  // result is "foo bar"
1531
1547
  ```
1532
1548
 
1533
- ### ltrim
1549
+ #### ltrim
1534
1550
 
1535
1551
  Remove all whitespace from the beginning of a string.
1536
1552
 
@@ -1542,7 +1558,7 @@ const result = ltrim(" foo bar ");
1542
1558
  // result is "foo bar "
1543
1559
  ```
1544
1560
 
1545
- ### rtrim
1561
+ #### rtrim
1546
1562
 
1547
1563
  Remove all whitespace from the end of a string.
1548
1564
 
@@ -1554,7 +1570,7 @@ const result = rtrim(" foo bar ");
1554
1570
  // result is " foo bar"
1555
1571
  ```
1556
1572
 
1557
- ### ucfirst
1573
+ #### ucfirst
1558
1574
 
1559
1575
  Make a string's first character uppercase.
1560
1576
 
@@ -1566,7 +1582,7 @@ const result = ucfirst("foo bar");
1566
1582
  // result is "Foo bar"
1567
1583
  ```
1568
1584
 
1569
- ### ucsplit
1585
+ #### ucsplit
1570
1586
 
1571
1587
  Split a string into pieces by uppercase characters.
1572
1588
 
@@ -1578,7 +1594,7 @@ const result = ucsplit("FooBar");
1578
1594
  // result is ["Foo", "Bar"]
1579
1595
  ```
1580
1596
 
1581
- ### ucwords
1597
+ #### ucwords
1582
1598
 
1583
1599
  Uppercase the first letter of each word in a string.
1584
1600
 
@@ -1590,7 +1606,7 @@ const result = ucwords("laravel framework");
1590
1606
  // result is "Laravel Framework"
1591
1607
  ```
1592
1608
 
1593
- ### upper
1609
+ #### upper
1594
1610
 
1595
1611
  Convert the given string to upper-case.
1596
1612
 
@@ -1602,7 +1618,7 @@ const result = upper("laravel");
1602
1618
  // result is "LARAVEL"
1603
1619
  ```
1604
1620
 
1605
- ### ulid
1621
+ #### ulid
1606
1622
 
1607
1623
  Generate a ULID (Universally Unique Lexicographically Sortable Identifier).
1608
1624
 
@@ -1646,7 +1662,7 @@ const result2 = ulid();
1646
1662
  // result is a randomly generated ULID
1647
1663
  ```
1648
1664
 
1649
- ### unwrap
1665
+ #### unwrap
1650
1666
 
1651
1667
  Unwrap the string with the given strings.
1652
1668
 
@@ -1662,7 +1678,7 @@ const result2 = unwrap('{framework: "Laravel"}', "{", "}");
1662
1678
  // result2 is 'framework: "Laravel"'
1663
1679
  ```
1664
1680
 
1665
- ### uuid
1681
+ #### uuid
1666
1682
 
1667
1683
  Generate a UUID (version 4).
1668
1684
 
@@ -1706,7 +1722,7 @@ const result2 = uuid();
1706
1722
  // result is a randomly generated UUID
1707
1723
  ```
1708
1724
 
1709
- ### uuid7
1725
+ #### uuid7
1710
1726
 
1711
1727
  Generate a UUID (version 7).
1712
1728
 
@@ -1722,7 +1738,7 @@ const result = uuid7();
1722
1738
 
1723
1739
  The `uuid7()` function also uses the `createUuidsUsing` and `createUuidsNormally` functions for testing purposes, as described in the `uuid` function above.
1724
1740
 
1725
- ### wordCount
1741
+ #### wordCount
1726
1742
 
1727
1743
  Get the number of words a string contains.
1728
1744
 
@@ -1734,7 +1750,7 @@ const result = wordCount("Hello, world!");
1734
1750
  // result is 2
1735
1751
  ```
1736
1752
 
1737
- ### wordWrap
1753
+ #### wordWrap
1738
1754
 
1739
1755
  Wrap a string to a given number of characters.
1740
1756
 
@@ -1755,7 +1771,7 @@ dog.
1755
1771
  */
1756
1772
  ```
1757
1773
 
1758
- ### words
1774
+ #### words
1759
1775
 
1760
1776
  Limit the number of words in a string.
1761
1777
 
@@ -1767,7 +1783,7 @@ const result = words("Perfectly balanced, as all things should be.", 3, " >>>");
1767
1783
  // result is "Perfectly balanced, as >>>"
1768
1784
  ```
1769
1785
 
1770
- ### wrap
1786
+ #### wrap
1771
1787
 
1772
1788
  Wrap the string with the given strings.
1773
1789
 
@@ -1783,7 +1799,7 @@ const result2 = wrap("is", "This ", " Laravel!");
1783
1799
  // result2 is 'This is Laravel!'
1784
1800
  ```
1785
1801
 
1786
- ### str
1802
+ #### str
1787
1803
 
1788
1804
  Using the `str` or `of` functions is discouraged for frontend projects because it will import the entire `Stringable` class, all of its methods, and all 3rd party dependencies into your final bundle, which may significantly increase its size.
1789
1805
 
@@ -1809,7 +1825,7 @@ const result = str().snake("FooBar");
1809
1825
  // result is a Stringable class instance representing "foo_bar"
1810
1826
  ```
1811
1827
 
1812
- ### of
1828
+ #### of
1813
1829
 
1814
1830
  The `of` function is an alias for the `str` function made for parity with Laravels' `Str::of` method. See the [str](#str) function documentation for details.
1815
1831
 
@@ -1821,9 +1837,9 @@ const result = of("Laravel").upper();
1821
1837
  // result is a Stringable class instance representing "LARAVEL"
1822
1838
  ```
1823
1839
 
1824
- # Tolki Stringable Utilities List
1840
+ ## Tolki Stringable Utilities List
1825
1841
 
1826
- ## Stringable utilities list
1842
+ ### Stringable utilities list
1827
1843
 
1828
1844
  The documentation for fluent string utilities is in the works. In the meantime, I recommend checking out the Laravel documentation for [Fluent strings](https://laravel.com/docs/12.x/strings#fluent-strings-method-list) since the JavaScript utilities are designed to mirror the Laravel ones as closely as possible.
1829
1845