@tolki/str 1.0.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/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/ascii/index.d.ts +25 -0
- package/dist/ascii/index.d.ts.map +1 -0
- package/dist/ascii/index.js +46 -0
- package/dist/base64/index.d.ts +23 -0
- package/dist/base64/index.d.ts.map +1 -0
- package/dist/base64/index.js +124 -0
- package/dist/convertcase/index.d.ts +48 -0
- package/dist/convertcase/index.d.ts.map +1 -0
- package/dist/convertcase/index.js +49 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +138 -0
- package/dist/markdown/index.d.ts +49 -0
- package/dist/markdown/index.d.ts.map +1 -0
- package/dist/markdown/index.js +32 -0
- package/dist/pluralizer/index.d.ts +100 -0
- package/dist/pluralizer/index.d.ts.map +1 -0
- package/dist/pluralizer/index.js +99 -0
- package/dist/random/index.d.ts +28 -0
- package/dist/random/index.d.ts.map +1 -0
- package/dist/random/index.js +45 -0
- package/dist/replacer/index.d.ts +31 -0
- package/dist/replacer/index.d.ts.map +1 -0
- package/dist/replacer/index.js +42 -0
- package/dist/str.d.ts +968 -0
- package/dist/str.d.ts.map +1 -0
- package/dist/str.js +939 -0
- package/dist/stringable/index.d.ts +952 -0
- package/dist/stringable/index.d.ts.map +1 -0
- package/dist/stringable/index.js +1249 -0
- package/dist/transliterate/index.d.ts +14 -0
- package/dist/transliterate/index.d.ts.map +1 -0
- package/dist/transliterate/index.js +7 -0
- package/dist/trimmer/index.d.ts +25 -0
- package/dist/trimmer/index.d.ts.map +1 -0
- package/dist/trimmer/index.js +128 -0
- package/dist/ulid/index.d.ts +79 -0
- package/dist/ulid/index.d.ts.map +1 -0
- package/dist/ulid/index.js +58 -0
- package/dist/uuid/index.d.ts +92 -0
- package/dist/uuid/index.d.ts.map +1 -0
- package/dist/uuid/index.js +50 -0
- package/package.json +126 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Abraham Arango
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transliterate a UTF-8 value to ASCII.
|
|
3
|
+
*
|
|
4
|
+
* @param value The value to transliterate.
|
|
5
|
+
* @return The transliterated ASCII string.
|
|
6
|
+
*
|
|
7
|
+
* @requires {@link https://www.npmjs.com/package/transliteration transliteration package}
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
*
|
|
11
|
+
* ascii('Héllo Wörld'); -> 'Hello World'
|
|
12
|
+
*/
|
|
13
|
+
export declare function ascii(value: string): string;
|
|
14
|
+
/**
|
|
15
|
+
* Generate a URL friendly "slug" from a given string.
|
|
16
|
+
*
|
|
17
|
+
* @param title - The string to convert to a slug
|
|
18
|
+
* @param separator - The word separator to use (default: "-")
|
|
19
|
+
* @param dictionary - An optional dictionary of replacements
|
|
20
|
+
* @returns The generated slug string
|
|
21
|
+
*
|
|
22
|
+
* @requires {@link https://www.npmjs.com/package/transliteration transliteration package}
|
|
23
|
+
*/
|
|
24
|
+
export declare function slug(title: string, separator?: string, dictionary?: Record<string, string>): string;
|
|
25
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ascii/index.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;GAWG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;;;GASG;AACH,wBAAgB,IAAI,CAChB,KAAK,EAAE,MAAM,EACb,SAAS,GAAE,MAAY,EACvB,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAiB,GACnD,MAAM,CAwER"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { lower as m } from "@tolki/str";
|
|
2
|
+
import { transliterate as w } from "transliteration";
|
|
3
|
+
function h(r) {
|
|
4
|
+
return w(r);
|
|
5
|
+
}
|
|
6
|
+
function A(r, i = "-", p = { "@": "at" }) {
|
|
7
|
+
const s = i, a = (t) => t.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&"), l = (t) => t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), u = (t) => {
|
|
8
|
+
let e = t;
|
|
9
|
+
const $ = s === "-" ? "_" : "-";
|
|
10
|
+
{
|
|
11
|
+
const o = new RegExp(`[${a($)}]+`, "gu");
|
|
12
|
+
e = e.replace(o, s);
|
|
13
|
+
}
|
|
14
|
+
if (p && typeof p == "object") {
|
|
15
|
+
const o = {};
|
|
16
|
+
for (const [c, n] of Object.entries(p))
|
|
17
|
+
o[c] = (s ?? "") + n + (s ?? "");
|
|
18
|
+
for (const [c, n] of Object.entries(o))
|
|
19
|
+
c !== "" && (e = e.split(c).join(n));
|
|
20
|
+
}
|
|
21
|
+
if (e = m(e), s === "")
|
|
22
|
+
return e = e.replace(/[^\p{L}\p{N}\s]+/gu, ""), e = e.replace(/[\s]+/gu, ""), e;
|
|
23
|
+
{
|
|
24
|
+
const o = new RegExp(
|
|
25
|
+
`[^${a(s)}\\p{L}\\p{N}\\s]+`,
|
|
26
|
+
"gu"
|
|
27
|
+
);
|
|
28
|
+
e = e.replace(o, "");
|
|
29
|
+
const c = new RegExp(
|
|
30
|
+
`[${a(s)}\\s]+`,
|
|
31
|
+
"gu"
|
|
32
|
+
);
|
|
33
|
+
e = e.replace(c, s);
|
|
34
|
+
const n = new RegExp(
|
|
35
|
+
`^${l(s)}+|${l(s)}+$`,
|
|
36
|
+
"gu"
|
|
37
|
+
);
|
|
38
|
+
return e = e.replace(n, ""), e;
|
|
39
|
+
}
|
|
40
|
+
}, f = u(r), g = u(h(r));
|
|
41
|
+
return Object.keys(p || {}).some((t) => /[A-Za-z0-9]/.test(t)) ? g : f;
|
|
42
|
+
}
|
|
43
|
+
export {
|
|
44
|
+
h as ascii,
|
|
45
|
+
A as slug
|
|
46
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert the given string to Base64 encoding.
|
|
3
|
+
*
|
|
4
|
+
* @param value - The string to encode.
|
|
5
|
+
* @returns The Base64 encoded string.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toBase64(value: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Convert raw bytes to a Base64 string using the same fallbacks as toBase64.
|
|
10
|
+
*
|
|
11
|
+
* @param bytes - The bytes to encode.
|
|
12
|
+
* @returns The Base64 encoded string.
|
|
13
|
+
*/
|
|
14
|
+
export declare function bytesToBase64(bytes: Uint8Array): string;
|
|
15
|
+
/**
|
|
16
|
+
* Decode the given Base64 encoded string.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The Base64 encoded string to decode.
|
|
19
|
+
* @param strict - Whether to enforce strict Base64 validation.
|
|
20
|
+
* @returns The decoded string or false if decoding fails.
|
|
21
|
+
*/
|
|
22
|
+
export declare function fromBase64(value: string, strict?: boolean): string | false;
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/base64/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAgC9C;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAsBvD;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CACtB,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,OAAe,GACxB,MAAM,GAAG,KAAK,CAqEhB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { isFunction as l } from "@tolki/utils";
|
|
2
|
+
function S(r) {
|
|
3
|
+
const o = h();
|
|
4
|
+
if (o.Buffer && l(o.Buffer.from))
|
|
5
|
+
return o.Buffer.from(r, "utf8").toString("base64");
|
|
6
|
+
if (l(o.btoa))
|
|
7
|
+
try {
|
|
8
|
+
const t = d(r);
|
|
9
|
+
return o.btoa(t);
|
|
10
|
+
} catch {
|
|
11
|
+
return o.btoa(r);
|
|
12
|
+
}
|
|
13
|
+
const e = d(r);
|
|
14
|
+
return p(e);
|
|
15
|
+
}
|
|
16
|
+
function T(r) {
|
|
17
|
+
const o = h();
|
|
18
|
+
if (o.Buffer && l(o.Buffer.from))
|
|
19
|
+
return o.Buffer.from(r).toString("base64");
|
|
20
|
+
let e = "";
|
|
21
|
+
for (let t = 0; t < r.length; t++)
|
|
22
|
+
e += String.fromCharCode(r[t]);
|
|
23
|
+
return l(o.btoa) ? o.btoa(e) : p(e);
|
|
24
|
+
}
|
|
25
|
+
function y(r, o = !1) {
|
|
26
|
+
const e = h();
|
|
27
|
+
let t = String(r);
|
|
28
|
+
if (o) {
|
|
29
|
+
const c = t.replace(/\s+/g, "");
|
|
30
|
+
if (!/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(c))
|
|
31
|
+
return !1;
|
|
32
|
+
t = c;
|
|
33
|
+
} else
|
|
34
|
+
t = t.replace(/[^A-Za-z0-9+/=]/g, "");
|
|
35
|
+
if (e.Buffer && l(e.Buffer.from))
|
|
36
|
+
try {
|
|
37
|
+
return e.Buffer.from(t, "base64").toString("utf8");
|
|
38
|
+
} catch {
|
|
39
|
+
return !1;
|
|
40
|
+
}
|
|
41
|
+
if (l(e.atob))
|
|
42
|
+
try {
|
|
43
|
+
const c = e.atob(t);
|
|
44
|
+
if (typeof e.TextDecoder == "function") {
|
|
45
|
+
const f = new Uint8Array(c.length);
|
|
46
|
+
for (let a = 0; a < c.length; a++)
|
|
47
|
+
f[a] = c.charCodeAt(a);
|
|
48
|
+
return new e.TextDecoder("utf-8").decode(f);
|
|
49
|
+
}
|
|
50
|
+
let n = "";
|
|
51
|
+
for (let f = 0; f < c.length; f++)
|
|
52
|
+
n += "%" + c.charCodeAt(f).toString(16).padStart(2, "0");
|
|
53
|
+
return decodeURIComponent(n);
|
|
54
|
+
} catch {
|
|
55
|
+
return !1;
|
|
56
|
+
}
|
|
57
|
+
try {
|
|
58
|
+
const c = m(t);
|
|
59
|
+
return C(c);
|
|
60
|
+
} catch {
|
|
61
|
+
return !1;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function h() {
|
|
65
|
+
return globalThis;
|
|
66
|
+
}
|
|
67
|
+
function d(r) {
|
|
68
|
+
return encodeURIComponent(r).replace(
|
|
69
|
+
/%([0-9A-F]{2})/g,
|
|
70
|
+
(o, e) => String.fromCharCode(parseInt(e, 16))
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function p(r) {
|
|
74
|
+
const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
75
|
+
let e = "";
|
|
76
|
+
for (let t = 0; t < r.length; t += 3) {
|
|
77
|
+
const c = r.charCodeAt(t), n = r.charCodeAt(t + 1), f = r.charCodeAt(t + 2), a = (c ?? 0) << 16 | (n ?? 0) << 8 | (f ?? 0), i = a >> 18 & 63, s = a >> 12 & 63, u = a >> 6 & 63, g = a & 63;
|
|
78
|
+
isNaN(n) ? e += o.charAt(i) + o.charAt(s) + "==" : isNaN(f) ? e += o.charAt(i) + o.charAt(s) + o.charAt(u) + "=" : e += o.charAt(i) + o.charAt(s) + o.charAt(u) + o.charAt(g);
|
|
79
|
+
}
|
|
80
|
+
return e;
|
|
81
|
+
}
|
|
82
|
+
function m(r) {
|
|
83
|
+
const o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", e = /* @__PURE__ */ new Map();
|
|
84
|
+
for (let n = 0; n < o.length; n++)
|
|
85
|
+
e.set(o[n], n);
|
|
86
|
+
const t = r.replace(/=+$/g, ""), c = [];
|
|
87
|
+
for (let n = 0; n < t.length; n += 4) {
|
|
88
|
+
const f = e.has(t[n]) ? e.get(t[n]) : 64, a = e.has(t[n + 1]) ? e.get(t[n + 1]) : 64, i = e.has(t[n + 2]) ? e.get(t[n + 2]) : 64, s = e.has(t[n + 3]) ? e.get(t[n + 3]) : 64, u = f << 18 | a << 12 | (i & 63) << 6 | s & 63, g = u >> 16 & 255, b = u >> 8 & 255, A = u & 255;
|
|
89
|
+
c.push(g), i !== 64 && c.push(b), s !== 64 && c.push(A);
|
|
90
|
+
}
|
|
91
|
+
return c;
|
|
92
|
+
}
|
|
93
|
+
function C(r) {
|
|
94
|
+
const o = h();
|
|
95
|
+
if (typeof o.TextDecoder == "function")
|
|
96
|
+
return new o.TextDecoder("utf-8").decode(new Uint8Array(r));
|
|
97
|
+
let e = "";
|
|
98
|
+
for (let t = 0; t < r.length; ) {
|
|
99
|
+
const c = r[t++];
|
|
100
|
+
if (c < 128)
|
|
101
|
+
e += String.fromCharCode(c);
|
|
102
|
+
else if (c < 224) {
|
|
103
|
+
const n = r[t++];
|
|
104
|
+
e += String.fromCharCode((c & 31) << 6 | n & 63);
|
|
105
|
+
} else if (c < 240) {
|
|
106
|
+
const n = r[t++], f = r[t++];
|
|
107
|
+
e += String.fromCharCode(
|
|
108
|
+
(c & 15) << 12 | (n & 63) << 6 | f & 63
|
|
109
|
+
);
|
|
110
|
+
} else {
|
|
111
|
+
const n = r[t++], f = r[t++], a = r[t++], s = ((c & 7) << 18 | (n & 63) << 12 | (f & 63) << 6 | a & 63) - 65536;
|
|
112
|
+
e += String.fromCharCode(
|
|
113
|
+
55296 + (s >> 10 & 1023),
|
|
114
|
+
56320 + (s & 1023)
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return e;
|
|
119
|
+
}
|
|
120
|
+
export {
|
|
121
|
+
T as bytesToBase64,
|
|
122
|
+
y as fromBase64,
|
|
123
|
+
S as toBase64
|
|
124
|
+
};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export declare const CaseTypes: {
|
|
2
|
+
readonly upper: "upper";
|
|
3
|
+
readonly lower: "lower";
|
|
4
|
+
readonly title: "title";
|
|
5
|
+
readonly fold: "fold";
|
|
6
|
+
readonly simple: "simple";
|
|
7
|
+
readonly lower_simple: "lower_simple";
|
|
8
|
+
readonly title_simple: "title_simple";
|
|
9
|
+
readonly fold_simple: "fold_simple";
|
|
10
|
+
};
|
|
11
|
+
export type ConvertCaseMode = (typeof CaseTypes)[keyof typeof CaseTypes];
|
|
12
|
+
/**
|
|
13
|
+
* Convert the case of a string.
|
|
14
|
+
*
|
|
15
|
+
* @param value - The string to convert.
|
|
16
|
+
* @param mode - The case conversion mode to apply. Defaults to 'fold'.
|
|
17
|
+
* @returns The converted string.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* convertCase('hello', CaseTypes.upper); -> 'HELLO'
|
|
22
|
+
*/
|
|
23
|
+
export declare function convertCase(value: string, mode?: ConvertCaseMode): string;
|
|
24
|
+
/**
|
|
25
|
+
* Convert the given string to upper-case.
|
|
26
|
+
*
|
|
27
|
+
* @param value - The string to convert.
|
|
28
|
+
* @returns The upper-case string.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
*
|
|
32
|
+
* upper("foo bar baz"); -> "FOO BAR BAZ"
|
|
33
|
+
* upper("foO bAr BaZ"); -> "FOO BAR BAZ"
|
|
34
|
+
*/
|
|
35
|
+
export declare function upper(value: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Convert the given string to proper case.
|
|
38
|
+
*
|
|
39
|
+
* @param value - The string to convert.
|
|
40
|
+
* @returns The proper-case string.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
*
|
|
44
|
+
* title("foo bar baz"); -> "Foo Bar Baz"
|
|
45
|
+
* title("foO bAr BaZ"); -> "Foo Bar Baz"
|
|
46
|
+
*/
|
|
47
|
+
export declare function title(value: string): string;
|
|
48
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/convertcase/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,SAAS;;;;;;;;;CASZ,CAAC;AAEX,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEzE;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CACvB,KAAK,EAAE,MAAM,EACb,IAAI,GAAE,eAAgC,GACvC,MAAM,CAER;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE3C"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { upperFirst as o, lowerFirst as l, toLower as s, toUpper as n } from "@tolki/utils";
|
|
2
|
+
const r = {
|
|
3
|
+
upper: "upper",
|
|
4
|
+
lower: "lower",
|
|
5
|
+
title: "title",
|
|
6
|
+
fold: "fold",
|
|
7
|
+
simple: "simple",
|
|
8
|
+
lower_simple: "lower_simple",
|
|
9
|
+
title_simple: "title_simple",
|
|
10
|
+
fold_simple: "fold_simple"
|
|
11
|
+
};
|
|
12
|
+
function a(e, p = r.fold) {
|
|
13
|
+
return i(e, p);
|
|
14
|
+
}
|
|
15
|
+
function m(e) {
|
|
16
|
+
return i(e, r.upper);
|
|
17
|
+
}
|
|
18
|
+
function u(e) {
|
|
19
|
+
return i(e, r.title);
|
|
20
|
+
}
|
|
21
|
+
function i(e, p) {
|
|
22
|
+
switch (p) {
|
|
23
|
+
case r.upper:
|
|
24
|
+
return n(e);
|
|
25
|
+
case r.lower:
|
|
26
|
+
return s(e);
|
|
27
|
+
case r.title:
|
|
28
|
+
return e.replace(
|
|
29
|
+
new RegExp("\\p{L}[\\p{L}\\p{M}\\p{N}]*", "gu"),
|
|
30
|
+
(t) => t.charAt(0).toUpperCase() + t.slice(1).toLowerCase()
|
|
31
|
+
);
|
|
32
|
+
case r.fold:
|
|
33
|
+
return e.normalize("NFKD").toLowerCase();
|
|
34
|
+
case r.simple:
|
|
35
|
+
return e.replace(/[^a-z0-9]+/g, " ").trim();
|
|
36
|
+
case r.lower_simple:
|
|
37
|
+
return l(e).replace(/[^a-z0-9]+/g, " ").trim();
|
|
38
|
+
case r.title_simple:
|
|
39
|
+
return e.split(/[^a-z0-9]+/g).map((t) => o(t)).join(" ");
|
|
40
|
+
case r.fold_simple:
|
|
41
|
+
return e.normalize("NFKD").toLowerCase().replace(/[^a-z0-9]+/g, " ").trim();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
r as CaseTypes,
|
|
46
|
+
a as convertCase,
|
|
47
|
+
u as title,
|
|
48
|
+
m as upper
|
|
49
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
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';
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAC3B,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { ascii as t, slug as a } from "./ascii/index.js";
|
|
2
|
+
import { bytesToBase64 as i, fromBase64 as o, toBase64 as n } from "./base64/index.js";
|
|
3
|
+
import { CaseTypes as c, convertCase as p, title as d, upper as u } from "./convertcase/index.js";
|
|
4
|
+
import { inlineMarkdown as f, markDownRenderer as h, markdown as g } from "./markdown/index.js";
|
|
5
|
+
import { inflector as U, isPlural as w, isSingular as x, matchCase as b, plural as C, pluralPascal as k, pluralStudly as y, singular as R, uncountable as z } from "./pluralizer/index.js";
|
|
6
|
+
import { randomInt as W, randomString as q } from "./random/index.js";
|
|
7
|
+
import { substr as L, substrCount as v, substrReplace as E } from "./replacer/index.js";
|
|
8
|
+
import { after as N, afterLast as P, apa as T, before as F, beforeLast as D, between as I, betweenFirst as J, camel as O, camelCacheSize as j, charAt as G, chopEnd as H, chopStart as K, contains as Q, containsAll as V, createRandomStringsNormally as X, createRandomStringsUsing as Y, createRandomStringsUsingSequence as Z, deduplicate as _, doesntContain as $, doesntEndWith as ee, doesntStartWith as re, endsWith as te, excerpt as ae, finish as se, flushCache as ie, headline as oe, is as ne, isAscii as le, isJson as ce, isMatch as pe, isUrl as de, kebab as ue, lcfirst as me, length as fe, limit as he, lower as ge, makePad as Se, mask as Ue, match as we, matchAll as xe, numbers as be, padBoth as Ce, padLeft as ke, padRight as ye, pascal as Re, password as ze, position as Ae, random as We, remove as qe, repeat as Be, replace as Le, replaceArray as ve, replaceEnd as Ee, replaceFirst as Me, replaceLast as Ne, replaceMatches as Pe, replaceStart as Te, reverse as Fe, snake as De, snakeCacheSize as Ie, squish as Je, start as Oe, startsWith as je, stripTags as Ge, studly as He, studlyCacheSize as Ke, swap as Qe, take as Ve, toStringOr as Xe, ucfirst as Ye, ucsplit as Ze, ucwords as _e, unwrap as $e, wordCount as er, wordWrap as rr, words as tr, wrap as ar } from "./str.js";
|
|
9
|
+
import { Stringable as ir, of as or, str as nr } from "./stringable/index.js";
|
|
10
|
+
import { transliterate as cr } from "./transliterate/index.js";
|
|
11
|
+
import { ltrim as dr, rtrim as ur, trim as mr } from "./trimmer/index.js";
|
|
12
|
+
import { createUlidsNormally as hr, createUlidsUsing as gr, createUlidsUsingSequence as Sr, freezeUlids as Ur, isUlid as wr, ulid as xr } from "./ulid/index.js";
|
|
13
|
+
import { createUuidsNormally as Cr, createUuidsUsing as kr, createUuidsUsingSequence as yr, freezeUuids as Rr, isUuid as zr, uuid as Ar, uuid7 as Wr } from "./uuid/index.js";
|
|
14
|
+
export {
|
|
15
|
+
c as CaseTypes,
|
|
16
|
+
ir as Stringable,
|
|
17
|
+
N as after,
|
|
18
|
+
P as afterLast,
|
|
19
|
+
T as apa,
|
|
20
|
+
t as ascii,
|
|
21
|
+
F as before,
|
|
22
|
+
D as beforeLast,
|
|
23
|
+
I as between,
|
|
24
|
+
J as betweenFirst,
|
|
25
|
+
i as bytesToBase64,
|
|
26
|
+
O as camel,
|
|
27
|
+
j as camelCacheSize,
|
|
28
|
+
G as charAt,
|
|
29
|
+
H as chopEnd,
|
|
30
|
+
K as chopStart,
|
|
31
|
+
Q as contains,
|
|
32
|
+
V as containsAll,
|
|
33
|
+
p as convertCase,
|
|
34
|
+
X as createRandomStringsNormally,
|
|
35
|
+
Y as createRandomStringsUsing,
|
|
36
|
+
Z as createRandomStringsUsingSequence,
|
|
37
|
+
hr as createUlidsNormally,
|
|
38
|
+
gr as createUlidsUsing,
|
|
39
|
+
Sr as createUlidsUsingSequence,
|
|
40
|
+
Cr as createUuidsNormally,
|
|
41
|
+
kr as createUuidsUsing,
|
|
42
|
+
yr as createUuidsUsingSequence,
|
|
43
|
+
_ as deduplicate,
|
|
44
|
+
$ as doesntContain,
|
|
45
|
+
ee as doesntEndWith,
|
|
46
|
+
re as doesntStartWith,
|
|
47
|
+
te as endsWith,
|
|
48
|
+
ae as excerpt,
|
|
49
|
+
se as finish,
|
|
50
|
+
ie as flushCache,
|
|
51
|
+
Ur as freezeUlids,
|
|
52
|
+
Rr as freezeUuids,
|
|
53
|
+
o as fromBase64,
|
|
54
|
+
oe as headline,
|
|
55
|
+
U as inflector,
|
|
56
|
+
f as inlineMarkdown,
|
|
57
|
+
ne as is,
|
|
58
|
+
le as isAscii,
|
|
59
|
+
ce as isJson,
|
|
60
|
+
pe as isMatch,
|
|
61
|
+
w as isPlural,
|
|
62
|
+
x as isSingular,
|
|
63
|
+
wr as isUlid,
|
|
64
|
+
de as isUrl,
|
|
65
|
+
zr as isUuid,
|
|
66
|
+
ue as kebab,
|
|
67
|
+
me as lcfirst,
|
|
68
|
+
fe as length,
|
|
69
|
+
he as limit,
|
|
70
|
+
ge as lower,
|
|
71
|
+
dr as ltrim,
|
|
72
|
+
Se as makePad,
|
|
73
|
+
h as markDownRenderer,
|
|
74
|
+
g as markdown,
|
|
75
|
+
Ue as mask,
|
|
76
|
+
we as match,
|
|
77
|
+
xe as matchAll,
|
|
78
|
+
b as matchCase,
|
|
79
|
+
be as numbers,
|
|
80
|
+
or as of,
|
|
81
|
+
Ce as padBoth,
|
|
82
|
+
ke as padLeft,
|
|
83
|
+
ye as padRight,
|
|
84
|
+
Re as pascal,
|
|
85
|
+
ze as password,
|
|
86
|
+
C as plural,
|
|
87
|
+
k as pluralPascal,
|
|
88
|
+
y as pluralStudly,
|
|
89
|
+
Ae as position,
|
|
90
|
+
We as random,
|
|
91
|
+
W as randomInt,
|
|
92
|
+
q as randomString,
|
|
93
|
+
qe as remove,
|
|
94
|
+
Be as repeat,
|
|
95
|
+
Le as replace,
|
|
96
|
+
ve as replaceArray,
|
|
97
|
+
Ee as replaceEnd,
|
|
98
|
+
Me as replaceFirst,
|
|
99
|
+
Ne as replaceLast,
|
|
100
|
+
Pe as replaceMatches,
|
|
101
|
+
Te as replaceStart,
|
|
102
|
+
Fe as reverse,
|
|
103
|
+
ur as rtrim,
|
|
104
|
+
R as singular,
|
|
105
|
+
a as slug,
|
|
106
|
+
De as snake,
|
|
107
|
+
Ie as snakeCacheSize,
|
|
108
|
+
Je as squish,
|
|
109
|
+
Oe as start,
|
|
110
|
+
je as startsWith,
|
|
111
|
+
nr as str,
|
|
112
|
+
Ge as stripTags,
|
|
113
|
+
He as studly,
|
|
114
|
+
Ke as studlyCacheSize,
|
|
115
|
+
L as substr,
|
|
116
|
+
v as substrCount,
|
|
117
|
+
E as substrReplace,
|
|
118
|
+
Qe as swap,
|
|
119
|
+
Ve as take,
|
|
120
|
+
d as title,
|
|
121
|
+
n as toBase64,
|
|
122
|
+
Xe as toStringOr,
|
|
123
|
+
cr as transliterate,
|
|
124
|
+
mr as trim,
|
|
125
|
+
Ye as ucfirst,
|
|
126
|
+
Ze as ucsplit,
|
|
127
|
+
_e as ucwords,
|
|
128
|
+
xr as ulid,
|
|
129
|
+
z as uncountable,
|
|
130
|
+
$e as unwrap,
|
|
131
|
+
u as upper,
|
|
132
|
+
Ar as uuid,
|
|
133
|
+
Wr as uuid7,
|
|
134
|
+
er as wordCount,
|
|
135
|
+
rr as wordWrap,
|
|
136
|
+
tr as words,
|
|
137
|
+
ar as wrap
|
|
138
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { default as MarkdownIt, Options as MarkdownItOptions, PluginSimple, PluginWithOptions } from 'markdown-it';
|
|
2
|
+
export interface MarkDownOptions extends MarkdownItOptions {
|
|
3
|
+
gfm?: boolean;
|
|
4
|
+
anchors?: object | boolean;
|
|
5
|
+
typographer?: boolean;
|
|
6
|
+
}
|
|
7
|
+
export type MarkDownExtension = PluginSimple | PluginWithOptions<unknown> | [PluginWithOptions<unknown>, unknown];
|
|
8
|
+
export type MarkDownExtensions = MarkDownExtension[];
|
|
9
|
+
/**
|
|
10
|
+
* Converts GitHub flavored Markdown into HTML.
|
|
11
|
+
*
|
|
12
|
+
* @param value - The markdown string to convert.
|
|
13
|
+
* @param options - Options to customize the markdown rendering. Defaults to GFM enabled and no anchors.
|
|
14
|
+
* @param extensions - An array of markdown-it extensions to apply during rendering.
|
|
15
|
+
* @returns The resulting HTML string.
|
|
16
|
+
*
|
|
17
|
+
* @requires {@link https://www.npmjs.com/package/markdown-it markdown-it package}
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
*
|
|
21
|
+
* markdown('# Hello World'); -> '<h1>Hello World</h1>\n'
|
|
22
|
+
*/
|
|
23
|
+
export declare function markdown(value: string, options?: MarkDownOptions, extensions?: MarkDownExtensions): string;
|
|
24
|
+
/**
|
|
25
|
+
* Converts inline Markdown into HTML.
|
|
26
|
+
*
|
|
27
|
+
* @param value - The inline markdown string to convert.
|
|
28
|
+
* @param options - Options to customize the markdown rendering. Defaults to GFM enabled.
|
|
29
|
+
* @param extensions - An array of markdown-it extensions to apply during rendering.
|
|
30
|
+
* @returns The resulting HTML string.
|
|
31
|
+
*
|
|
32
|
+
* @requires {@link https://www.npmjs.com/package/markdown-it markdown-it package}
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
*
|
|
36
|
+
* inlineMarkdown("Hello *World*"); -> "<p>Hello <em>World</em></p>"
|
|
37
|
+
*/
|
|
38
|
+
export declare function inlineMarkdown(value: string, options?: MarkDownOptions, extensions?: MarkDownExtensions): string;
|
|
39
|
+
/**
|
|
40
|
+
* Creates and configures a MarkdownIt renderer with the specified options and extensions.
|
|
41
|
+
*
|
|
42
|
+
* @param options - Options to customize the markdown rendering. Defaults to GFM enabled and no anchors.
|
|
43
|
+
* @param extensions - An array of markdown-it extensions to apply during rendering.
|
|
44
|
+
* @returns A configured MarkdownIt instance.
|
|
45
|
+
*
|
|
46
|
+
* @requires {@link https://www.npmjs.com/package/markdown-it markdown-it package}
|
|
47
|
+
*/
|
|
48
|
+
export declare function markDownRenderer(options?: MarkDownOptions, extensions?: MarkDownExtensions): MarkdownIt;
|
|
49
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markdown/index.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,EAAE,EACf,KAAK,OAAO,IAAI,iBAAiB,EACjC,KAAK,YAAY,EACjB,KAAK,iBAAiB,EACzB,MAAM,aAAa,CAAC;AAIrB,MAAM,WAAW,eAAgB,SAAQ,iBAAiB;IACtD,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC3B,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED,MAAM,MAAM,iBAAiB,GACvB,YAAY,GACZ,iBAAiB,CAAC,OAAO,CAAC,GAC1B,CAAC,iBAAiB,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,CAAC;AAE5C,MAAM,MAAM,kBAAkB,GAAG,iBAAiB,EAAE,CAAC;AAErD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,QAAQ,CACpB,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAA+C,EACxD,UAAU,GAAE,kBAAuB,GACpC,MAAM,CAER;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC1B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,eAA+B,EACxC,UAAU,GAAE,kBAAuB,GACpC,MAAM,CAER;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,eAA+C,EACxD,UAAU,GAAE,kBAAuB,cAgCtC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isArray as d } from "@tolki/utils";
|
|
2
|
+
import k from "markdown-it";
|
|
3
|
+
import p from "markdown-it-anchor";
|
|
4
|
+
import w from "markdown-it-task-lists";
|
|
5
|
+
function y(r, e = { gfm: !0, anchors: !1 }, t = []) {
|
|
6
|
+
return s(e, t).render(r);
|
|
7
|
+
}
|
|
8
|
+
function A(r, e = { gfm: !0 }, t = []) {
|
|
9
|
+
return s(e, t).renderInline(r);
|
|
10
|
+
}
|
|
11
|
+
function s(r = { gfm: !0, anchors: !1 }, e = []) {
|
|
12
|
+
const {
|
|
13
|
+
html: t = !1,
|
|
14
|
+
linkify: i = !0,
|
|
15
|
+
breaks: u = !0,
|
|
16
|
+
gfm: a = !0,
|
|
17
|
+
anchors: f = !1,
|
|
18
|
+
...m
|
|
19
|
+
} = r, n = new k({ html: t, linkify: i, breaks: u, ...m });
|
|
20
|
+
a && n.use(w, { label: !0, labelAfter: !0 }), f && n.use(p, typeof f == "object" ? f : {});
|
|
21
|
+
for (const o of e)
|
|
22
|
+
if (d(o)) {
|
|
23
|
+
const [l, c] = o;
|
|
24
|
+
n.use(l, c);
|
|
25
|
+
} else o && n.use(o);
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
export {
|
|
29
|
+
A as inlineMarkdown,
|
|
30
|
+
s as markDownRenderer,
|
|
31
|
+
y as markdown
|
|
32
|
+
};
|