@tolki/str 1.7.0 → 1.8.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 +22 -0
- package/dist/ascii/index.js +24 -39
- package/dist/base64/index.js +90 -118
- package/dist/convertcase/index.js +29 -44
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -141
- package/dist/markdown/index.js +29 -31
- package/dist/pluralizer/index.js +30 -93
- package/dist/random/index.js +30 -42
- package/dist/replacer/index.d.ts +1 -0
- package/dist/replacer/index.d.ts.map +1 -1
- package/dist/replacer/index.js +39 -60
- package/dist/str.d.ts +9 -8
- package/dist/str.d.ts.map +1 -1
- package/dist/str.js +687 -1006
- package/dist/stringable/index.js +462 -1329
- package/dist/transliterate/index.js +5 -6
- package/dist/trimmer/index.js +83 -88
- package/dist/ulid/index.js +42 -52
- package/dist/uuid/index.js +33 -43
- package/package.json +36 -22
package/dist/markdown/index.js
CHANGED
|
@@ -1,34 +1,32 @@
|
|
|
1
|
-
import { isArray as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import { isArray as e } from "@tolki/utils";
|
|
2
|
+
import t from "markdown-it";
|
|
3
|
+
import n from "markdown-it-anchor";
|
|
4
|
+
import r from "markdown-it-task-lists";
|
|
5
|
+
// src/markdown/index.ts
|
|
6
|
+
function i(e, t = {
|
|
7
|
+
gfm: !0,
|
|
8
|
+
anchors: !1
|
|
9
|
+
}, n = []) {
|
|
10
|
+
return e === null ? "" : o(t, n).render(e);
|
|
7
11
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
12
|
+
function a(e, t = { gfm: !0 }, n = []) {
|
|
13
|
+
return e === null ? "" : o(t, n).renderInline(e);
|
|
10
14
|
}
|
|
11
|
-
function i
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
e.use(f);
|
|
28
|
-
return e;
|
|
15
|
+
function o(i, a) {
|
|
16
|
+
let { html: o = !1, linkify: s = !0, breaks: c = !0, gfm: l = !0, anchors: u = !1, allowUnsafeLinks: d = !1, ...f } = i, p = new t({
|
|
17
|
+
html: o,
|
|
18
|
+
linkify: s,
|
|
19
|
+
breaks: c,
|
|
20
|
+
...f
|
|
21
|
+
});
|
|
22
|
+
d && (p.validateLink = () => !0), l && p.use(r, {
|
|
23
|
+
label: !0,
|
|
24
|
+
labelAfter: !0
|
|
25
|
+
}), u && p.use(n, typeof u == "object" ? u : {});
|
|
26
|
+
for (let t of a) if (e(t)) {
|
|
27
|
+
let [e, n] = t;
|
|
28
|
+
p.use(e, n);
|
|
29
|
+
} else p.use(t);
|
|
30
|
+
return p;
|
|
29
31
|
}
|
|
30
|
-
export {
|
|
31
|
-
L as inlineMarkdown,
|
|
32
|
-
i as markDownRenderer,
|
|
33
|
-
A as markdown
|
|
34
|
-
};
|
|
32
|
+
export { a as inlineMarkdown, o as markDownRenderer, i as markdown };
|
package/dist/pluralizer/index.js
CHANGED
|
@@ -1,104 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"cattle",
|
|
10
|
-
"chassis",
|
|
11
|
-
"compensation",
|
|
12
|
-
"coreopsis",
|
|
13
|
-
"data",
|
|
14
|
-
"deer",
|
|
15
|
-
"education",
|
|
16
|
-
"emoji",
|
|
17
|
-
"equipment",
|
|
18
|
-
"evidence",
|
|
19
|
-
"feedback",
|
|
20
|
-
"firmware",
|
|
21
|
-
"fish",
|
|
22
|
-
"furniture",
|
|
23
|
-
"gold",
|
|
24
|
-
"hardware",
|
|
25
|
-
"information",
|
|
26
|
-
"jedi",
|
|
27
|
-
"kin",
|
|
28
|
-
"knowledge",
|
|
29
|
-
"love",
|
|
30
|
-
"metadata",
|
|
31
|
-
"money",
|
|
32
|
-
"moose",
|
|
33
|
-
"news",
|
|
34
|
-
"nutrition",
|
|
35
|
-
"offspring",
|
|
36
|
-
"plankton",
|
|
37
|
-
"pokemon",
|
|
38
|
-
"police",
|
|
39
|
-
"rain",
|
|
40
|
-
"recommended",
|
|
41
|
-
"related",
|
|
42
|
-
"rice",
|
|
43
|
-
"series",
|
|
44
|
-
"sheep",
|
|
45
|
-
"software",
|
|
46
|
-
"species",
|
|
47
|
-
"swine",
|
|
48
|
-
"traffic",
|
|
49
|
-
"wheat"
|
|
50
|
-
]
|
|
51
|
-
};
|
|
52
|
-
function d(e, n = 2) {
|
|
53
|
-
const t = e.split(/(?=[A-Z])/), r = String(t.pop());
|
|
54
|
-
return t.join("") + a(r, n);
|
|
1
|
+
import { isNumber as e, isUndefined as t } from "@tolki/utils";
|
|
2
|
+
import { format as n } from "@tolki/num";
|
|
3
|
+
import r from "pluralize";
|
|
4
|
+
// src/pluralizer/index.ts
|
|
5
|
+
var i, a = { uncountable: /* @__PURE__ */ "audio.bison.cattle.chassis.compensation.coreopsis.data.deer.education.emoji.equipment.evidence.feedback.firmware.fish.furniture.gold.hardware.information.jedi.kin.knowledge.love.metadata.money.moose.news.nutrition.offspring.plankton.pokemon.police.rain.recommended.related.rice.series.sheep.software.species.swine.traffic.wheat".split(".") };
|
|
6
|
+
function o(e, t = 2) {
|
|
7
|
+
let n = e.split(/(?=[A-Z])/), r = String(n.pop());
|
|
8
|
+
return n.join("") + c(r, t);
|
|
55
9
|
}
|
|
56
|
-
function
|
|
57
|
-
|
|
10
|
+
function s(e, t = 2) {
|
|
11
|
+
return o(e, t);
|
|
58
12
|
}
|
|
59
|
-
function
|
|
60
|
-
|
|
61
|
-
|
|
13
|
+
function c(t, r = 2, i = !1) {
|
|
14
|
+
let a = e(r) ? r : r.length;
|
|
15
|
+
return (i ? n(a) + " " : "") + u(t, a);
|
|
62
16
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
17
|
+
function l(e, t) {
|
|
18
|
+
return c(e, t, !0);
|
|
65
19
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
return e;
|
|
69
|
-
const t = o().plural(e);
|
|
70
|
-
return s(t, e);
|
|
20
|
+
function u(e, t) {
|
|
21
|
+
return Math.abs(t) === 1 || f(e) ? e : h(g().plural(e), e);
|
|
71
22
|
}
|
|
72
|
-
function
|
|
73
|
-
|
|
74
|
-
return s(n, e);
|
|
23
|
+
function d(e) {
|
|
24
|
+
return h(g().singular(e), e);
|
|
75
25
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
26
|
+
function f(e) {
|
|
27
|
+
return a.uncountable.includes(e.toLowerCase());
|
|
78
28
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
29
|
+
function p(e = "") {
|
|
30
|
+
return g().isPlural(e);
|
|
81
31
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
32
|
+
function m(e = "") {
|
|
33
|
+
return g().isSingular(e);
|
|
84
34
|
}
|
|
85
|
-
function
|
|
86
|
-
|
|
35
|
+
function h(e, t) {
|
|
36
|
+
return t.toLowerCase() === t ? e.toLowerCase() : t.toUpperCase() === t ? e.toUpperCase() : t[0] && t[0].toUpperCase() + t.slice(1) === t ? (e[0] ?? "").toUpperCase() + e.slice(1) : e;
|
|
87
37
|
}
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
(e) => i.addUncountableRule(e)
|
|
91
|
-
)), i;
|
|
38
|
+
function g() {
|
|
39
|
+
return t(i) && (i = r, a.uncountable.forEach((e) => i.addUncountableRule(e))), i;
|
|
92
40
|
}
|
|
93
|
-
export {
|
|
94
|
-
U as counted,
|
|
95
|
-
o as inflector,
|
|
96
|
-
S as isPlural,
|
|
97
|
-
j as isSingular,
|
|
98
|
-
s as matchCase,
|
|
99
|
-
a as plural,
|
|
100
|
-
C as pluralPascal,
|
|
101
|
-
d as pluralStudly,
|
|
102
|
-
k as singular,
|
|
103
|
-
g as uncountable
|
|
104
|
-
};
|
|
41
|
+
export { l as counted, g as inflector, p as isPlural, m as isSingular, h as matchCase, c as plural, s as pluralPascal, o as pluralStudly, d as singular, f as uncountable };
|
package/dist/random/index.js
CHANGED
|
@@ -1,45 +1,33 @@
|
|
|
1
|
-
import { bytesToBase64 as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { bytesToBase64 as e } from "../base64/index.js";
|
|
2
|
+
// src/random/index.ts
|
|
3
|
+
function t(t = 16) {
|
|
4
|
+
if (!Number.isFinite(t) || t <= 0) return "";
|
|
5
|
+
let n = "";
|
|
6
|
+
for (; n.length < t;) {
|
|
7
|
+
let i = t - n.length, a = r(Math.ceil(i / 3) * 3), o = e(a).replace(/[/+=]/g, "");
|
|
8
|
+
n += o.slice(0, i);
|
|
9
|
+
}
|
|
10
|
+
return n;
|
|
11
11
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
if (r % 8 !== 0) {
|
|
28
|
-
const s = 8 - r % 8;
|
|
29
|
-
n = n >> s & (1 << r) - 1;
|
|
30
|
-
}
|
|
31
|
-
if (n <= o)
|
|
32
|
-
return e + n;
|
|
33
|
-
}
|
|
12
|
+
function n(e, t) {
|
|
13
|
+
if (!Number.isInteger(e) || !Number.isInteger(t)) throw TypeError("randomInt bounds must be safe integers");
|
|
14
|
+
if (e > t) throw RangeError("randomInt min must be <= max");
|
|
15
|
+
if (e === t) return e;
|
|
16
|
+
if (Math.abs(e) > 2 ** 53 - 1 || Math.abs(t) > 2 ** 53 - 1) throw RangeError("Bounds exceed MAX_SAFE_INTEGER");
|
|
17
|
+
let n = t - e, i = Math.floor(Math.log2(n)) + 1, a = Math.ceil(i / 8);
|
|
18
|
+
for (;;) {
|
|
19
|
+
let t = r(a), o = 0;
|
|
20
|
+
for (let e = 0; e < a; e++) o = o << 8 | t[e];
|
|
21
|
+
if (i % 8 != 0) {
|
|
22
|
+
let e = 8 - i % 8;
|
|
23
|
+
o = o >> e & (1 << i) - 1;
|
|
24
|
+
}
|
|
25
|
+
if (o <= n) return e + o;
|
|
26
|
+
}
|
|
34
27
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return globalThis.crypto.getRandomValues(new Uint8Array(e));
|
|
40
|
-
throw new Error("Secure randomness not available in this environment");
|
|
28
|
+
function r(e) {
|
|
29
|
+
if (e <= 0) return /* @__PURE__ */ new Uint8Array();
|
|
30
|
+
if (typeof globalThis.crypto?.getRandomValues == "function") return globalThis.crypto.getRandomValues(new Uint8Array(e));
|
|
31
|
+
throw Error("Secure randomness not available in this environment");
|
|
41
32
|
}
|
|
42
|
-
export {
|
|
43
|
-
l as randomInt,
|
|
44
|
-
f as randomString
|
|
45
|
-
};
|
|
33
|
+
export { n as randomInt, t as randomString };
|
package/dist/replacer/index.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare function substr(string: string, start: number, length?: number |
|
|
|
17
17
|
* @param offset - The starting position for the search. If negative, it starts that many characters from the end of the string.
|
|
18
18
|
* @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
19
|
* @returns The number of occurrences of the substring within the specified segment.
|
|
20
|
+
* @throws Error for an empty needle, as PHP's substr_count() throws its ValueError
|
|
20
21
|
*
|
|
21
22
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#substrcount
|
|
22
23
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replacer/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,CAWR;AAED
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/replacer/index.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AACH,wBAAgB,MAAM,CAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,CAWR;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CACvB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAM,GAAG,IAAW,GAC7B,MAAM,CAkBR;AAED;;;;;;;;;;;GAWG;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,66 +1,45 @@
|
|
|
1
|
-
import { isArray as
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { isArray as e, isObject as t, isString as n } from "@tolki/utils";
|
|
2
|
+
// src/replacer/index.ts
|
|
3
|
+
function r(e, t, n = null) {
|
|
4
|
+
let r = Array.from(e), i = r.length, { start: a, end: o } = s(i, t, n);
|
|
5
|
+
return a >= i || o <= a ? "" : r.slice(a, o).join("");
|
|
5
6
|
}
|
|
6
|
-
function
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (u >= c || o <= u)
|
|
11
|
-
return 0;
|
|
12
|
-
const i = n.slice(u, o).join("");
|
|
13
|
-
return p(i, s);
|
|
7
|
+
function i(e, t, n = 0, r = null) {
|
|
8
|
+
if (t === "") throw Error("substr_count(): Argument #2 ($needle) must not be empty");
|
|
9
|
+
let i = Array.from(e), a = i.length, { start: o, end: l } = s(a, n, r);
|
|
10
|
+
return o >= a || l <= o ? 0 : c(i.slice(o, l).join(""), t);
|
|
14
11
|
}
|
|
15
|
-
function
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return f(e, i, r, t);
|
|
24
|
-
}
|
|
25
|
-
const c = a(r) ? r : null, u = a(t) ? t : null, o = (i, l) => f(
|
|
26
|
-
i,
|
|
27
|
-
String(n === null ? s : n[l] ?? ""),
|
|
28
|
-
c === null ? r : c[l] ?? 0,
|
|
29
|
-
u === null ? t : u[l] ?? null
|
|
30
|
-
);
|
|
31
|
-
return a(e) ? e.map((i, l) => o(i, l)) : Object.fromEntries(
|
|
32
|
-
Object.entries(e).map(([i, l], b) => [
|
|
33
|
-
i,
|
|
34
|
-
o(l, b)
|
|
35
|
-
])
|
|
36
|
-
);
|
|
12
|
+
function a(r, i, a = 0, s = null) {
|
|
13
|
+
let c = e(i) ? i : t(i) ? Object.values(i) : null;
|
|
14
|
+
if (n(r)) {
|
|
15
|
+
if (e(a) || e(s)) throw TypeError("substrReplace(): offset and length must be numbers when the subject is a string");
|
|
16
|
+
return o(r, String(c === null ? i : c[0] ?? ""), a, s);
|
|
17
|
+
}
|
|
18
|
+
let l = e(a) ? a : null, u = e(s) ? s : null, d = (e, t) => o(e, String(c === null ? i : c[t] ?? ""), l === null ? a : l[t] ?? 0, u === null ? s : u[t] ?? null);
|
|
19
|
+
return e(r) ? r.map((e, t) => d(e, t)) : Object.fromEntries(Object.entries(r).map(([e, t], n) => [e, d(t, n)]));
|
|
37
20
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let l;
|
|
44
|
-
return t === null ? l = "" : l = i.slice(t).join(""), o + s + l;
|
|
21
|
+
function o(e, t, n, r) {
|
|
22
|
+
let i = Array.from(e), a = i.length, o = n >= 0 ? n : a + n;
|
|
23
|
+
o < 0 && (o = 0), o > a && (o = a);
|
|
24
|
+
let s = i.slice(0, o).join(""), c = i.slice(o), l;
|
|
25
|
+
return l = r === null ? "" : c.slice(r).join(""), s + t + l;
|
|
45
26
|
}
|
|
46
|
-
function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
27
|
+
function s(e, t, n) {
|
|
28
|
+
let r = t >= 0 ? t : e + t;
|
|
29
|
+
r < 0 && (r = 0), r > e && (r = e);
|
|
30
|
+
let i;
|
|
31
|
+
return i = n == null ? e : n < 0 ? e + n : r + n, i = Math.max(0, Math.min(i, e)), {
|
|
32
|
+
start: r,
|
|
33
|
+
end: i
|
|
34
|
+
};
|
|
51
35
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
return r;
|
|
36
|
+
function c(e, t) {
|
|
37
|
+
let n = 0, r = 0;
|
|
38
|
+
for (;;) {
|
|
39
|
+
let i = e.indexOf(t, r);
|
|
40
|
+
if (i === -1) break;
|
|
41
|
+
n++, r = i + t.length;
|
|
42
|
+
}
|
|
43
|
+
return n;
|
|
61
44
|
}
|
|
62
|
-
export {
|
|
63
|
-
d as substr,
|
|
64
|
-
y as substrCount,
|
|
65
|
-
S as substrReplace
|
|
66
|
-
};
|
|
45
|
+
export { r as substr, i as substrCount, a as substrReplace };
|
package/dist/str.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { StringSubject, StringSubjectResult } from '@tolki/types';
|
|
1
2
|
/**
|
|
2
3
|
* Return the remainder of a string after the first occurrence of a given value.
|
|
3
4
|
*
|
|
@@ -504,14 +505,15 @@ export declare function toStringOr(value: unknown, fallback: string): string;
|
|
|
504
505
|
*
|
|
505
506
|
* @param search - The value or values to search for
|
|
506
507
|
* @param replacement - The value or values to replace with
|
|
507
|
-
* @param subject - The string or
|
|
508
|
+
* @param subject - The string, or the strings in a list, object, Map, collection or iterable
|
|
508
509
|
* @param caseSensitive - Whether the search should be case-sensitive (default: true)
|
|
509
|
-
* @returns The resulting string or
|
|
510
|
+
* @returns The resulting string, or the strings in the subject's shape: a list for a list or iterable, an object for an
|
|
511
|
+
* object, a Map for a Map, and what all() holds for a collection
|
|
510
512
|
* @throws TypeError when the search term is a string but the replacement is a list, mirroring PHP's str_replace
|
|
511
513
|
*
|
|
512
514
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#replace
|
|
513
515
|
*/
|
|
514
|
-
export declare function replace<
|
|
516
|
+
export declare function replace<TSubject extends StringSubject<TSubject>>(search: string | Iterable<string>, replacement: string | Iterable<string>, subject: TSubject, caseSensitive?: boolean): StringSubjectResult<TSubject>;
|
|
515
517
|
/**
|
|
516
518
|
* Replace the first occurrence of a given value in the string.
|
|
517
519
|
*
|
|
@@ -587,15 +589,14 @@ export declare function stripTags(value: string): string;
|
|
|
587
589
|
* mirroring Laravel's behavior.
|
|
588
590
|
*
|
|
589
591
|
* @param search - The string or strings to remove
|
|
590
|
-
* @param subject - The string or strings
|
|
592
|
+
* @param subject - The string, or the strings in a list, object, Map, collection or iterable
|
|
591
593
|
* @param caseSensitive - Whether the search should be case-sensitive (default: true)
|
|
592
|
-
* @returns The resulting string or
|
|
594
|
+
* @returns The resulting string, or the strings in the subject's shape: a list for a list or iterable, an object for an
|
|
595
|
+
* object, a Map for a Map, and what all() holds for a collection
|
|
593
596
|
*
|
|
594
597
|
* @see https://tolki.abe.dev/strings/string-utilities-list.html#remove
|
|
595
598
|
*/
|
|
596
|
-
export declare function remove(search: string | Iterable<string>, subject:
|
|
597
|
-
export declare function remove(search: string | Iterable<string>, subject: Iterable<string>, caseSensitive?: boolean): string[];
|
|
598
|
-
export declare function remove(search: string | Iterable<string>, subject: string | Iterable<string>, caseSensitive?: boolean): string | string[];
|
|
599
|
+
export declare function remove<TSubject extends StringSubject<TSubject>>(search: string | Iterable<string>, subject: TSubject, caseSensitive?: boolean): StringSubjectResult<TSubject>;
|
|
599
600
|
/**
|
|
600
601
|
* Reverse the given string.
|
|
601
602
|
*
|
package/dist/str.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"str.d.ts","sourceRoot":"","sources":["../src/str.ts"],"names":[],"mappings":"
|
|
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;AA4CvE;;;;;;;;GAQG;AACH,wBAAgB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAatE;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAY1E;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAQvE;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAY3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,OAAO,CACnB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GACpB,MAAM,CAMR;AAED;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CACxB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,EAAE,EAAE,MAAM,GAAG,MAAM,GACpB,MAAM,CAMR;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAU3C;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,M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