@tolki/str 1.3.0 → 1.5.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.
@@ -1,22 +1,58 @@
1
- import { isInteger as v, isFunction as l } from "@tolki/utils";
2
- import { ascii as c, slug as p } from "../ascii/index.js";
3
- import { toBase64 as d, fromBase64 as f } from "../base64/index.js";
4
- import { convertCase as m, upper as _, title as E } from "../convertcase/index.js";
5
- import { markdown as y, inlineMarkdown as A } from "../markdown/index.js";
6
- import { counted as W, plural as x, pluralStudly as k, pluralPascal as N, singular as U } from "../pluralizer/index.js";
1
+ import { isInteger as v, isFunction as a } from "@tolki/utils";
2
+ import { ascii as p, slug as d } from "../ascii/index.js";
3
+ import { toBase64 as m, fromBase64 as f } from "../base64/index.js";
4
+ import { convertCase as _, upper as E, title as y } from "../convertcase/index.js";
5
+ import { markdown as A, inlineMarkdown as W } from "../markdown/index.js";
6
+ import { counted as x, plural as k, pluralStudly as I, pluralPascal as N, singular as U } from "../pluralizer/index.js";
7
7
  import { substr as C, substrCount as L, substrReplace as M } from "../replacer/index.js";
8
- import { after as F, afterLast as I, before as B, beforeLast as R, between as j, betweenFirst as D, camel as T, charAt as P, chopStart as q, chopEnd as J, contains as V, containsAll as $, doesntContain as z, deduplicate as G, endsWith as X, doesntEndWith as H, excerpt as K, finish as O, is as Q, isAscii as Y, isJson as Z, isUrl as g, kebab as b, length as S, limit as ee, lower as a, mask as te, match as se, isMatch as re, matchAll as ne, numbers as ue, padBoth as ie, padLeft as he, padRight as le, position as ae, remove as oe, reverse as we, repeat as ve, replace as ce, replaceArray as pe, replaceFirst as de, replaceStart as fe, replaceLast as me, replaceEnd as _e, replaceMatches as Ee, squish as ye, start as Ae, stripTags as We, headline as xe, initials as ke, apa as Ne, snake as Ue, startsWith as Ce, doesntStartWith as Le, studly as Me, pascal as Fe, swap as Ie, take as Be, lcfirst as Re, ucfirst as je, ucsplit as De, ucwords as Te, words as Pe, wordCount as qe, wordWrap as Je, wrap as Ve, unwrap as $e } from "../str.js";
8
+ import { after as F, afterLast as R, before as B, beforeLast as j, between as T, betweenFirst as D, camel as q, charAt as O, chopStart as P, chopEnd as $, contains as J, containsAll as V, doesntContain as z, deduplicate as G, endsWith as X, doesntEndWith as H, excerpt as K, finish as Q, is as Y, isAscii as Z, isJson as g, isUrl as b, kebab as S, length as ee, limit as te, lower as o, mask as re, match as se, isMatch as ne, matchAll as ue, numbers as ie, padBoth as he, padLeft as le, padRight as ae, position as oe, remove as we, reverse as ce, repeat as ve, replace as pe, replaceArray as de, replaceFirst as me, replaceStart as fe, replaceLast as _e, replaceEnd as Ee, replaceMatches as ye, squish as Ae, start as We, stripTags as xe, headline as ke, initials as Ie, apa as Ne, snake as Ue, startsWith as Ce, doesntStartWith as Le, studly as Me, pascal as Fe, swap as Re, take as Be, lcfirst as je, ucfirst as Te, ucsplit as De, ucwords as qe, words as Oe, wordCount as Pe, wordWrap as $e, wrap as Je, unwrap as Ve } from "../str.js";
9
9
  import { transliterate as ze } from "../transliterate/index.js";
10
- import { trim as o, ltrim as Ge, rtrim as Xe } from "../trimmer/index.js";
10
+ import { trim as w, ltrim as Ge, rtrim as Xe } from "../trimmer/index.js";
11
11
  import { isUlid as He } from "../ulid/index.js";
12
12
  import { isUuid as Ke } from "../uuid/index.js";
13
- function ut(h = "") {
14
- return new s(h);
13
+ function at(i = "") {
14
+ return new r(i);
15
15
  }
16
- function it(h = "") {
17
- return new s(h);
16
+ function ot(i = "") {
17
+ return new r(i);
18
18
  }
19
- class s {
19
+ function Qe(i, e) {
20
+ const t = l(i, 0), s = t.slice(t.lastIndexOf("/") + 1);
21
+ return e !== "" && s !== e && s.endsWith(e) ? s.slice(0, -e.length) : s;
22
+ }
23
+ function Ye(i, e) {
24
+ if (e < 1)
25
+ throw new RangeError(
26
+ "dirname(): Argument #2 ($levels) must be greater than or equal to 1"
27
+ );
28
+ let t = i;
29
+ for (let s = 0; s < e; s += 1) {
30
+ const n = Ze(t);
31
+ if (n === t)
32
+ return n;
33
+ t = n;
34
+ }
35
+ return t;
36
+ }
37
+ function Ze(i) {
38
+ if (i === "")
39
+ return "";
40
+ const e = l(i, 1);
41
+ if (e === "/")
42
+ return "/";
43
+ const t = e.lastIndexOf("/");
44
+ if (t === -1)
45
+ return ".";
46
+ const s = l(e.slice(0, t), 1);
47
+ return s === "" ? "/" : s;
48
+ }
49
+ function l(i, e) {
50
+ let t = i.length;
51
+ for (; t > e && i[t - 1] === "/"; )
52
+ t -= 1;
53
+ return i.slice(0, t);
54
+ }
55
+ class r {
20
56
  /**
21
57
  * Create a new instance of the class.
22
58
  *
@@ -33,7 +69,7 @@ class s {
33
69
  * @returns The portion of the string after the first occurrence of the search value.
34
70
  */
35
71
  after(e) {
36
- return new s(F(this._value, e));
72
+ return new r(F(this._value, e));
37
73
  }
38
74
  /**
39
75
  * Return the remainder of a string after the last occurrence of a given value
@@ -42,7 +78,7 @@ class s {
42
78
  * @returns The portion of the string after the last occurrence of the search value.
43
79
  */
44
80
  afterLast(e) {
45
- return new s(I(this._value, e));
81
+ return new r(R(this._value, e));
46
82
  }
47
83
  /**
48
84
  * Append the given values to the string.
@@ -51,7 +87,7 @@ class s {
51
87
  * @returns The updated Stringable instance.
52
88
  */
53
89
  append(...e) {
54
- return new s(this._value + e.map(String).join(""));
90
+ return new r(this._value + e.map(String).join(""));
55
91
  }
56
92
  /**
57
93
  * Append a new line to the string.
@@ -69,7 +105,16 @@ class s {
69
105
  * @returns The transliterated string as a new Stringable instance.
70
106
  */
71
107
  ascii() {
72
- return new s(c(this._value));
108
+ return new r(p(this._value));
109
+ }
110
+ /**
111
+ * Get the trailing name component of the path.
112
+ *
113
+ * @param suffix - Removed from the end of the name unless it is the whole name.
114
+ * @returns The trailing name component as a new Stringable instance.
115
+ */
116
+ basename(e = "") {
117
+ return new r(Qe(this._value, e));
73
118
  }
74
119
  /**
75
120
  * Get the portion of a string before the first occurrence of a given value.
@@ -78,7 +123,7 @@ class s {
78
123
  * @returns The portion of the string before the first occurrence of the search value.
79
124
  */
80
125
  before(e) {
81
- return new s(B(this._value, e));
126
+ return new r(B(this._value, e));
82
127
  }
83
128
  /**
84
129
  * Get the portion of a string before the last occurrence of a given value.
@@ -87,7 +132,7 @@ class s {
87
132
  * @returns The portion of the string before the last occurrence of the search value.
88
133
  */
89
134
  beforeLast(e) {
90
- return new s(R(this._value, e));
135
+ return new r(j(this._value, e));
91
136
  }
92
137
  /**
93
138
  * Get the portion of a string between two given values.
@@ -97,7 +142,7 @@ class s {
97
142
  * @returns The portion of the string between the two given values.
98
143
  */
99
144
  between(e, t) {
100
- return new s(j(this._value, e, t));
145
+ return new r(T(this._value, e, t));
101
146
  }
102
147
  /**
103
148
  * Get the smallest possible portion of a string between two given values.
@@ -107,7 +152,7 @@ class s {
107
152
  * @returns The smallest possible portion of the string between the two given values.
108
153
  */
109
154
  betweenFirst(e, t) {
110
- return new s(D(this._value, e, t));
155
+ return new r(D(this._value, e, t));
111
156
  }
112
157
  /**
113
158
  * Convert a value to camel case.
@@ -115,7 +160,7 @@ class s {
115
160
  * @returns The camel-cased string as a new Stringable instance.
116
161
  */
117
162
  camel() {
118
- return new s(T(this._value));
163
+ return new r(q(this._value));
119
164
  }
120
165
  /**
121
166
  * Get the character at the specified index.
@@ -124,7 +169,7 @@ class s {
124
169
  * @returns The character at the specified index, or false if the index is out of bounds.
125
170
  */
126
171
  charAt(e) {
127
- return P(this._value, e);
172
+ return O(this._value, e);
128
173
  }
129
174
  /**
130
175
  * Remove the given string if it exists at the start of the current string.
@@ -133,7 +178,7 @@ class s {
133
178
  * @returns The updated Stringable instance.
134
179
  */
135
180
  chopStart(e) {
136
- return new s(q(this._value, e));
181
+ return new r(P(this._value, e));
137
182
  }
138
183
  /**
139
184
  * Remove the given string if it exists at the end of the current string.
@@ -142,7 +187,7 @@ class s {
142
187
  * @returns The updated Stringable instance.
143
188
  */
144
189
  chopEnd(e) {
145
- return new s(J(this._value, e));
190
+ return new r($(this._value, e));
146
191
  }
147
192
  /**
148
193
  * Determine if a given string contains a given substring.
@@ -152,7 +197,7 @@ class s {
152
197
  * @returns boolean - True if the substring(s) are found, false otherwise
153
198
  */
154
199
  contains(e, t = !1) {
155
- return V(this._value, e, t);
200
+ return J(this._value, e, t);
156
201
  }
157
202
  /**
158
203
  * Determine if a given string contains all array values.
@@ -162,7 +207,7 @@ class s {
162
207
  * @returns boolean - True if all substring(s) are found, false otherwise
163
208
  */
164
209
  containsAll(e, t = !1) {
165
- return $(this._value, e, t);
210
+ return V(this._value, e, t);
166
211
  }
167
212
  /**
168
213
  * Determine if a given string doesn't contain a given substring.
@@ -181,7 +226,7 @@ class s {
181
226
  * @returns The converted string as a new Stringable instance.
182
227
  */
183
228
  convertCase(e) {
184
- return new s(m(this._value, e));
229
+ return new r(_(this._value, e));
185
230
  }
186
231
  /**
187
232
  * Get the plural form of an English word with the count prepended.
@@ -190,7 +235,7 @@ class s {
190
235
  * @returns The pluralized string with the formatted count prepended, as a new Stringable instance.
191
236
  */
192
237
  counted(e) {
193
- return new s(W(this._value, e));
238
+ return new r(x(this._value, e));
194
239
  }
195
240
  /**
196
241
  * Replace consecutive instances of a given character with a single character.
@@ -199,7 +244,16 @@ class s {
199
244
  * @returns The updated Stringable instance.
200
245
  */
201
246
  deduplicate(e = " ") {
202
- return new s(G(this._value, e));
247
+ return new r(G(this._value, e));
248
+ }
249
+ /**
250
+ * Get the parent directory's path.
251
+ *
252
+ * @param levels - How many parent directories to go up. Defaults to 1.
253
+ * @returns The parent directory's path as a new Stringable instance.
254
+ */
255
+ dirname(e = 1) {
256
+ return new r(Ye(this._value, e));
203
257
  }
204
258
  /**
205
259
  * Determine if a given string ends with a given substring.
@@ -226,7 +280,7 @@ class s {
226
280
  * @returns True if the strings are exactly the same, false otherwise.
227
281
  */
228
282
  exactly(e) {
229
- const t = e instanceof s ? e.toString() : String(e);
283
+ const t = e instanceof r ? e.toString() : String(e);
230
284
  return this._value === t;
231
285
  }
232
286
  /**
@@ -247,13 +301,13 @@ class s {
247
301
  * @returns An array of strings obtained by splitting the original string.
248
302
  */
249
303
  explode(e, t = Number.MAX_SAFE_INTEGER) {
250
- const r = this._value.split(e);
251
- if (t > 0 && r.length > t) {
252
- const n = r.slice(0, t - 1);
253
- return n.push(r.slice(t - 1).join(e)), n;
304
+ const s = this._value.split(e);
305
+ if (t > 0 && s.length > t) {
306
+ const n = s.slice(0, t - 1);
307
+ return n.push(s.slice(t - 1).join(e)), n;
254
308
  } else if (t < 0)
255
- return r.slice(0, t);
256
- return r;
309
+ return s.slice(0, t);
310
+ return s;
257
311
  }
258
312
  /**
259
313
  * Split a string using a regular expression or by length.
@@ -264,10 +318,10 @@ class s {
264
318
  */
265
319
  split(e, t = null) {
266
320
  if (v(e)) {
267
- const n = Number(e), i = [];
321
+ const n = Number(e), h = [];
268
322
  for (let u = 0; u < this._value.length; u += n)
269
- i.push(this._value.substr(u, n));
270
- return i;
323
+ h.push(this._value.substr(u, n));
324
+ return h;
271
325
  }
272
326
  return this._value.split(
273
327
  new RegExp(String(e)),
@@ -281,7 +335,7 @@ class s {
281
335
  * @returns The updated Stringable instance.
282
336
  */
283
337
  finish(e) {
284
- return new s(O(this._value, e));
338
+ return new r(Q(this._value, e));
285
339
  }
286
340
  /**
287
341
  * Determine if a given string matches a given pattern.
@@ -290,7 +344,7 @@ class s {
290
344
  * @returns boolean - True if the pattern(s) match, false otherwise
291
345
  */
292
346
  is(e, t = !1) {
293
- return Q(e, this._value, t);
347
+ return Y(e, this._value, t);
294
348
  }
295
349
  /**
296
350
  * Determine if a given string is 7 bit ASCII.
@@ -298,7 +352,7 @@ class s {
298
352
  * @returns True if the string is ASCII, false otherwise.
299
353
  */
300
354
  isAscii() {
301
- return Y(this._value);
355
+ return Z(this._value);
302
356
  }
303
357
  /**
304
358
  * Determine if a given string is valid JSON.
@@ -306,7 +360,7 @@ class s {
306
360
  * @returns True if the string is valid JSON, false otherwise.
307
361
  */
308
362
  isJson() {
309
- return Z(this._value);
363
+ return g(this._value);
310
364
  }
311
365
  /**
312
366
  * Determine if a given value is a valid URL.
@@ -315,7 +369,7 @@ class s {
315
369
  * @returns True if the string is a valid URL, false otherwise.
316
370
  */
317
371
  isUrl(e = []) {
318
- return g(this._value, e);
372
+ return b(this._value, e);
319
373
  }
320
374
  /**
321
375
  * Determine if a given string is a valid UUID.
@@ -356,7 +410,7 @@ class s {
356
410
  * @returns The kebab-cased string as a new Stringable instance.
357
411
  */
358
412
  kebab() {
359
- return new s(b(this._value));
413
+ return new r(S(this._value));
360
414
  }
361
415
  /**
362
416
  * Return the length of the given string.
@@ -364,7 +418,7 @@ class s {
364
418
  * @returns The length of the string.
365
419
  */
366
420
  length() {
367
- return S(this._value);
421
+ return ee(this._value);
368
422
  }
369
423
  /**
370
424
  * Limit the number of characters in a string.
@@ -374,9 +428,9 @@ class s {
374
428
  * @param preserveWords - Whether to avoid cutting off in the middle of a word.
375
429
  * @returns A new Stringable instance with the limited string.
376
430
  */
377
- limit(e = 100, t = "...", r = !1) {
378
- return new s(
379
- ee(this._value, e, t, r)
431
+ limit(e = 100, t = "...", s = !1) {
432
+ return new r(
433
+ te(this._value, e, t, s)
380
434
  );
381
435
  }
382
436
  /**
@@ -385,7 +439,7 @@ class s {
385
439
  * @returns The lower-cased string as a new Stringable instance.
386
440
  */
387
441
  lower() {
388
- return new s(a(this._value));
442
+ return new r(o(this._value));
389
443
  }
390
444
  /**
391
445
  * Convert GitHub flavored Markdown into HTML.
@@ -395,7 +449,7 @@ class s {
395
449
  * @returns The resulting HTML string as a new Stringable instance.
396
450
  */
397
451
  markdown(e = { gfm: !0, anchors: !1 }, t = []) {
398
- return new s(y(this._value, e, t));
452
+ return new r(A(this._value, e, t));
399
453
  }
400
454
  /**
401
455
  * Convert inline Markdown into HTML.
@@ -405,7 +459,7 @@ class s {
405
459
  * @returns The resulting HTML string as a new Stringable instance.
406
460
  */
407
461
  inlineMarkdown(e = { gfm: !0 }, t = []) {
408
- return new s(A(this._value, e, t));
462
+ return new r(W(this._value, e, t));
409
463
  }
410
464
  /**
411
465
  * Masks a portion of a string with a repeated character.
@@ -415,8 +469,8 @@ class s {
415
469
  * @param length - The number of characters to mask. If null, masks to the end of the string.
416
470
  * @returns The masked string as a new Stringable instance.
417
471
  */
418
- mask(e, t, r = null) {
419
- return new s(te(this._value, e, t, r));
472
+ mask(e, t, s = null) {
473
+ return new r(re(this._value, e, t, s));
420
474
  }
421
475
  /**
422
476
  * Get the string matching the given pattern.
@@ -425,7 +479,7 @@ class s {
425
479
  * @returns A new Stringable instance containing the matched string.
426
480
  */
427
481
  match(e) {
428
- return new s(se(e, this._value));
482
+ return new r(se(e, this._value));
429
483
  }
430
484
  /**
431
485
  * Determine if a given string matches a given pattern.
@@ -434,7 +488,7 @@ class s {
434
488
  * @returns boolean - True if the pattern(s) match, false otherwise
435
489
  */
436
490
  isMatch(e) {
437
- return re(e, this._value);
491
+ return ne(e, this._value);
438
492
  }
439
493
  /**
440
494
  * Get the string matching the given pattern.
@@ -443,7 +497,7 @@ class s {
443
497
  * @returns An array of all matched strings.
444
498
  */
445
499
  matchAll(e) {
446
- return ne(e, this._value);
500
+ return ue(e, this._value);
447
501
  }
448
502
  /**
449
503
  * Determine if the string matches the given pattern.
@@ -460,7 +514,7 @@ class s {
460
514
  * @returns The numeric string as a new Stringable instance.
461
515
  */
462
516
  numbers() {
463
- return new s(ue(this._value));
517
+ return new r(ie(this._value));
464
518
  }
465
519
  /**
466
520
  * Pad both sides of the string with another.
@@ -470,7 +524,7 @@ class s {
470
524
  * @returns The padded string as a new Stringable instance.
471
525
  */
472
526
  padBoth(e, t = " ") {
473
- return new s(ie(this._value, e, t));
527
+ return new r(he(this._value, e, t));
474
528
  }
475
529
  /**
476
530
  * Pad the left side of the string with another.
@@ -480,7 +534,7 @@ class s {
480
534
  * @returns The padded string as a new Stringable instance.
481
535
  */
482
536
  padLeft(e, t = " ") {
483
- return new s(he(this._value, e, t));
537
+ return new r(le(this._value, e, t));
484
538
  }
485
539
  /**
486
540
  * Pad the right side of the string with another.
@@ -490,7 +544,7 @@ class s {
490
544
  * @returns The padded string as a new Stringable instance.
491
545
  */
492
546
  padRight(e, t = " ") {
493
- return new s(le(this._value, e, t));
547
+ return new r(ae(this._value, e, t));
494
548
  }
495
549
  /**
496
550
  * Call the given callback and return a new string.
@@ -500,7 +554,7 @@ class s {
500
554
  */
501
555
  pipe(e) {
502
556
  const t = e(this);
503
- return t instanceof s ? t : new s(String(t));
557
+ return t instanceof r ? t : new r(String(t));
504
558
  }
505
559
  /**
506
560
  * Get the plural form of an English word.
@@ -510,7 +564,7 @@ class s {
510
564
  * @returns The pluralized string as a new Stringable instance.
511
565
  */
512
566
  plural(e = 2, t = !1) {
513
- return new s(x(this._value, e, t));
567
+ return new r(k(this._value, e, t));
514
568
  }
515
569
  /**
516
570
  * Pluralize the last word of an English, studly caps case string.
@@ -519,7 +573,7 @@ class s {
519
573
  * @returns The pluralized string as a new Stringable instance.
520
574
  */
521
575
  pluralStudly(e = 2) {
522
- return new s(k(this._value, e));
576
+ return new r(I(this._value, e));
523
577
  }
524
578
  /**
525
579
  * Pluralize the last word of an English, Pascal caps case string.
@@ -528,7 +582,7 @@ class s {
528
582
  * @returns The pluralized string as a new Stringable instance.
529
583
  */
530
584
  pluralPascal(e = 2) {
531
- return new s(N(this._value, e));
585
+ return new r(N(this._value, e));
532
586
  }
533
587
  /**
534
588
  * Find the multi-byte safe position of the first occurrence of the given substring.
@@ -538,7 +592,7 @@ class s {
538
592
  * @returns The position of the first occurrence of the substring, or false if not found.
539
593
  */
540
594
  position(e, t = 0) {
541
- return ae(this._value, e, t);
595
+ return oe(this._value, e, t);
542
596
  }
543
597
  /**
544
598
  * Prepend the given values to the string.
@@ -547,7 +601,7 @@ class s {
547
601
  * @returns The updated Stringable instance.
548
602
  */
549
603
  prepend(...e) {
550
- return new s(e.map(String).join("") + this._value);
604
+ return new r(e.map(String).join("") + this._value);
551
605
  }
552
606
  /**
553
607
  * Remove any occurrence of the given string in the subject.
@@ -557,8 +611,8 @@ class s {
557
611
  * @returns The updated Stringable instance.
558
612
  */
559
613
  remove(e, t = !0) {
560
- return new s(
561
- oe(e, this._value, t)
614
+ return new r(
615
+ we(e, this._value, t)
562
616
  );
563
617
  }
564
618
  /**
@@ -567,7 +621,7 @@ class s {
567
621
  * @returns The reversed string as a new Stringable instance.
568
622
  */
569
623
  reverse() {
570
- return new s(we(this._value));
624
+ return new r(ce(this._value));
571
625
  }
572
626
  /**
573
627
  * Repeat the string.
@@ -576,7 +630,7 @@ class s {
576
630
  * @returns The repeated string as a new Stringable instance.
577
631
  */
578
632
  repeat(e) {
579
- return new s(ve(this._value, e));
633
+ return new r(ve(this._value, e));
580
634
  }
581
635
  /**
582
636
  * Replace the given value in the given string.
@@ -586,9 +640,9 @@ class s {
586
640
  * @param caseSensitive - Whether the search should be case-sensitive. Defaults to true.
587
641
  * @returns The updated Stringable instance.
588
642
  */
589
- replace(e, t, r = !0) {
590
- return new s(
591
- ce(e, t, this._value, r)
643
+ replace(e, t, s = !0) {
644
+ return new r(
645
+ pe(e, t, this._value, s)
592
646
  );
593
647
  }
594
648
  /**
@@ -599,7 +653,7 @@ class s {
599
653
  * @returns The updated Stringable instance.
600
654
  */
601
655
  replaceArray(e, t) {
602
- return new s(pe(e, t, this._value));
656
+ return new r(de(e, t, this._value));
603
657
  }
604
658
  /**
605
659
  * Replace the first occurrence of a given value in the string.
@@ -609,7 +663,7 @@ class s {
609
663
  * @returns The updated Stringable instance.
610
664
  */
611
665
  replaceFirst(e, t) {
612
- return new s(de(e, t, this._value));
666
+ return new r(me(e, t, this._value));
613
667
  }
614
668
  /**
615
669
  * Replace the first occurrence of the given value if it appears at the start of the string.
@@ -619,7 +673,7 @@ class s {
619
673
  * @returns The updated Stringable instance.
620
674
  */
621
675
  replaceStart(e, t) {
622
- return new s(fe(e, t, this._value));
676
+ return new r(fe(e, t, this._value));
623
677
  }
624
678
  /**
625
679
  * Replace the last occurrence of a given value in the string.
@@ -629,7 +683,7 @@ class s {
629
683
  * @returns The updated Stringable instance.
630
684
  */
631
685
  replaceLast(e, t) {
632
- return new s(me(e, t, this._value));
686
+ return new r(_e(e, t, this._value));
633
687
  }
634
688
  /**
635
689
  * Replace the last occurrence of a given value if it appears at the end of the string.
@@ -639,7 +693,7 @@ class s {
639
693
  * @returns The updated Stringable instance.
640
694
  */
641
695
  replaceEnd(e, t) {
642
- return new s(_e(e, t, this._value));
696
+ return new r(Ee(e, t, this._value));
643
697
  }
644
698
  /**
645
699
  * Replace the patterns matching the given regular expression.
@@ -649,9 +703,9 @@ class s {
649
703
  * @param limit - The maximum number of replacements to perform. Defaults to -1 (no limit).
650
704
  * @returns The updated Stringable instance.
651
705
  */
652
- replaceMatches(e, t, r = -1) {
653
- const n = Ee(e, t, this._value, r);
654
- return new s(n);
706
+ replaceMatches(e, t, s = -1) {
707
+ const n = ye(e, t, this._value, s);
708
+ return new r(n);
655
709
  }
656
710
  /**
657
711
  * Parse input from a string to an array, according to a format.
@@ -666,22 +720,22 @@ class s {
666
720
  * Str.of("filename.jpg").scan("%[^.].%s") -> ["filename", "jpg"]
667
721
  */
668
722
  scan(e) {
669
- let t = "", r = 0;
670
- for (; r < e.length; )
671
- if (e[r] === "%")
672
- if (e[r + 1] === "[") {
673
- let u = r + 2;
723
+ let t = "", s = 0;
724
+ for (; s < e.length; )
725
+ if (e[s] === "%")
726
+ if (e[s + 1] === "[") {
727
+ let u = s + 2;
674
728
  for (; u < e.length && e[u] !== "]"; )
675
729
  u++;
676
- const w = e.substring(r + 2, u);
677
- t += "([" + w + "]+)", r = u + 1;
678
- } else e[r + 1] === "d" ? (t += "\\s*(-?\\d+)", r += 2) : e[r + 1] === "s" ? (t += "\\s*(\\S+)", r += 2) : (t += e[r], r++);
730
+ const c = e.substring(s + 2, u);
731
+ t += "([" + c + "]+)", s = u + 1;
732
+ } else e[s + 1] === "d" ? (t += "\\s*(-?\\d+)", s += 2) : e[s + 1] === "s" ? (t += "\\s*(\\S+)", s += 2) : (t += e[s], s++);
679
733
  else {
680
- const u = e[r];
681
- u && /[.+?^${}()|\\]/.test(u) ? t += "\\" + u : t += u, r++;
734
+ const u = e[s];
735
+ u && /[.+?^${}()|\\]/.test(u) ? t += "\\" + u : t += u, s++;
682
736
  }
683
- const n = new RegExp("^" + t + "$"), i = this._value.match(n);
684
- return i ? i.slice(1).filter((u) => u !== void 0) : [];
737
+ const n = new RegExp("^" + t + "$"), h = this._value.match(n);
738
+ return h ? h.slice(1).filter((u) => u !== void 0) : [];
685
739
  }
686
740
  /**
687
741
  * Remove all "extra" blank space from the given string.
@@ -689,7 +743,7 @@ class s {
689
743
  * @returns The updated Stringable instance.
690
744
  */
691
745
  squish() {
692
- return new s(ye(this._value));
746
+ return new r(Ae(this._value));
693
747
  }
694
748
  /**
695
749
  * Begin a string with a single instance of a given value.
@@ -698,7 +752,7 @@ class s {
698
752
  * @returns The updated Stringable instance.
699
753
  */
700
754
  start(e) {
701
- return new s(Ae(this._value, e));
755
+ return new r(We(this._value, e));
702
756
  }
703
757
  /**
704
758
  * Strip HTML and PHP tags from the given string.
@@ -706,7 +760,7 @@ class s {
706
760
  * @returns The updated Stringable instance.
707
761
  */
708
762
  stripTags() {
709
- return new s(We(this._value));
763
+ return new r(xe(this._value));
710
764
  }
711
765
  /**
712
766
  * Convert the given string to upper-case.
@@ -714,7 +768,7 @@ class s {
714
768
  * @returns The upper-cased string as a new Stringable instance.
715
769
  */
716
770
  upper() {
717
- return new s(_(this._value));
771
+ return new r(E(this._value));
718
772
  }
719
773
  /**
720
774
  * Convert the given string to proper case.
@@ -722,7 +776,7 @@ class s {
722
776
  * @returns The title-cased string as a new Stringable instance.
723
777
  */
724
778
  title() {
725
- return new s(E(this._value));
779
+ return new r(y(this._value));
726
780
  }
727
781
  /**
728
782
  * Convert the given string to proper case for each word.
@@ -730,7 +784,7 @@ class s {
730
784
  * @returns The headline-cased string as a new Stringable instance.
731
785
  */
732
786
  headline() {
733
- return new s(xe(this._value));
787
+ return new r(ke(this._value));
734
788
  }
735
789
  /**
736
790
  * Convert the given string to only its initials.
@@ -739,7 +793,7 @@ class s {
739
793
  * @returns The initials of the string as a new Stringable instance.
740
794
  */
741
795
  initials(e = !1) {
742
- return new s(ke(this._value, e));
796
+ return new r(Ie(this._value, e));
743
797
  }
744
798
  /**
745
799
  * Convert the given string to APA-style title case.
@@ -747,7 +801,7 @@ class s {
747
801
  * @returns The APA title-cased string as a new Stringable instance.
748
802
  */
749
803
  apa() {
750
- return new s(Ne(this._value));
804
+ return new r(Ne(this._value));
751
805
  }
752
806
  /**
753
807
  * Transliterate a string to its closest ASCII representation.
@@ -755,7 +809,7 @@ class s {
755
809
  * @returns The transliterated string as a new Stringable instance.
756
810
  */
757
811
  transliterate() {
758
- return new s(ze(this._value));
812
+ return new r(ze(this._value));
759
813
  }
760
814
  /**
761
815
  * Get the singular form of an English word.
@@ -763,7 +817,7 @@ class s {
763
817
  * @returns The singularized string as a new Stringable instance.
764
818
  */
765
819
  singular() {
766
- return new s(U(this._value));
820
+ return new r(U(this._value));
767
821
  }
768
822
  /**
769
823
  * Generate a URL friendly "slug" from a given string.
@@ -773,7 +827,7 @@ class s {
773
827
  * @returns The slugified string as a new Stringable instance.
774
828
  */
775
829
  slug(e = "-", t = { "@": "at" }) {
776
- return new s(p(this._value, e, t));
830
+ return new r(d(this._value, e, t));
777
831
  }
778
832
  /**
779
833
  * Convert a string to snake case.
@@ -782,7 +836,7 @@ class s {
782
836
  * @returns The snake-cased string as a new Stringable instance.
783
837
  */
784
838
  snake(e = "_") {
785
- return new s(Ue(this._value, e));
839
+ return new r(Ue(this._value, e));
786
840
  }
787
841
  /**
788
842
  * Determine if a given string starts with a given substring.
@@ -809,7 +863,7 @@ class s {
809
863
  * @returns The studly-cased string as a new Stringable instance.
810
864
  */
811
865
  studly(e = !1) {
812
- return new s(Me(this._value, e));
866
+ return new r(Me(this._value, e));
813
867
  }
814
868
  /**
815
869
  * Convert the string to Pascal case.
@@ -818,7 +872,7 @@ class s {
818
872
  * @returns The pascal-cased string as a new Stringable instance.
819
873
  */
820
874
  pascal(e = !1) {
821
- return new s(Fe(this._value, e));
875
+ return new r(Fe(this._value, e));
822
876
  }
823
877
  /**
824
878
  * Returns the portion of the string specified by the start and length parameters.
@@ -828,7 +882,7 @@ class s {
828
882
  * @returns The extracted substring as a new Stringable instance.
829
883
  */
830
884
  substr(e, t = null) {
831
- return new s(C(this._value, e, t));
885
+ return new r(C(this._value, e, t));
832
886
  }
833
887
  /**
834
888
  * Returns the number of substring occurrences.
@@ -838,20 +892,20 @@ class s {
838
892
  * @param length - The length of the string to search within. If null, searches to the end of the string.
839
893
  * @returns The number of occurrences of the substring.
840
894
  */
841
- substrCount(e, t = 0, r = null) {
842
- return L(this._value, e, t, r);
895
+ substrCount(e, t = 0, s = null) {
896
+ return L(this._value, e, t, s);
843
897
  }
844
898
  /**
845
899
  * Replace text within a portion of a string.
846
900
  *
847
- * @param replace - The replacement string.
848
- * @param offset - The starting position to begin replacing.
849
- * @param length - The number of characters to replace. If null, replaces to the end of the string.
901
+ * @param replace - The replacement string, or an array of replacements from which the first value is used.
902
+ * @param offset - The starting position to begin replacing. If negative, it starts that many characters from the end of the string.
903
+ * @param length - The number of characters to replace. If null, replaces to the end of the string. If negative, omits that many characters from the end.
850
904
  * @returns The updated Stringable instance.
851
905
  */
852
- substrReplace(e, t = 0, r = null) {
853
- return new s(
854
- M(this._value, e, t, r)
906
+ substrReplace(e, t = 0, s = null) {
907
+ return new r(
908
+ M(this._value, e, t, s)
855
909
  );
856
910
  }
857
911
  /**
@@ -861,7 +915,7 @@ class s {
861
915
  * @returns The updated Stringable instance.
862
916
  */
863
917
  swap(e) {
864
- return new s(Ie(e, this._value));
918
+ return new r(Re(e, this._value));
865
919
  }
866
920
  /**
867
921
  * Take the first or last {$limit} characters.
@@ -870,7 +924,7 @@ class s {
870
924
  * @returns The resulting substring as a new Stringable instance.
871
925
  */
872
926
  take(e) {
873
- return new s(Be(this._value, e));
927
+ return new r(Be(this._value, e));
874
928
  }
875
929
  /**
876
930
  * Trim the string of the given characters.
@@ -879,7 +933,7 @@ class s {
879
933
  * @returns The trimmed string as a new Stringable instance.
880
934
  */
881
935
  trim(e = null) {
882
- return new s(o(this._value, e));
936
+ return new r(w(this._value, e));
883
937
  }
884
938
  /**
885
939
  * Left trim the string of the given characters.
@@ -888,7 +942,7 @@ class s {
888
942
  * @returns The left-trimmed string as a new Stringable instance.
889
943
  */
890
944
  ltrim(e = null) {
891
- return new s(Ge(this._value, e));
945
+ return new r(Ge(this._value, e));
892
946
  }
893
947
  /**
894
948
  * Right trim the string of the given characters.
@@ -897,7 +951,7 @@ class s {
897
951
  * @returns The right-trimmed string as a new Stringable instance.
898
952
  */
899
953
  rtrim(e = null) {
900
- return new s(Xe(this._value, e));
954
+ return new r(Xe(this._value, e));
901
955
  }
902
956
  /**
903
957
  * Make a string's first character lowercase.
@@ -905,7 +959,7 @@ class s {
905
959
  * @returns The updated Stringable instance.
906
960
  */
907
961
  lcfirst() {
908
- return new s(Re(this._value));
962
+ return new r(je(this._value));
909
963
  }
910
964
  /**
911
965
  * Make a string's first character uppercase.
@@ -913,7 +967,7 @@ class s {
913
967
  * @returns The updated Stringable instance.
914
968
  */
915
969
  ucfirst() {
916
- return new s(je(this._value));
970
+ return new r(Te(this._value));
917
971
  }
918
972
  /**
919
973
  * Split a string by uppercase characters.
@@ -929,7 +983,7 @@ class s {
929
983
  * @returns The updated Stringable instance.
930
984
  */
931
985
  ucwords() {
932
- return new s(Te(this._value));
986
+ return new r(qe(this._value));
933
987
  }
934
988
  /**
935
989
  * Apply the callback if the given "value" is (or resolves to) truthy.
@@ -953,9 +1007,9 @@ class s {
953
1007
  * str.when(s => s.contains('foo'), s => s.upper(), s => s.lower()); // Returns 'hello world'
954
1008
  * ```
955
1009
  */
956
- when(e, t = null, r = null) {
957
- const n = l(e) ? e(this) : e;
958
- return n ? t?.(this, n) ?? this : r ? r(this, n) ?? this : this;
1010
+ when(e, t = null, s = null) {
1011
+ const n = a(e) ? e(this) : e;
1012
+ return n ? t?.(this, n) ?? this : s ? s(this, n) ?? this : this;
959
1013
  }
960
1014
  /**
961
1015
  * Apply the callback if the given "value" is (or resolves to) falsy.
@@ -971,11 +1025,11 @@ class s {
971
1025
  * str.unless(true, s => s.upper()); // Returns 'hello world'
972
1026
  * str.unless(false, s => s.upper(), s => s.lower()); // Returns 'HELLO WORLD'
973
1027
  */
974
- unless(e, t = null, r = null) {
975
- const n = l(e) ? e(this) : e;
1028
+ unless(e, t = null, s = null) {
1029
+ const n = a(e) ? e(this) : e;
976
1030
  if (n) {
977
- if (r)
978
- return r(this, n) ?? this;
1031
+ if (s)
1032
+ return s(this, n) ?? this;
979
1033
  } else return t?.(this, n) ?? this;
980
1034
  return this;
981
1035
  }
@@ -987,8 +1041,8 @@ class s {
987
1041
  * @param defaultCallback - The callback to execute if the substring(s) are not found
988
1042
  * @returns Stringable - The current instance or the result of the callback
989
1043
  */
990
- whenContains(e, t, r = null) {
991
- return this.when(this.contains(e), t, r);
1044
+ whenContains(e, t, s = null) {
1045
+ return this.when(this.contains(e), t, s);
992
1046
  }
993
1047
  /**
994
1048
  * Execute the given callback if the string contains all array values.
@@ -998,8 +1052,8 @@ class s {
998
1052
  * @param defaultCallback - The callback to execute if not all substring(s) are found
999
1053
  * @returns Stringable - The current instance or the result of the callback
1000
1054
  */
1001
- whenContainsAll(e, t, r = null) {
1002
- return this.when(this.containsAll(e), t, r);
1055
+ whenContainsAll(e, t, s = null) {
1056
+ return this.when(this.containsAll(e), t, s);
1003
1057
  }
1004
1058
  /**
1005
1059
  * Execute the given callback if the string is empty.
@@ -1029,8 +1083,8 @@ class s {
1029
1083
  * @param defaultCallback - The callback to execute if the substring(s) are not found
1030
1084
  * @returns Stringable - The current instance or the result of the callback
1031
1085
  */
1032
- whenEndsWith(e, t, r = null) {
1033
- return this.when(this.endsWith(e), t, r);
1086
+ whenEndsWith(e, t, s = null) {
1087
+ return this.when(this.endsWith(e), t, s);
1034
1088
  }
1035
1089
  /**
1036
1090
  * Execute the given callback if the string doesn't end with a given substring.
@@ -1040,11 +1094,11 @@ class s {
1040
1094
  * @param defaultCallback - The callback to execute if the substring(s) are found
1041
1095
  * @returns Stringable - The current instance or the result of the callback
1042
1096
  */
1043
- whenDoesntEndWith(e, t, r = null) {
1097
+ whenDoesntEndWith(e, t, s = null) {
1044
1098
  return this.when(
1045
1099
  this.doesntEndWith(e),
1046
1100
  t,
1047
- r
1101
+ s
1048
1102
  );
1049
1103
  }
1050
1104
  /**
@@ -1055,8 +1109,8 @@ class s {
1055
1109
  * @param defaultCallback - The callback to execute if the string does not match the value
1056
1110
  * @returns Stringable - The current instance or the result of the callback
1057
1111
  */
1058
- whenExactly(e, t, r = null) {
1059
- return this.when(this.exactly(e), t, r);
1112
+ whenExactly(e, t, s = null) {
1113
+ return this.when(this.exactly(e), t, s);
1060
1114
  }
1061
1115
  /**
1062
1116
  * Execute the given callback if the string is not an exact match with the given value.
@@ -1066,8 +1120,8 @@ class s {
1066
1120
  * @param defaultCallback - The callback to execute if the string matches the value
1067
1121
  * @returns Stringable - The current instance or the result of the callback
1068
1122
  */
1069
- whenNotExactly(e, t, r = null) {
1070
- return this.when(!this.exactly(e), t, r);
1123
+ whenNotExactly(e, t, s = null) {
1124
+ return this.when(!this.exactly(e), t, s);
1071
1125
  }
1072
1126
  /**
1073
1127
  * Execute the given callback if the string matches a given pattern.
@@ -1077,8 +1131,8 @@ class s {
1077
1131
  * @param defaultCallback - The callback to execute if the pattern(s) do not match
1078
1132
  * @returns Stringable - The current instance or the result of the callback
1079
1133
  */
1080
- whenIs(e, t, r = null) {
1081
- return this.when(this.is(e), t, r);
1134
+ whenIs(e, t, s = null) {
1135
+ return this.when(this.is(e), t, s);
1082
1136
  }
1083
1137
  /**
1084
1138
  * Execute the given callback if the string is 7 bit ASCII.
@@ -1118,8 +1172,8 @@ class s {
1118
1172
  * @param defaultCallback - The callback to execute if the substring(s) are not found
1119
1173
  * @returns Stringable - The current instance or the result of the callback
1120
1174
  */
1121
- whenStartsWith(e, t, r = null) {
1122
- return this.when(this.startsWith(e), t, r);
1175
+ whenStartsWith(e, t, s = null) {
1176
+ return this.when(this.startsWith(e), t, s);
1123
1177
  }
1124
1178
  /**
1125
1179
  * Execute the given callback if the string matches the given pattern.
@@ -1129,8 +1183,8 @@ class s {
1129
1183
  * @param defaultCallback - The callback to execute if the pattern(s) do not match
1130
1184
  * @returns Stringable - The current instance or the result of the callback
1131
1185
  */
1132
- whenTest(e, t, r = null) {
1133
- return this.when(this.test(e), t, r);
1186
+ whenTest(e, t, s = null) {
1187
+ return this.when(this.test(e), t, s);
1134
1188
  }
1135
1189
  /**
1136
1190
  * Limit the number of words in a string.
@@ -1140,7 +1194,7 @@ class s {
1140
1194
  * @returns The truncated string as a new Stringable instance.
1141
1195
  */
1142
1196
  words(e = 100, t = "...") {
1143
- return new s(Pe(this._value, e, t));
1197
+ return new r(Oe(this._value, e, t));
1144
1198
  }
1145
1199
  /**
1146
1200
  * Get the number of words a string contains.
@@ -1149,7 +1203,7 @@ class s {
1149
1203
  * @returns The number of words in the string.
1150
1204
  */
1151
1205
  wordCount(e = null) {
1152
- return qe(this._value, e);
1206
+ return Pe(this._value, e);
1153
1207
  }
1154
1208
  /**
1155
1209
  * Wrap a string to a given number of characters.
@@ -1160,9 +1214,9 @@ class s {
1160
1214
  * @returns The wrapped string as a new Stringable instance.
1161
1215
  */
1162
1216
  wordWrap(e = 75, t = `
1163
- `, r = !1) {
1164
- return new s(
1165
- Je(this._value, e, t, r)
1217
+ `, s = !1) {
1218
+ return new r(
1219
+ $e(this._value, e, t, s)
1166
1220
  );
1167
1221
  }
1168
1222
  /**
@@ -1173,7 +1227,7 @@ class s {
1173
1227
  * @returns The wrapped string as a new Stringable instance.
1174
1228
  */
1175
1229
  wrap(e, t = null) {
1176
- return new s(Ve(this._value, e, t));
1230
+ return new r(Je(this._value, e, t));
1177
1231
  }
1178
1232
  /**
1179
1233
  * Unwrap the string with the given strings.
@@ -1183,7 +1237,7 @@ class s {
1183
1237
  * @returns The unwrapped string as a new Stringable instance.
1184
1238
  */
1185
1239
  unwrap(e, t = null) {
1186
- return new s($e(this._value, e, t));
1240
+ return new r(Ve(this._value, e, t));
1187
1241
  }
1188
1242
  /**
1189
1243
  * Convert the string to Base64 encoding.
@@ -1191,7 +1245,7 @@ class s {
1191
1245
  * @returns The Base64 encoded string as a new Stringable instance.
1192
1246
  */
1193
1247
  toBase64() {
1194
- return new s(d(this._value));
1248
+ return new r(m(this._value));
1195
1249
  }
1196
1250
  /**
1197
1251
  * Decode the Base64 encoded string.
@@ -1201,7 +1255,16 @@ class s {
1201
1255
  */
1202
1256
  fromBase64(e = !1) {
1203
1257
  const t = f(this._value, e);
1204
- return t === !1 ? !1 : new s(t);
1258
+ return t === !1 ? !1 : new r(t);
1259
+ }
1260
+ /**
1261
+ * Dump the string and the given arguments to the console.
1262
+ *
1263
+ * @param args - Extra values to log alongside the string.
1264
+ * @returns The current instance.
1265
+ */
1266
+ dump(...e) {
1267
+ return console.log(this._value, ...e), this;
1205
1268
  }
1206
1269
  /**
1207
1270
  * Get the underlying string value.
@@ -1243,7 +1306,7 @@ class s {
1243
1306
  * @returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
1244
1307
  */
1245
1308
  toBoolean() {
1246
- const e = a(o(this._value));
1309
+ const e = o(w(this._value));
1247
1310
  return e === "1" || e === "true" || e === "on" || e === "yes";
1248
1311
  }
1249
1312
  /**
@@ -1265,7 +1328,7 @@ class s {
1265
1328
  }
1266
1329
  }
1267
1330
  export {
1268
- s as Stringable,
1269
- ut as of,
1270
- it as str
1331
+ r as Stringable,
1332
+ at as of,
1333
+ ot as str
1271
1334
  };