@tolki/str 1.8.1 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -1
- package/dist/convertcase/index.js +4 -1
- package/dist/index.d.ts +13 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/replacer/index.d.ts +3 -0
- package/dist/replacer/index.d.ts.map +1 -1
- package/dist/replacer/index.js +24 -24
- package/dist/str.d.ts +16 -2
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +198 -186
- package/dist/stringable/index.d.ts +20 -3
- package/dist/stringable/index.d.ts.map +1 -1
- package/dist/stringable/index.js +5 -3
- package/dist/width/index.d.ts +19 -0
- package/dist/width/index.d.ts.map +1 -0
- package/dist/width/index.js +155 -0
- package/package.json +8 -23
package/README.md
CHANGED
|
@@ -770,6 +770,8 @@ const result = length("Tolki JS");
|
|
|
770
770
|
// result is 8
|
|
771
771
|
```
|
|
772
772
|
|
|
773
|
+
Characters are Unicode code points, as PHP's `mb_strlen` counts them, so an emoji counts as one.
|
|
774
|
+
|
|
773
775
|
#### limit
|
|
774
776
|
|
|
775
777
|
Limit the number of characters in a string.
|
|
@@ -782,6 +784,8 @@ const result = limit("The quick brown fox jumps over the lazy dog", 20);
|
|
|
782
784
|
// result is "The quick brown fox..."
|
|
783
785
|
```
|
|
784
786
|
|
|
787
|
+
The limit is a display width, as in Laravel: wide characters such as emoji and Chinese, Japanese or Korean characters count as two, so `limit("😀😀😀", 4)` gives `"😀😀..."`. A negative limit past the string's full width throws, as it does in PHP.
|
|
788
|
+
|
|
785
789
|
You may pass a third argument to specify the string to append to the truncated string (defaults to an ellipsis):
|
|
786
790
|
|
|
787
791
|
```javascript
|
|
@@ -967,13 +971,15 @@ import { padBoth } from "@tolki/str";
|
|
|
967
971
|
|
|
968
972
|
const result = padBoth("James", 10, "_");
|
|
969
973
|
|
|
970
|
-
// result is "
|
|
974
|
+
// result is "__James___"
|
|
971
975
|
|
|
972
976
|
const result2 = padBoth("James", 10);
|
|
973
977
|
|
|
974
978
|
// result2 is " James "
|
|
975
979
|
```
|
|
976
980
|
|
|
981
|
+
The length counts characters, so an emoji counts as one. An empty pad string throws when the value needs padding, as it does in PHP.
|
|
982
|
+
|
|
977
983
|
#### padLeft
|
|
978
984
|
|
|
979
985
|
Pad the left side of a string with another string to a certain length.
|
|
@@ -990,6 +996,8 @@ const result2 = padLeft("James", 10);
|
|
|
990
996
|
// result2 is " James"
|
|
991
997
|
```
|
|
992
998
|
|
|
999
|
+
The length counts characters, so an emoji counts as one. An empty pad string throws when the value needs padding, as it does in PHP.
|
|
1000
|
+
|
|
993
1001
|
#### padRight
|
|
994
1002
|
|
|
995
1003
|
Pad the right side of a string with another string to a certain length.
|
|
@@ -1006,6 +1014,8 @@ const result2 = padRight("James", 10);
|
|
|
1006
1014
|
// result2 is "James "
|
|
1007
1015
|
```
|
|
1008
1016
|
|
|
1017
|
+
The length counts characters, so an emoji counts as one. An empty pad string throws when the value needs padding, as it does in PHP.
|
|
1018
|
+
|
|
1009
1019
|
#### pascal
|
|
1010
1020
|
|
|
1011
1021
|
Convert a value to Pascal case.
|
|
@@ -1122,6 +1132,8 @@ const result2 = position("Hello, World!", "W");
|
|
|
1122
1132
|
// result2 is 7
|
|
1123
1133
|
```
|
|
1124
1134
|
|
|
1135
|
+
Positions count characters, so an emoji counts as one. An empty needle returns the offset, and an offset outside the string throws, as in PHP.
|
|
1136
|
+
|
|
1125
1137
|
#### random
|
|
1126
1138
|
|
|
1127
1139
|
Generate a more truly "random" alpha-numeric string.
|
|
@@ -26,7 +26,10 @@ function c(a, o) {
|
|
|
26
26
|
switch (o) {
|
|
27
27
|
case i.upper: return n(a);
|
|
28
28
|
case i.lower: return t(a);
|
|
29
|
-
case i.title: return a.replace(/\p{L}[\p{L}\p{M}\p{N}]*/gu, (e) =>
|
|
29
|
+
case i.title: return a.replace(/\p{L}[\p{L}\p{M}\p{N}]*/gu, (e) => {
|
|
30
|
+
let t = Array.from(e);
|
|
31
|
+
return t.slice(0, 1).join("").toUpperCase() + t.slice(1).join("").toLowerCase();
|
|
32
|
+
});
|
|
30
33
|
case i.fold: return a.normalize("NFKD").toLowerCase();
|
|
31
34
|
case i.simple: return a.replace(/[^a-z0-9]+/g, " ").trim();
|
|
32
35
|
case i.lower_simple: return e(a).replace(/[^a-z0-9]+/g, " ").trim();
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export * from './ascii';
|
|
2
|
-
export * from './base64';
|
|
3
|
-
export * from './convertcase';
|
|
4
|
-
export * from './markdown';
|
|
5
|
-
export * from './pluralizer';
|
|
6
|
-
export * from './random';
|
|
7
|
-
export * from './replacer';
|
|
8
|
-
export * from './str';
|
|
9
|
-
export * from './stringable';
|
|
10
|
-
export * from './transliterate';
|
|
11
|
-
export * from './trimmer';
|
|
12
|
-
export * from './ulid';
|
|
13
|
-
export * from './uuid';
|
|
1
|
+
export * from './ascii/index.js';
|
|
2
|
+
export * from './base64/index.js';
|
|
3
|
+
export * from './convertcase/index.js';
|
|
4
|
+
export * from './markdown/index.js';
|
|
5
|
+
export * from './pluralizer/index.js';
|
|
6
|
+
export * from './random/index.js';
|
|
7
|
+
export * from './replacer/index.js';
|
|
8
|
+
export * from './str.js';
|
|
9
|
+
export * from './stringable/index.js';
|
|
10
|
+
export * from './transliterate/index.js';
|
|
11
|
+
export * from './trimmer/index.js';
|
|
12
|
+
export * from './ulid/index.js';
|
|
13
|
+
export * from './uuid/index.js';
|
|
14
14
|
export type { StringSubject, StringSubjectResult } from '@tolki/types';
|
|
15
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC;AACzB,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,iBAAiB,CAAC;AAChC,YAAY,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/replacer/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* @param start - The starting position. If negative, it starts that many characters from the end of the string.
|
|
6
6
|
* @param length - The number of characters to return. If omitted or null, returns all characters from start to the end of the string. If negative, omits that many characters from the end.
|
|
7
7
|
* @returns The extracted substring.
|
|
8
|
+
* @throws TypeError for a NaN or infinite start or length, as PHP's mb_substr() does
|
|
8
9
|
*
|
|
9
10
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#substr
|
|
10
11
|
*/
|
|
@@ -18,6 +19,7 @@ export declare function substr(string: string, start: number, length?: number |
|
|
|
18
19
|
* @param length - The length of the segment to search within. If omitted or null, searches to the end of the string. If negative, omits that many characters from the end.
|
|
19
20
|
* @returns The number of occurrences of the substring within the specified segment.
|
|
20
21
|
* @throws Error for an empty needle, as PHP's substr_count() throws its ValueError
|
|
22
|
+
* @throws TypeError for a NaN or infinite offset or length, as PHP's mb_substr() does
|
|
21
23
|
*
|
|
22
24
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#substrcount
|
|
23
25
|
*/
|
|
@@ -31,6 +33,7 @@ export declare function substrCount(haystack: string, needle: string, offset?: n
|
|
|
31
33
|
* @param offset - The starting position for the replacement, or an array of positions applied positionally. If negative, it starts that many characters from the end of the string.
|
|
32
34
|
* @param length - The number of characters to replace, or an array of lengths applied positionally. If omitted or null, replaces all characters from offset to the end of the string. If negative, omits that many characters from the end.
|
|
33
35
|
* @returns The modified string, or an array/object of modified strings mirroring the subject's shape and keys.
|
|
36
|
+
* @throws TypeError for a NaN or infinite offset or length, as PHP's mb_substr() does
|
|
34
37
|
*
|
|
35
38
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#substrreplace
|
|
36
39
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replacer/index.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replacer/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;GAUG;AAEH,wBAAgB,MAAM,CAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,CAWR;AAED;;;;;;;;;;;;GAYG;AAEH,wBAAgB,WAAW,CACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,CAmBR;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CACzB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnD,MAAM,CAAC,EAAE,MAAM,EACf,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GACvB,MAAM,CAAC;AACV,wBAAgB,aAAa,CACzB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAClC,MAAM,EAAE,CAAC;AACZ,wBAAgB,aAAa,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACjE,MAAM,EAAE,QAAQ,EAChB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAClC,MAAM,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC,CAAC;AAClC,wBAAgB,aAAa,CACzB,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAClD,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EACnD,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,EAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,IAAI,GAClC,MAAM,GAAG,MAAM,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC"}
|
package/dist/replacer/index.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { isArray as e, isObject as t, isString as n } from "@tolki/utils";
|
|
1
|
+
import { isArray as e, isObject as t, isString as n, phpIntArgument as r } from "@tolki/utils";
|
|
2
2
|
// src/replacer/index.ts
|
|
3
3
|
/* @__NO_SIDE_EFFECTS__ */
|
|
4
|
-
function
|
|
5
|
-
let r = Array.from(e), i = r.length, { start: a, end: o } =
|
|
4
|
+
function i(e, t, n = null) {
|
|
5
|
+
let r = Array.from(e), i = r.length, { start: a, end: o } = c(i, t, n);
|
|
6
6
|
return a >= i || o <= a ? "" : r.slice(a, o).join("");
|
|
7
7
|
}
|
|
8
8
|
/* @__NO_SIDE_EFFECTS__ */
|
|
9
|
-
function
|
|
9
|
+
function a(e, t, n = 0, r = null) {
|
|
10
|
+
let i = Array.from(e), a = i.length, { start: o, end: s } = c(a, n, r);
|
|
10
11
|
if (t === "") throw Error("substr_count(): Argument #2 ($needle) must not be empty");
|
|
11
|
-
|
|
12
|
-
return o >= a || l <= o ? 0 : c(i.slice(o, l).join(""), t);
|
|
12
|
+
return o >= a || s <= o ? 0 : l(i.slice(o, s).join(""), t);
|
|
13
13
|
}
|
|
14
14
|
/* @__NO_SIDE_EFFECTS__ */
|
|
15
|
-
function
|
|
15
|
+
function o(r, i, a = 0, o = null) {
|
|
16
16
|
let c = e(i) ? i : t(i) ? Object.values(i) : null;
|
|
17
17
|
if (n(r)) {
|
|
18
|
-
if (e(a) || e(
|
|
19
|
-
return
|
|
18
|
+
if (e(a) || e(o)) throw TypeError("substrReplace(): offset and length must be numbers when the subject is a string");
|
|
19
|
+
return s(r, String(c === null ? i : c[0] ?? ""), a, o);
|
|
20
20
|
}
|
|
21
|
-
let l = e(a) ? a : null, u = e(
|
|
21
|
+
let l = e(a) ? a : null, u = e(o) ? o : null, d = (e, t) => s(e, String(c === null ? i : c[t] ?? ""), l === null ? a : l[t] ?? 0, u === null ? o : u[t] ?? null);
|
|
22
22
|
return e(r) ? r.map((e, t) => d(e, t)) : Object.fromEntries(Object.entries(r).map(([e, t], n) => [e, d(t, n)]));
|
|
23
23
|
}
|
|
24
|
-
function
|
|
25
|
-
let
|
|
26
|
-
|
|
27
|
-
let
|
|
28
|
-
return
|
|
24
|
+
function s(e, t, n, i) {
|
|
25
|
+
let a = Array.from(e), o = a.length, s = r(n, "mb_substr(): Argument #3 ($length) must be of type ?int, float given"), c = i === null ? null : r(i, "mb_substr(): Argument #2 ($start) must be of type int, float given"), l = s >= 0 ? s : o + s;
|
|
26
|
+
l < 0 && (l = 0), l > o && (l = o);
|
|
27
|
+
let u = a.slice(0, l).join(""), d = a.slice(l), f;
|
|
28
|
+
return f = c === null ? "" : d.slice(c).join(""), u + t + f;
|
|
29
29
|
}
|
|
30
|
-
function
|
|
31
|
-
let
|
|
32
|
-
|
|
33
|
-
let
|
|
34
|
-
return
|
|
35
|
-
start:
|
|
36
|
-
end:
|
|
30
|
+
function c(e, t, n) {
|
|
31
|
+
let i = r(t, "mb_substr(): Argument #2 ($start) must be of type int, float given"), a = n == null ? null : r(n, "mb_substr(): Argument #3 ($length) must be of type ?int, float given"), o = i >= 0 ? i : e + i;
|
|
32
|
+
o < 0 && (o = 0), o > e && (o = e);
|
|
33
|
+
let s;
|
|
34
|
+
return s = a === null ? e : a < 0 ? e + a : o + a, s = Math.max(0, Math.min(s, e)), {
|
|
35
|
+
start: o,
|
|
36
|
+
end: s
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function l(e, t) {
|
|
40
40
|
let n = 0, r = 0;
|
|
41
41
|
for (;;) {
|
|
42
42
|
let i = e.indexOf(t, r);
|
|
@@ -45,4 +45,4 @@ function c(e, t) {
|
|
|
45
45
|
}
|
|
46
46
|
return n;
|
|
47
47
|
}
|
|
48
|
-
export {
|
|
48
|
+
export { i as substr, a as substrCount, o as substrReplace };
|
package/dist/str.d.ts
CHANGED
|
@@ -76,6 +76,7 @@ export declare function camel(value: string): string;
|
|
|
76
76
|
* @param subject - The string to get the character from
|
|
77
77
|
* @param index - The index of the character to get
|
|
78
78
|
* @returns The character at the specified index, or false if the index is out of bounds
|
|
79
|
+
* @throws TypeError for a NaN index, as PHP's mb_substr() does
|
|
79
80
|
*
|
|
80
81
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#charat
|
|
81
82
|
*/
|
|
@@ -152,6 +153,7 @@ export declare function doesntContain(haystack: string, needles: string | Iterab
|
|
|
152
153
|
* @param value - The string to process
|
|
153
154
|
* @param character - The character or characters to deduplicate
|
|
154
155
|
* @returns The string with consecutive instances of the character(s) replaced by a single instance
|
|
156
|
+
* @throws SyntaxError for an empty character
|
|
155
157
|
*
|
|
156
158
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#deduplicate
|
|
157
159
|
*/
|
|
@@ -260,7 +262,7 @@ export declare function kebab(value: string): string;
|
|
|
260
262
|
* Return the length of the given string.
|
|
261
263
|
*
|
|
262
264
|
* @param value - The string to measure
|
|
263
|
-
* @returns The
|
|
265
|
+
* @returns The number of Unicode code points in the string
|
|
264
266
|
*
|
|
265
267
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#length
|
|
266
268
|
*/
|
|
@@ -269,10 +271,12 @@ export declare function length(value: string): number;
|
|
|
269
271
|
* Limit the number of characters in a string.
|
|
270
272
|
*
|
|
271
273
|
* @param value - The string to limit
|
|
272
|
-
* @param limit - The maximum
|
|
274
|
+
* @param limit - The maximum display width, where an emoji or a Chinese, Japanese or Korean character counts as two
|
|
273
275
|
* @param end - The string to append if the value is truncated
|
|
274
276
|
* @param preserveWords - Whether to preserve whole words when truncating
|
|
275
277
|
* @returns The limited string
|
|
278
|
+
* @throws Error for a negative limit past the string's full width, as PHP's mb_strimwidth() throws its ValueError
|
|
279
|
+
* @throws TypeError for a NaN limit, as PHP's mb_strimwidth() does
|
|
276
280
|
*
|
|
277
281
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#limit
|
|
278
282
|
*/
|
|
@@ -305,6 +309,7 @@ export declare function words(value: string, words?: number, end?: string): stri
|
|
|
305
309
|
* @param index - The starting index to begin masking (can be negative)
|
|
306
310
|
* @param length - The number of characters to mask (if null, mask to the end of the string)
|
|
307
311
|
* @returns The masked string
|
|
312
|
+
* @throws TypeError for a NaN or infinite index or length, as PHP's mb_substr() does
|
|
308
313
|
*
|
|
309
314
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#mask
|
|
310
315
|
*/
|
|
@@ -357,6 +362,8 @@ export declare function numbers(value: string | string[]): string | string[];
|
|
|
357
362
|
* @param length - The desired total length after padding
|
|
358
363
|
* @param pad - The string to use for padding
|
|
359
364
|
* @returns The padded string
|
|
365
|
+
* @throws Error for an empty pad string when the value needs padding, as PHP's mb_str_pad() throws its ValueError
|
|
366
|
+
* @throws TypeError for a NaN or infinite length, as PHP's mb_str_pad() does
|
|
360
367
|
*
|
|
361
368
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#padboth
|
|
362
369
|
*/
|
|
@@ -368,6 +375,8 @@ export declare function padBoth(value: string, length: number, pad?: string): st
|
|
|
368
375
|
* @param length - The desired total length after padding
|
|
369
376
|
* @param pad - The string to use for padding
|
|
370
377
|
* @returns The padded string
|
|
378
|
+
* @throws Error for an empty pad string when the value needs padding, as PHP's mb_str_pad() throws its ValueError
|
|
379
|
+
* @throws TypeError for a NaN or infinite length, as PHP's mb_str_pad() does
|
|
371
380
|
*
|
|
372
381
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#padleft
|
|
373
382
|
*/
|
|
@@ -379,6 +388,8 @@ export declare function padLeft(value: string, length: number, pad?: string): st
|
|
|
379
388
|
* @param length - The desired total length after padding
|
|
380
389
|
* @param pad - The string to use for padding
|
|
381
390
|
* @returns The padded string
|
|
391
|
+
* @throws Error for an empty pad string when the value needs padding, as PHP's mb_str_pad() throws its ValueError
|
|
392
|
+
* @throws TypeError for a NaN or infinite length, as PHP's mb_str_pad() does
|
|
382
393
|
*
|
|
383
394
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#padright
|
|
384
395
|
*/
|
|
@@ -420,6 +431,8 @@ export declare function password(length?: number, letters?: boolean, numbers?: b
|
|
|
420
431
|
* @param needle - The substring to search for
|
|
421
432
|
* @param offset - The position to start searching from (can be negative)
|
|
422
433
|
* @returns The position of the first occurrence or false if not found
|
|
434
|
+
* @throws Error If the offset is outside the haystack, as mb_strpos() does
|
|
435
|
+
* @throws TypeError If the offset is NaN or infinite, as mb_strpos() does
|
|
423
436
|
*
|
|
424
437
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#position
|
|
425
438
|
*/
|
|
@@ -726,6 +739,7 @@ export declare function swap(map: Record<string, string>, subject: string): stri
|
|
|
726
739
|
* @param value - The string to process
|
|
727
740
|
* @param limit - The number of characters to take (negative for from end)
|
|
728
741
|
* @returns The resulting substring
|
|
742
|
+
* @throws TypeError for a NaN or infinite limit, as Laravel's int $limit parameter does
|
|
729
743
|
*
|
|
730
744
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#take
|
|
731
745
|
*/
|
package/dist/str.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../src/str.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../src/str.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AA8CvE;;;;;;;;GAQG;AAEH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAatE;AAED;;;;;;;;GAQG;AAEH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAY1E;AAED;;;;;;;;GAQG;AAEH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAQvE;AAED;;;;;;;;GAQG;AAEH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAY3E;AAED;;;;;;;;;GASG;AAEH,wBAAgB,OAAO,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GACpB,MAAM,CAMR;AAED;;;;;;;;;GASG;AAEH,wBAAgB,YAAY,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,MAAM,EAC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