@tolki/str 1.0.1 → 1.0.3
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/ascii/index.d.ts +2 -0
- package/dist/ascii/index.d.ts.map +1 -1
- package/dist/ascii/index.js +23 -28
- package/dist/base64/index.d.ts +2 -0
- package/dist/base64/index.d.ts.map +1 -1
- package/dist/convertcase/index.d.ts +2 -8
- package/dist/convertcase/index.d.ts.map +1 -1
- package/dist/markdown/index.d.ts +1 -1
- package/dist/markdown/index.d.ts.map +1 -1
- package/dist/markdown/index.js +12 -11
- package/dist/pluralizer/index.d.ts +8 -14
- package/dist/pluralizer/index.d.ts.map +1 -1
- package/dist/replacer/index.d.ts +8 -0
- package/dist/replacer/index.d.ts.map +1 -1
- package/dist/replacer/index.js +31 -27
- package/dist/str.d.ts +50 -136
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +371 -375
- package/dist/stringable/index.d.ts +5 -9
- package/dist/stringable/index.d.ts.map +1 -1
- package/dist/stringable/index.js +109 -118
- package/dist/transliterate/index.d.ts +1 -3
- package/dist/transliterate/index.d.ts.map +1 -1
- package/dist/trimmer/index.d.ts +6 -0
- package/dist/trimmer/index.d.ts.map +1 -1
- package/dist/ulid/index.d.ts +8 -14
- package/dist/ulid/index.d.ts.map +1 -1
- package/dist/ulid/index.js +8 -8
- package/dist/uuid/index.d.ts +9 -17
- package/dist/uuid/index.d.ts.map +1 -1
- package/dist/uuid/index.js +6 -6
- package/package.json +3 -3
package/dist/stringable/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { after as
|
|
2
|
-
import { isInteger as
|
|
3
|
-
function
|
|
4
|
-
return new s(
|
|
1
|
+
import { after as v, afterLast as c, ascii as p, before as d, beforeLast as f, between as _, betweenFirst as m, camel as E, charAt as y, chopStart as A, chopEnd as W, contains as x, containsAll as k, doesntContain as N, convertCase as U, deduplicate as C, endsWith as L, doesntEndWith as M, excerpt as F, finish as I, is as B, isAscii as R, isJson as j, isUrl as D, isUuid as T, isUlid as P, kebab as q, length as J, limit as V, lower as l, markdown as $, inlineMarkdown as z, mask as G, match as X, isMatch as H, matchAll as K, numbers as O, padBoth as Q, padLeft as Y, padRight as Z, plural as g, pluralStudly as b, pluralPascal as S, position as ee, remove as te, reverse as se, repeat as re, replace as ne, replaceArray as ue, replaceFirst as ie, replaceStart as he, replaceLast as le, replaceEnd as ae, replaceMatches as we, squish as oe, start as ve, stripTags as ce, upper as pe, title as de, headline as fe, apa as _e, transliterate as me, singular as Ee, slug as ye, snake as Ae, startsWith as We, doesntStartWith as xe, studly as ke, pascal as Ne, substr as Ue, substrCount as Ce, substrReplace as Le, swap as Me, take as Fe, trim as a, ltrim as Ie, rtrim 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, toBase64 as ze, fromBase64 as Ge } from "@tolki/str";
|
|
2
|
+
import { isInteger as Xe, isFunction as w } from "@tolki/utils";
|
|
3
|
+
function Oe(h = "") {
|
|
4
|
+
return new s(h);
|
|
5
5
|
}
|
|
6
|
-
function
|
|
7
|
-
return new s(
|
|
6
|
+
function Qe(h = "") {
|
|
7
|
+
return new s(h);
|
|
8
8
|
}
|
|
9
9
|
class s {
|
|
10
10
|
/**
|
|
@@ -22,7 +22,7 @@ class s {
|
|
|
22
22
|
* @returns The portion of the string after the first occurrence of the search value.
|
|
23
23
|
*/
|
|
24
24
|
after(e) {
|
|
25
|
-
return new s(
|
|
25
|
+
return new s(v(this._value, e));
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Return the remainder of a string after the last occurrence of a given value
|
|
@@ -31,7 +31,7 @@ class s {
|
|
|
31
31
|
* @returns The portion of the string after the last occurrence of the search value.
|
|
32
32
|
*/
|
|
33
33
|
afterLast(e) {
|
|
34
|
-
return new s(
|
|
34
|
+
return new s(c(this._value, e));
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
37
37
|
* Append the given values to the string.
|
|
@@ -58,7 +58,7 @@ class s {
|
|
|
58
58
|
* @returns The transliterated string as a new Stringable instance.
|
|
59
59
|
*/
|
|
60
60
|
ascii() {
|
|
61
|
-
return new s(
|
|
61
|
+
return new s(p(this._value));
|
|
62
62
|
}
|
|
63
63
|
/**
|
|
64
64
|
* Get the portion of a string before the first occurrence of a given value.
|
|
@@ -67,7 +67,7 @@ class s {
|
|
|
67
67
|
* @returns The portion of the string before the first occurrence of the search value.
|
|
68
68
|
*/
|
|
69
69
|
before(e) {
|
|
70
|
-
return new s(
|
|
70
|
+
return new s(d(this._value, e));
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Get the portion of a string before the last occurrence of a given value.
|
|
@@ -76,7 +76,7 @@ class s {
|
|
|
76
76
|
* @returns The portion of the string before the last occurrence of the search value.
|
|
77
77
|
*/
|
|
78
78
|
beforeLast(e) {
|
|
79
|
-
return new s(
|
|
79
|
+
return new s(f(this._value, e));
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
82
|
* Get the portion of a string between two given values.
|
|
@@ -86,7 +86,7 @@ class s {
|
|
|
86
86
|
* @returns The portion of the string between the two given values.
|
|
87
87
|
*/
|
|
88
88
|
between(e, t) {
|
|
89
|
-
return new s(
|
|
89
|
+
return new s(_(this._value, e, t));
|
|
90
90
|
}
|
|
91
91
|
/**
|
|
92
92
|
* Get the smallest possible portion of a string between two given values.
|
|
@@ -96,7 +96,7 @@ class s {
|
|
|
96
96
|
* @returns The smallest possible portion of the string between the two given values.
|
|
97
97
|
*/
|
|
98
98
|
betweenFirst(e, t) {
|
|
99
|
-
return new s(
|
|
99
|
+
return new s(m(this._value, e, t));
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Convert a value to camel case.
|
|
@@ -104,7 +104,7 @@ class s {
|
|
|
104
104
|
* @returns The camel-cased string as a new Stringable instance.
|
|
105
105
|
*/
|
|
106
106
|
camel() {
|
|
107
|
-
return new s(
|
|
107
|
+
return new s(E(this._value));
|
|
108
108
|
}
|
|
109
109
|
/**
|
|
110
110
|
* Get the character at the specified index.
|
|
@@ -113,7 +113,7 @@ class s {
|
|
|
113
113
|
* @returns The character at the specified index, or false if the index is out of bounds.
|
|
114
114
|
*/
|
|
115
115
|
charAt(e) {
|
|
116
|
-
return
|
|
116
|
+
return y(this._value, e);
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* Remove the given string if it exists at the start of the current string.
|
|
@@ -122,7 +122,7 @@ class s {
|
|
|
122
122
|
* @returns The updated Stringable instance.
|
|
123
123
|
*/
|
|
124
124
|
chopStart(e) {
|
|
125
|
-
return new s(
|
|
125
|
+
return new s(A(this._value, e));
|
|
126
126
|
}
|
|
127
127
|
/**
|
|
128
128
|
* Remove the given string if it exists at the end of the current string.
|
|
@@ -131,7 +131,7 @@ class s {
|
|
|
131
131
|
* @returns The updated Stringable instance.
|
|
132
132
|
*/
|
|
133
133
|
chopEnd(e) {
|
|
134
|
-
return new s(
|
|
134
|
+
return new s(W(this._value, e));
|
|
135
135
|
}
|
|
136
136
|
/**
|
|
137
137
|
* Determine if a given string contains a given substring.
|
|
@@ -141,7 +141,7 @@ class s {
|
|
|
141
141
|
* @returns boolean - True if the substring(s) are found, false otherwise
|
|
142
142
|
*/
|
|
143
143
|
contains(e, t = !1) {
|
|
144
|
-
return
|
|
144
|
+
return x(this._value, e, t);
|
|
145
145
|
}
|
|
146
146
|
/**
|
|
147
147
|
* Determine if a given string contains all array values.
|
|
@@ -151,7 +151,7 @@ class s {
|
|
|
151
151
|
* @returns boolean - True if all substring(s) are found, false otherwise
|
|
152
152
|
*/
|
|
153
153
|
containsAll(e, t = !1) {
|
|
154
|
-
return
|
|
154
|
+
return k(this._value, e, t);
|
|
155
155
|
}
|
|
156
156
|
/**
|
|
157
157
|
* Determine if a given string doesn't contain a given substring.
|
|
@@ -161,7 +161,7 @@ class s {
|
|
|
161
161
|
* @returns boolean - True if the substring(s) are not found, false otherwise
|
|
162
162
|
*/
|
|
163
163
|
doesntContain(e, t = !1) {
|
|
164
|
-
return
|
|
164
|
+
return N(this._value, e, t);
|
|
165
165
|
}
|
|
166
166
|
/**
|
|
167
167
|
* Convert the case of a string.
|
|
@@ -170,7 +170,7 @@ class s {
|
|
|
170
170
|
* @returns The converted string as a new Stringable instance.
|
|
171
171
|
*/
|
|
172
172
|
convertCase(e) {
|
|
173
|
-
return new s(
|
|
173
|
+
return new s(U(this._value, e));
|
|
174
174
|
}
|
|
175
175
|
/**
|
|
176
176
|
* Replace consecutive instances of a given character with a single character.
|
|
@@ -179,7 +179,7 @@ class s {
|
|
|
179
179
|
* @returns The updated Stringable instance.
|
|
180
180
|
*/
|
|
181
181
|
deduplicate(e = " ") {
|
|
182
|
-
return new s(
|
|
182
|
+
return new s(C(this._value, e));
|
|
183
183
|
}
|
|
184
184
|
/**
|
|
185
185
|
* Determine if a given string ends with a given substring.
|
|
@@ -188,7 +188,7 @@ class s {
|
|
|
188
188
|
* @returns boolean - True if the substring(s) are found, false otherwise
|
|
189
189
|
*/
|
|
190
190
|
endsWith(e) {
|
|
191
|
-
return
|
|
191
|
+
return L(this._value, e);
|
|
192
192
|
}
|
|
193
193
|
/**
|
|
194
194
|
* Determine if a given string doesn't end with a given substring.
|
|
@@ -197,7 +197,7 @@ class s {
|
|
|
197
197
|
* @returns boolean - True if the substring(s) are not found, false otherwise
|
|
198
198
|
*/
|
|
199
199
|
doesntEndWith(e) {
|
|
200
|
-
return
|
|
200
|
+
return M(this._value, e);
|
|
201
201
|
}
|
|
202
202
|
/**
|
|
203
203
|
* Determine if the string is an exact match with the given value.
|
|
@@ -217,7 +217,7 @@ class s {
|
|
|
217
217
|
* @returns The extracted excerpt or null if the phrase is not found.
|
|
218
218
|
*/
|
|
219
219
|
excerpt(e = "", t = {}) {
|
|
220
|
-
return
|
|
220
|
+
return F(this._value, e, t);
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
223
223
|
* Explode the string into an array
|
|
@@ -243,11 +243,11 @@ class s {
|
|
|
243
243
|
* @returns An array of strings obtained by splitting the original string.
|
|
244
244
|
*/
|
|
245
245
|
split(e, t = null) {
|
|
246
|
-
if (
|
|
247
|
-
const n = Number(e),
|
|
248
|
-
for (let
|
|
249
|
-
|
|
250
|
-
return
|
|
246
|
+
if (Xe(e)) {
|
|
247
|
+
const n = Number(e), i = [];
|
|
248
|
+
for (let u = 0; u < this._value.length; u += n)
|
|
249
|
+
i.push(this._value.substr(u, n));
|
|
250
|
+
return i;
|
|
251
251
|
}
|
|
252
252
|
return this._value.split(
|
|
253
253
|
new RegExp(String(e)),
|
|
@@ -261,7 +261,7 @@ class s {
|
|
|
261
261
|
* @returns The updated Stringable instance.
|
|
262
262
|
*/
|
|
263
263
|
finish(e) {
|
|
264
|
-
return new s(
|
|
264
|
+
return new s(I(this._value, e));
|
|
265
265
|
}
|
|
266
266
|
/**
|
|
267
267
|
* Determine if a given string matches a given pattern.
|
|
@@ -270,7 +270,7 @@ class s {
|
|
|
270
270
|
* @returns boolean - True if the pattern(s) match, false otherwise
|
|
271
271
|
*/
|
|
272
272
|
is(e, t = !1) {
|
|
273
|
-
return
|
|
273
|
+
return B(e, this._value, t);
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
276
|
* Determine if a given string is 7 bit ASCII.
|
|
@@ -278,7 +278,7 @@ class s {
|
|
|
278
278
|
* @returns True if the string is ASCII, false otherwise.
|
|
279
279
|
*/
|
|
280
280
|
isAscii() {
|
|
281
|
-
return
|
|
281
|
+
return R(this._value);
|
|
282
282
|
}
|
|
283
283
|
/**
|
|
284
284
|
* Determine if a given string is valid JSON.
|
|
@@ -286,7 +286,7 @@ class s {
|
|
|
286
286
|
* @returns True if the string is valid JSON, false otherwise.
|
|
287
287
|
*/
|
|
288
288
|
isJson() {
|
|
289
|
-
return
|
|
289
|
+
return j(this._value);
|
|
290
290
|
}
|
|
291
291
|
/**
|
|
292
292
|
* Determine if a given value is a valid URL.
|
|
@@ -295,7 +295,7 @@ class s {
|
|
|
295
295
|
* @returns True if the string is a valid URL, false otherwise.
|
|
296
296
|
*/
|
|
297
297
|
isUrl(e = []) {
|
|
298
|
-
return
|
|
298
|
+
return D(this._value, e);
|
|
299
299
|
}
|
|
300
300
|
/**
|
|
301
301
|
* Determine if a given string is a valid UUID.
|
|
@@ -304,7 +304,7 @@ class s {
|
|
|
304
304
|
* @returns True if the string is a valid UUID, false otherwise.
|
|
305
305
|
*/
|
|
306
306
|
isUuid(e = null) {
|
|
307
|
-
return
|
|
307
|
+
return T(this._value, e);
|
|
308
308
|
}
|
|
309
309
|
/**
|
|
310
310
|
* Determine if a given string is a valid ULID.
|
|
@@ -312,7 +312,7 @@ class s {
|
|
|
312
312
|
* @return True if the string is a valid ULID, false otherwise.
|
|
313
313
|
*/
|
|
314
314
|
isUlid() {
|
|
315
|
-
return
|
|
315
|
+
return P(this._value);
|
|
316
316
|
}
|
|
317
317
|
/**
|
|
318
318
|
* Determine if the given string is empty.
|
|
@@ -336,7 +336,7 @@ class s {
|
|
|
336
336
|
* @returns The kebab-cased string as a new Stringable instance.
|
|
337
337
|
*/
|
|
338
338
|
kebab() {
|
|
339
|
-
return new s(
|
|
339
|
+
return new s(q(this._value));
|
|
340
340
|
}
|
|
341
341
|
/**
|
|
342
342
|
* Return the length of the given string.
|
|
@@ -344,7 +344,7 @@ class s {
|
|
|
344
344
|
* @returns The length of the string.
|
|
345
345
|
*/
|
|
346
346
|
length() {
|
|
347
|
-
return
|
|
347
|
+
return J(this._value);
|
|
348
348
|
}
|
|
349
349
|
/**
|
|
350
350
|
* Limit the number of characters in a string.
|
|
@@ -356,7 +356,7 @@ class s {
|
|
|
356
356
|
*/
|
|
357
357
|
limit(e = 100, t = "...", r = !1) {
|
|
358
358
|
return new s(
|
|
359
|
-
|
|
359
|
+
V(this._value, e, t, r)
|
|
360
360
|
);
|
|
361
361
|
}
|
|
362
362
|
/**
|
|
@@ -365,7 +365,7 @@ class s {
|
|
|
365
365
|
* @returns The lower-cased string as a new Stringable instance.
|
|
366
366
|
*/
|
|
367
367
|
lower() {
|
|
368
|
-
return new s(
|
|
368
|
+
return new s(l(this._value));
|
|
369
369
|
}
|
|
370
370
|
/**
|
|
371
371
|
* Convert GitHub flavored Markdown into HTML.
|
|
@@ -375,7 +375,7 @@ class s {
|
|
|
375
375
|
* @returns The resulting HTML string as a new Stringable instance.
|
|
376
376
|
*/
|
|
377
377
|
markdown(e = { gfm: !0, anchors: !1 }, t = []) {
|
|
378
|
-
return new s(
|
|
378
|
+
return new s($(this._value, e, t));
|
|
379
379
|
}
|
|
380
380
|
/**
|
|
381
381
|
* Convert inline Markdown into HTML.
|
|
@@ -385,7 +385,7 @@ class s {
|
|
|
385
385
|
* @returns The resulting HTML string as a new Stringable instance.
|
|
386
386
|
*/
|
|
387
387
|
inlineMarkdown(e = { gfm: !0 }, t = []) {
|
|
388
|
-
return new s(
|
|
388
|
+
return new s(z(this._value, e, t));
|
|
389
389
|
}
|
|
390
390
|
/**
|
|
391
391
|
* Masks a portion of a string with a repeated character.
|
|
@@ -396,7 +396,7 @@ class s {
|
|
|
396
396
|
* @returns The masked string as a new Stringable instance.
|
|
397
397
|
*/
|
|
398
398
|
mask(e, t, r = null) {
|
|
399
|
-
return new s(
|
|
399
|
+
return new s(G(this._value, e, t, r));
|
|
400
400
|
}
|
|
401
401
|
/**
|
|
402
402
|
* Get the string matching the given pattern.
|
|
@@ -405,7 +405,7 @@ class s {
|
|
|
405
405
|
* @returns A new Stringable instance containing the matched string.
|
|
406
406
|
*/
|
|
407
407
|
match(e) {
|
|
408
|
-
return new s(
|
|
408
|
+
return new s(X(e, this._value));
|
|
409
409
|
}
|
|
410
410
|
/**
|
|
411
411
|
* Determine if a given string matches a given pattern.
|
|
@@ -414,7 +414,7 @@ class s {
|
|
|
414
414
|
* @returns boolean - True if the pattern(s) match, false otherwise
|
|
415
415
|
*/
|
|
416
416
|
isMatch(e) {
|
|
417
|
-
return
|
|
417
|
+
return H(e, this._value);
|
|
418
418
|
}
|
|
419
419
|
/**
|
|
420
420
|
* Get the string matching the given pattern.
|
|
@@ -423,7 +423,7 @@ class s {
|
|
|
423
423
|
* @returns An array of all matched strings.
|
|
424
424
|
*/
|
|
425
425
|
matchAll(e) {
|
|
426
|
-
return
|
|
426
|
+
return K(e, this._value);
|
|
427
427
|
}
|
|
428
428
|
/**
|
|
429
429
|
* Determine if the string matches the given pattern.
|
|
@@ -440,7 +440,7 @@ class s {
|
|
|
440
440
|
* @returns The numeric string as a new Stringable instance.
|
|
441
441
|
*/
|
|
442
442
|
numbers() {
|
|
443
|
-
return new s(
|
|
443
|
+
return new s(O(this._value));
|
|
444
444
|
}
|
|
445
445
|
/**
|
|
446
446
|
* Pad both sides of the string with another.
|
|
@@ -450,7 +450,7 @@ class s {
|
|
|
450
450
|
* @returns The padded string as a new Stringable instance.
|
|
451
451
|
*/
|
|
452
452
|
padBoth(e, t = " ") {
|
|
453
|
-
return new s(
|
|
453
|
+
return new s(Q(this._value, e, t));
|
|
454
454
|
}
|
|
455
455
|
/**
|
|
456
456
|
* Pad the left side of the string with another.
|
|
@@ -460,7 +460,7 @@ class s {
|
|
|
460
460
|
* @returns The padded string as a new Stringable instance.
|
|
461
461
|
*/
|
|
462
462
|
padLeft(e, t = " ") {
|
|
463
|
-
return new s(
|
|
463
|
+
return new s(Y(this._value, e, t));
|
|
464
464
|
}
|
|
465
465
|
/**
|
|
466
466
|
* Pad the right side of the string with another.
|
|
@@ -470,7 +470,7 @@ class s {
|
|
|
470
470
|
* @returns The padded string as a new Stringable instance.
|
|
471
471
|
*/
|
|
472
472
|
padRight(e, t = " ") {
|
|
473
|
-
return new s(
|
|
473
|
+
return new s(Z(this._value, e, t));
|
|
474
474
|
}
|
|
475
475
|
/**
|
|
476
476
|
* Call the given callback and return a new string.
|
|
@@ -490,7 +490,7 @@ class s {
|
|
|
490
490
|
* @returns The pluralized string as a new Stringable instance.
|
|
491
491
|
*/
|
|
492
492
|
plural(e = 2, t = !1) {
|
|
493
|
-
return new s(
|
|
493
|
+
return new s(g(this._value, e, t));
|
|
494
494
|
}
|
|
495
495
|
/**
|
|
496
496
|
* Pluralize the last word of an English, studly caps case string.
|
|
@@ -499,8 +499,7 @@ class s {
|
|
|
499
499
|
* @returns The pluralized string as a new Stringable instance.
|
|
500
500
|
*/
|
|
501
501
|
pluralStudly(e = 2) {
|
|
502
|
-
|
|
503
|
-
return new s(ee(this._value, t));
|
|
502
|
+
return new s(b(this._value, e));
|
|
504
503
|
}
|
|
505
504
|
/**
|
|
506
505
|
* Pluralize the last word of an English, Pascal caps case string.
|
|
@@ -509,8 +508,7 @@ class s {
|
|
|
509
508
|
* @returns The pluralized string as a new Stringable instance.
|
|
510
509
|
*/
|
|
511
510
|
pluralPascal(e = 2) {
|
|
512
|
-
|
|
513
|
-
return new s(te(this._value, t));
|
|
511
|
+
return new s(S(this._value, e));
|
|
514
512
|
}
|
|
515
513
|
/**
|
|
516
514
|
* Find the multi-byte safe position of the first occurrence of the given substring.
|
|
@@ -520,7 +518,7 @@ class s {
|
|
|
520
518
|
* @returns The position of the first occurrence of the substring, or false if not found.
|
|
521
519
|
*/
|
|
522
520
|
position(e, t = 0) {
|
|
523
|
-
return
|
|
521
|
+
return ee(this._value, e, t);
|
|
524
522
|
}
|
|
525
523
|
/**
|
|
526
524
|
* Prepend the given values to the string.
|
|
@@ -540,7 +538,7 @@ class s {
|
|
|
540
538
|
*/
|
|
541
539
|
remove(e, t = !0) {
|
|
542
540
|
return new s(
|
|
543
|
-
|
|
541
|
+
te(e, this._value, t)
|
|
544
542
|
);
|
|
545
543
|
}
|
|
546
544
|
/**
|
|
@@ -549,7 +547,7 @@ class s {
|
|
|
549
547
|
* @returns The reversed string as a new Stringable instance.
|
|
550
548
|
*/
|
|
551
549
|
reverse() {
|
|
552
|
-
return new s(
|
|
550
|
+
return new s(se(this._value));
|
|
553
551
|
}
|
|
554
552
|
/**
|
|
555
553
|
* Repeat the string.
|
|
@@ -558,7 +556,7 @@ class s {
|
|
|
558
556
|
* @returns The repeated string as a new Stringable instance.
|
|
559
557
|
*/
|
|
560
558
|
repeat(e) {
|
|
561
|
-
return new s(
|
|
559
|
+
return new s(re(this._value, e));
|
|
562
560
|
}
|
|
563
561
|
/**
|
|
564
562
|
* Replace the given value in the given string.
|
|
@@ -570,7 +568,7 @@ class s {
|
|
|
570
568
|
*/
|
|
571
569
|
replace(e, t, r = !0) {
|
|
572
570
|
return new s(
|
|
573
|
-
|
|
571
|
+
ne(e, t, this._value, r)
|
|
574
572
|
);
|
|
575
573
|
}
|
|
576
574
|
/**
|
|
@@ -581,7 +579,7 @@ class s {
|
|
|
581
579
|
* @returns The updated Stringable instance.
|
|
582
580
|
*/
|
|
583
581
|
replaceArray(e, t) {
|
|
584
|
-
return new s(
|
|
582
|
+
return new s(ue(e, t, this._value));
|
|
585
583
|
}
|
|
586
584
|
/**
|
|
587
585
|
* Replace the first occurrence of a given value in the string.
|
|
@@ -591,7 +589,7 @@ class s {
|
|
|
591
589
|
* @returns The updated Stringable instance.
|
|
592
590
|
*/
|
|
593
591
|
replaceFirst(e, t) {
|
|
594
|
-
return new s(
|
|
592
|
+
return new s(ie(e, t, this._value));
|
|
595
593
|
}
|
|
596
594
|
/**
|
|
597
595
|
* Replace the first occurrence of the given value if it appears at the start of the string.
|
|
@@ -601,7 +599,7 @@ class s {
|
|
|
601
599
|
* @returns The updated Stringable instance.
|
|
602
600
|
*/
|
|
603
601
|
replaceStart(e, t) {
|
|
604
|
-
return new s(
|
|
602
|
+
return new s(he(e, t, this._value));
|
|
605
603
|
}
|
|
606
604
|
/**
|
|
607
605
|
* Replace the last occurrence of a given value in the string.
|
|
@@ -611,7 +609,7 @@ class s {
|
|
|
611
609
|
* @returns The updated Stringable instance.
|
|
612
610
|
*/
|
|
613
611
|
replaceLast(e, t) {
|
|
614
|
-
return new s(
|
|
612
|
+
return new s(le(e, t, this._value));
|
|
615
613
|
}
|
|
616
614
|
/**
|
|
617
615
|
* Replace the last occurrence of a given value if it appears at the end of the string.
|
|
@@ -621,7 +619,7 @@ class s {
|
|
|
621
619
|
* @returns The updated Stringable instance.
|
|
622
620
|
*/
|
|
623
621
|
replaceEnd(e, t) {
|
|
624
|
-
return new s(
|
|
622
|
+
return new s(ae(e, t, this._value));
|
|
625
623
|
}
|
|
626
624
|
/**
|
|
627
625
|
* Replace the patterns matching the given regular expression.
|
|
@@ -632,7 +630,7 @@ class s {
|
|
|
632
630
|
* @returns The updated Stringable instance.
|
|
633
631
|
*/
|
|
634
632
|
replaceMatches(e, t, r = -1) {
|
|
635
|
-
const n =
|
|
633
|
+
const n = we(e, t, this._value, r);
|
|
636
634
|
return new s(n);
|
|
637
635
|
}
|
|
638
636
|
/**
|
|
@@ -655,22 +653,15 @@ class s {
|
|
|
655
653
|
let u = r + 2;
|
|
656
654
|
for (; u < e.length && e[u] !== "]"; )
|
|
657
655
|
u++;
|
|
658
|
-
const
|
|
659
|
-
t += "([" +
|
|
656
|
+
const o = e.substring(r + 2, u);
|
|
657
|
+
t += "([" + o + "]+)", r = u + 1;
|
|
660
658
|
} else e[r + 1] === "d" ? (t += "\\s*(-?\\d+)", r += 2) : e[r + 1] === "s" ? (t += "\\s*(\\S+)", r += 2) : (t += e[r], r++);
|
|
661
659
|
else {
|
|
662
660
|
const u = e[r];
|
|
663
661
|
u && /[.+?^${}()|\\]/.test(u) ? t += "\\" + u : t += u, r++;
|
|
664
662
|
}
|
|
665
|
-
const n = new RegExp("^" + t + "$"),
|
|
666
|
-
|
|
667
|
-
return [];
|
|
668
|
-
const i = [];
|
|
669
|
-
for (let u = 1; u < h.length; u++) {
|
|
670
|
-
const l = h[u];
|
|
671
|
-
l && i.push(l);
|
|
672
|
-
}
|
|
673
|
-
return i;
|
|
663
|
+
const n = new RegExp("^" + t + "$"), i = this._value.match(n);
|
|
664
|
+
return i ? i.slice(1).filter((u) => u !== void 0) : [];
|
|
674
665
|
}
|
|
675
666
|
/**
|
|
676
667
|
* Remove all "extra" blank space from the given string.
|
|
@@ -678,7 +669,7 @@ class s {
|
|
|
678
669
|
* @returns The updated Stringable instance.
|
|
679
670
|
*/
|
|
680
671
|
squish() {
|
|
681
|
-
return new s(
|
|
672
|
+
return new s(oe(this._value));
|
|
682
673
|
}
|
|
683
674
|
/**
|
|
684
675
|
* Begin a string with a single instance of a given value.
|
|
@@ -687,7 +678,7 @@ class s {
|
|
|
687
678
|
* @returns The updated Stringable instance.
|
|
688
679
|
*/
|
|
689
680
|
start(e) {
|
|
690
|
-
return new s(
|
|
681
|
+
return new s(ve(this._value, e));
|
|
691
682
|
}
|
|
692
683
|
/**
|
|
693
684
|
* Strip HTML and PHP tags from the given string.
|
|
@@ -695,7 +686,7 @@ class s {
|
|
|
695
686
|
* @returns The updated Stringable instance.
|
|
696
687
|
*/
|
|
697
688
|
stripTags() {
|
|
698
|
-
return new s(
|
|
689
|
+
return new s(ce(this._value));
|
|
699
690
|
}
|
|
700
691
|
/**
|
|
701
692
|
* Convert the given string to upper-case.
|
|
@@ -703,7 +694,7 @@ class s {
|
|
|
703
694
|
* @returns The upper-cased string as a new Stringable instance.
|
|
704
695
|
*/
|
|
705
696
|
upper() {
|
|
706
|
-
return new s(
|
|
697
|
+
return new s(pe(this._value));
|
|
707
698
|
}
|
|
708
699
|
/**
|
|
709
700
|
* Convert the given string to proper case.
|
|
@@ -711,7 +702,7 @@ class s {
|
|
|
711
702
|
* @returns The title-cased string as a new Stringable instance.
|
|
712
703
|
*/
|
|
713
704
|
title() {
|
|
714
|
-
return new s(
|
|
705
|
+
return new s(de(this._value));
|
|
715
706
|
}
|
|
716
707
|
/**
|
|
717
708
|
* Convert the given string to proper case for each word.
|
|
@@ -719,7 +710,7 @@ class s {
|
|
|
719
710
|
* @returns The headline-cased string as a new Stringable instance.
|
|
720
711
|
*/
|
|
721
712
|
headline() {
|
|
722
|
-
return new s(
|
|
713
|
+
return new s(fe(this._value));
|
|
723
714
|
}
|
|
724
715
|
/**
|
|
725
716
|
* Convert the given string to APA-style title case.
|
|
@@ -727,7 +718,7 @@ class s {
|
|
|
727
718
|
* @returns The APA title-cased string as a new Stringable instance.
|
|
728
719
|
*/
|
|
729
720
|
apa() {
|
|
730
|
-
return new s(
|
|
721
|
+
return new s(_e(this._value));
|
|
731
722
|
}
|
|
732
723
|
/**
|
|
733
724
|
* Transliterate a string to its closest ASCII representation.
|
|
@@ -735,7 +726,7 @@ class s {
|
|
|
735
726
|
* @returns The transliterated string as a new Stringable instance.
|
|
736
727
|
*/
|
|
737
728
|
transliterate() {
|
|
738
|
-
return new s(
|
|
729
|
+
return new s(me(this._value));
|
|
739
730
|
}
|
|
740
731
|
/**
|
|
741
732
|
* Get the singular form of an English word.
|
|
@@ -743,7 +734,7 @@ class s {
|
|
|
743
734
|
* @returns The singularized string as a new Stringable instance.
|
|
744
735
|
*/
|
|
745
736
|
singular() {
|
|
746
|
-
return new s(
|
|
737
|
+
return new s(Ee(this._value));
|
|
747
738
|
}
|
|
748
739
|
/**
|
|
749
740
|
* Generate a URL friendly "slug" from a given string.
|
|
@@ -753,7 +744,7 @@ class s {
|
|
|
753
744
|
* @returns The slugified string as a new Stringable instance.
|
|
754
745
|
*/
|
|
755
746
|
slug(e = "-", t = { "@": "at" }) {
|
|
756
|
-
return new s(
|
|
747
|
+
return new s(ye(this._value, e, t));
|
|
757
748
|
}
|
|
758
749
|
/**
|
|
759
750
|
* Convert a string to snake case.
|
|
@@ -762,7 +753,7 @@ class s {
|
|
|
762
753
|
* @returns The snake-cased string as a new Stringable instance.
|
|
763
754
|
*/
|
|
764
755
|
snake(e = "_") {
|
|
765
|
-
return new s(
|
|
756
|
+
return new s(Ae(this._value, e));
|
|
766
757
|
}
|
|
767
758
|
/**
|
|
768
759
|
* Determine if a given string starts with a given substring.
|
|
@@ -771,7 +762,7 @@ class s {
|
|
|
771
762
|
* @returns boolean - True if the substring(s) are found, false otherwise
|
|
772
763
|
*/
|
|
773
764
|
startsWith(e) {
|
|
774
|
-
return
|
|
765
|
+
return We(this._value, e);
|
|
775
766
|
}
|
|
776
767
|
/**
|
|
777
768
|
* Determine if a given string doesn't start with a given substring.
|
|
@@ -780,7 +771,7 @@ class s {
|
|
|
780
771
|
* @returns boolean - True if the substring(s) are not found, false otherwise
|
|
781
772
|
*/
|
|
782
773
|
doesntStartWith(e) {
|
|
783
|
-
return
|
|
774
|
+
return xe(this._value, e);
|
|
784
775
|
}
|
|
785
776
|
/**
|
|
786
777
|
* Convert a value to studly caps case.
|
|
@@ -788,7 +779,7 @@ class s {
|
|
|
788
779
|
* @returns The studly-cased string as a new Stringable instance.
|
|
789
780
|
*/
|
|
790
781
|
studly() {
|
|
791
|
-
return new s(
|
|
782
|
+
return new s(ke(this._value));
|
|
792
783
|
}
|
|
793
784
|
/**
|
|
794
785
|
* Convert the string to Pascal case.
|
|
@@ -796,7 +787,7 @@ class s {
|
|
|
796
787
|
* @returns The pascal-cased string as a new Stringable instance.
|
|
797
788
|
*/
|
|
798
789
|
pascal() {
|
|
799
|
-
return new s(
|
|
790
|
+
return new s(Ne(this._value));
|
|
800
791
|
}
|
|
801
792
|
/**
|
|
802
793
|
* Returns the portion of the string specified by the start and length parameters.
|
|
@@ -806,7 +797,7 @@ class s {
|
|
|
806
797
|
* @returns The extracted substring as a new Stringable instance.
|
|
807
798
|
*/
|
|
808
799
|
substr(e, t = null) {
|
|
809
|
-
return new s(
|
|
800
|
+
return new s(Ue(this._value, e, t));
|
|
810
801
|
}
|
|
811
802
|
/**
|
|
812
803
|
* Returns the number of substring occurrences.
|
|
@@ -817,7 +808,7 @@ class s {
|
|
|
817
808
|
* @returns The number of occurrences of the substring.
|
|
818
809
|
*/
|
|
819
810
|
substrCount(e, t = 0, r = null) {
|
|
820
|
-
return
|
|
811
|
+
return Ce(this._value, e, t, r);
|
|
821
812
|
}
|
|
822
813
|
/**
|
|
823
814
|
* Replace text within a portion of a string.
|
|
@@ -829,7 +820,7 @@ class s {
|
|
|
829
820
|
*/
|
|
830
821
|
substrReplace(e, t = 0, r = null) {
|
|
831
822
|
return new s(
|
|
832
|
-
|
|
823
|
+
Le(this._value, e, t, r)
|
|
833
824
|
);
|
|
834
825
|
}
|
|
835
826
|
/**
|
|
@@ -839,7 +830,7 @@ class s {
|
|
|
839
830
|
* @returns The updated Stringable instance.
|
|
840
831
|
*/
|
|
841
832
|
swap(e) {
|
|
842
|
-
return new s(
|
|
833
|
+
return new s(Me(e, this._value));
|
|
843
834
|
}
|
|
844
835
|
/**
|
|
845
836
|
* Take the first or last {$limit} characters.
|
|
@@ -848,7 +839,7 @@ class s {
|
|
|
848
839
|
* @returns The resulting substring as a new Stringable instance.
|
|
849
840
|
*/
|
|
850
841
|
take(e) {
|
|
851
|
-
return new s(
|
|
842
|
+
return new s(Fe(this._value, e));
|
|
852
843
|
}
|
|
853
844
|
/**
|
|
854
845
|
* Trim the string of the given characters.
|
|
@@ -857,7 +848,7 @@ class s {
|
|
|
857
848
|
* @returns The trimmed string as a new Stringable instance.
|
|
858
849
|
*/
|
|
859
850
|
trim(e = null) {
|
|
860
|
-
return new s(
|
|
851
|
+
return new s(a(this._value, e));
|
|
861
852
|
}
|
|
862
853
|
/**
|
|
863
854
|
* Left trim the string of the given characters.
|
|
@@ -866,7 +857,7 @@ class s {
|
|
|
866
857
|
* @returns The left-trimmed string as a new Stringable instance.
|
|
867
858
|
*/
|
|
868
859
|
ltrim(e = null) {
|
|
869
|
-
return new s(
|
|
860
|
+
return new s(Ie(this._value, e));
|
|
870
861
|
}
|
|
871
862
|
/**
|
|
872
863
|
* Right trim the string of the given characters.
|
|
@@ -875,7 +866,7 @@ class s {
|
|
|
875
866
|
* @returns The right-trimmed string as a new Stringable instance.
|
|
876
867
|
*/
|
|
877
868
|
rtrim(e = null) {
|
|
878
|
-
return new s(
|
|
869
|
+
return new s(Be(this._value, e));
|
|
879
870
|
}
|
|
880
871
|
/**
|
|
881
872
|
* Make a string's first character lowercase.
|
|
@@ -883,7 +874,7 @@ class s {
|
|
|
883
874
|
* @returns The updated Stringable instance.
|
|
884
875
|
*/
|
|
885
876
|
lcfirst() {
|
|
886
|
-
return new s(
|
|
877
|
+
return new s(Re(this._value));
|
|
887
878
|
}
|
|
888
879
|
/**
|
|
889
880
|
* Make a string's first character uppercase.
|
|
@@ -891,7 +882,7 @@ class s {
|
|
|
891
882
|
* @returns The updated Stringable instance.
|
|
892
883
|
*/
|
|
893
884
|
ucfirst() {
|
|
894
|
-
return new s(
|
|
885
|
+
return new s(je(this._value));
|
|
895
886
|
}
|
|
896
887
|
/**
|
|
897
888
|
* Split a string by uppercase characters.
|
|
@@ -899,7 +890,7 @@ class s {
|
|
|
899
890
|
* @returns An array of substrings split at uppercase characters.
|
|
900
891
|
*/
|
|
901
892
|
ucsplit() {
|
|
902
|
-
return
|
|
893
|
+
return De(this._value);
|
|
903
894
|
}
|
|
904
895
|
/**
|
|
905
896
|
* Uppercase the first character of each word in a string.
|
|
@@ -907,7 +898,7 @@ class s {
|
|
|
907
898
|
* @returns The updated Stringable instance.
|
|
908
899
|
*/
|
|
909
900
|
ucwords() {
|
|
910
|
-
return new s(
|
|
901
|
+
return new s(Te(this._value));
|
|
911
902
|
}
|
|
912
903
|
/**
|
|
913
904
|
* Apply the callback if the given "value" is (or resolves to) truthy.
|
|
@@ -932,7 +923,7 @@ class s {
|
|
|
932
923
|
* ```
|
|
933
924
|
*/
|
|
934
925
|
when(e, t = null, r = null) {
|
|
935
|
-
const n =
|
|
926
|
+
const n = w(e) ? e(this) : e;
|
|
936
927
|
return n ? t?.(this, n) ?? this : r ? r(this, n) ?? this : this;
|
|
937
928
|
}
|
|
938
929
|
/**
|
|
@@ -950,7 +941,7 @@ class s {
|
|
|
950
941
|
* str.unless(false, s => s.upper(), s => s.lower()); // Returns 'HELLO WORLD'
|
|
951
942
|
*/
|
|
952
943
|
unless(e, t = null, r = null) {
|
|
953
|
-
const n =
|
|
944
|
+
const n = w(e) ? e(this) : e;
|
|
954
945
|
if (n) {
|
|
955
946
|
if (r)
|
|
956
947
|
return r(this, n) ?? this;
|
|
@@ -1118,7 +1109,7 @@ class s {
|
|
|
1118
1109
|
* @returns The truncated string as a new Stringable instance.
|
|
1119
1110
|
*/
|
|
1120
1111
|
words(e = 100, t = "...") {
|
|
1121
|
-
return new s(
|
|
1112
|
+
return new s(Pe(this._value, e, t));
|
|
1122
1113
|
}
|
|
1123
1114
|
/**
|
|
1124
1115
|
* Get the number of words a string contains.
|
|
@@ -1127,7 +1118,7 @@ class s {
|
|
|
1127
1118
|
* @returns The number of words in the string.
|
|
1128
1119
|
*/
|
|
1129
1120
|
wordCount(e = null) {
|
|
1130
|
-
return
|
|
1121
|
+
return qe(this._value, e);
|
|
1131
1122
|
}
|
|
1132
1123
|
/**
|
|
1133
1124
|
* Wrap a string to a given number of characters.
|
|
@@ -1140,7 +1131,7 @@ class s {
|
|
|
1140
1131
|
wordWrap(e = 75, t = `
|
|
1141
1132
|
`, r = !1) {
|
|
1142
1133
|
return new s(
|
|
1143
|
-
|
|
1134
|
+
Je(this._value, e, t, r)
|
|
1144
1135
|
);
|
|
1145
1136
|
}
|
|
1146
1137
|
/**
|
|
@@ -1151,7 +1142,7 @@ class s {
|
|
|
1151
1142
|
* @returns The wrapped string as a new Stringable instance.
|
|
1152
1143
|
*/
|
|
1153
1144
|
wrap(e, t = null) {
|
|
1154
|
-
return new s(
|
|
1145
|
+
return new s(Ve(this._value, e, t));
|
|
1155
1146
|
}
|
|
1156
1147
|
/**
|
|
1157
1148
|
* Unwrap the string with the given strings.
|
|
@@ -1161,7 +1152,7 @@ class s {
|
|
|
1161
1152
|
* @returns The unwrapped string as a new Stringable instance.
|
|
1162
1153
|
*/
|
|
1163
1154
|
unwrap(e, t = null) {
|
|
1164
|
-
return new s(
|
|
1155
|
+
return new s($e(this._value, e, t));
|
|
1165
1156
|
}
|
|
1166
1157
|
/**
|
|
1167
1158
|
* Convert the string to Base64 encoding.
|
|
@@ -1169,7 +1160,7 @@ class s {
|
|
|
1169
1160
|
* @returns The Base64 encoded string as a new Stringable instance.
|
|
1170
1161
|
*/
|
|
1171
1162
|
toBase64() {
|
|
1172
|
-
return new s(
|
|
1163
|
+
return new s(ze(this._value));
|
|
1173
1164
|
}
|
|
1174
1165
|
/**
|
|
1175
1166
|
* Decode the Base64 encoded string.
|
|
@@ -1178,7 +1169,7 @@ class s {
|
|
|
1178
1169
|
* @returns The decoded string as a new Stringable instance, or false on failure.
|
|
1179
1170
|
*/
|
|
1180
1171
|
fromBase64(e = !1) {
|
|
1181
|
-
const t =
|
|
1172
|
+
const t = Ge(this._value, e);
|
|
1182
1173
|
return t === !1 ? !1 : new s(t);
|
|
1183
1174
|
}
|
|
1184
1175
|
/**
|
|
@@ -1221,11 +1212,11 @@ class s {
|
|
|
1221
1212
|
* @returns true when value is "1", "true", "on", and "yes". Otherwise, returns false.
|
|
1222
1213
|
*/
|
|
1223
1214
|
toBoolean() {
|
|
1224
|
-
const e =
|
|
1215
|
+
const e = l(a(this._value));
|
|
1225
1216
|
return e === "1" || e === "true" || e === "on" || e === "yes";
|
|
1226
1217
|
}
|
|
1227
1218
|
/**
|
|
1228
|
-
* Get the underlying string value as a
|
|
1219
|
+
* Get the underlying string value as a Date instance.
|
|
1229
1220
|
*
|
|
1230
1221
|
* @returns The Date instance or null if parsing fails.
|
|
1231
1222
|
*/
|
|
@@ -1244,6 +1235,6 @@ class s {
|
|
|
1244
1235
|
}
|
|
1245
1236
|
export {
|
|
1246
1237
|
s as Stringable,
|
|
1247
|
-
|
|
1248
|
-
|
|
1238
|
+
Oe as of,
|
|
1239
|
+
Qe as str
|
|
1249
1240
|
};
|