@tolki/str 1.7.0 → 1.7.1
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.js +24 -39
- package/dist/base64/index.js +90 -118
- package/dist/convertcase/index.js +29 -44
- 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.js +39 -60
- package/dist/str.js +692 -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 +35 -22
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import e from "any-ascii";
|
|
2
|
+
// src/transliterate/index.ts
|
|
3
|
+
function t(t) {
|
|
4
|
+
return t === null ? "" : e(t);
|
|
4
5
|
}
|
|
5
|
-
export {
|
|
6
|
-
i as transliterate
|
|
7
|
-
};
|
|
6
|
+
export { t as transliterate };
|
package/dist/trimmer/index.js
CHANGED
|
@@ -1,96 +1,91 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
// src/trimmer/index.ts
|
|
2
|
+
var e = [
|
|
3
|
+
9,
|
|
4
|
+
32,
|
|
5
|
+
160,
|
|
6
|
+
173,
|
|
7
|
+
847,
|
|
8
|
+
1564,
|
|
9
|
+
4447,
|
|
10
|
+
4448,
|
|
11
|
+
6068,
|
|
12
|
+
6069,
|
|
13
|
+
6158,
|
|
14
|
+
8192,
|
|
15
|
+
8193,
|
|
16
|
+
8194,
|
|
17
|
+
8195,
|
|
18
|
+
8196,
|
|
19
|
+
8197,
|
|
20
|
+
8198,
|
|
21
|
+
8199,
|
|
22
|
+
8200,
|
|
23
|
+
8201,
|
|
24
|
+
8202,
|
|
25
|
+
8203,
|
|
26
|
+
8204,
|
|
27
|
+
8205,
|
|
28
|
+
8206,
|
|
29
|
+
8207,
|
|
30
|
+
8239,
|
|
31
|
+
8287,
|
|
32
|
+
8288,
|
|
33
|
+
8289,
|
|
34
|
+
8290,
|
|
35
|
+
8291,
|
|
36
|
+
8292,
|
|
37
|
+
8293,
|
|
38
|
+
8298,
|
|
39
|
+
8299,
|
|
40
|
+
8300,
|
|
41
|
+
8301,
|
|
42
|
+
8302,
|
|
43
|
+
8303,
|
|
44
|
+
12288,
|
|
45
|
+
10240,
|
|
46
|
+
12644,
|
|
47
|
+
65279,
|
|
48
|
+
65440,
|
|
49
|
+
119129,
|
|
50
|
+
119155,
|
|
51
|
+
119156,
|
|
52
|
+
119157,
|
|
53
|
+
119158,
|
|
54
|
+
119159,
|
|
55
|
+
119160,
|
|
56
|
+
119161,
|
|
57
|
+
119162,
|
|
58
|
+
917536
|
|
59
|
+
].map((e) => `\\u{${e.toString(16)}}`).join("");
|
|
60
|
+
function t() {
|
|
61
|
+
return `\\s\\u0085${e}\\u0000`;
|
|
61
62
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
63
|
+
function n(e) {
|
|
64
|
+
return e.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
|
|
64
65
|
}
|
|
65
|
-
function
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
return n.slice(0, r);
|
|
66
|
+
function r(e, t) {
|
|
67
|
+
let n = RegExp(`[${t}]$`, "u"), r = e.length;
|
|
68
|
+
for (; r > 0;) {
|
|
69
|
+
let t = n.exec(e.slice(Math.max(r - 2, 0), r));
|
|
70
|
+
if (t === null) break;
|
|
71
|
+
r -= t[0].length;
|
|
72
|
+
}
|
|
73
|
+
return e.slice(0, r);
|
|
75
74
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
75
|
+
function i(e, t) {
|
|
76
|
+
return e.replace(RegExp(`^[${t}]+`, "u"), "");
|
|
78
77
|
}
|
|
79
|
-
function
|
|
80
|
-
|
|
78
|
+
function a(e) {
|
|
79
|
+
return e === null ? t() : n(e);
|
|
81
80
|
}
|
|
82
|
-
function
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
function o(e, t = null) {
|
|
82
|
+
let n = a(t);
|
|
83
|
+
return r(i(e, n), n);
|
|
85
84
|
}
|
|
86
|
-
function
|
|
87
|
-
|
|
85
|
+
function s(e, t = null) {
|
|
86
|
+
return i(e, a(t));
|
|
88
87
|
}
|
|
89
|
-
function
|
|
90
|
-
|
|
88
|
+
function c(e, t = null) {
|
|
89
|
+
return r(e, a(t));
|
|
91
90
|
}
|
|
92
|
-
export {
|
|
93
|
-
f as ltrim,
|
|
94
|
-
m as rtrim,
|
|
95
|
-
p as trim
|
|
96
|
-
};
|
|
91
|
+
export { s as ltrim, c as rtrim, o as trim };
|
package/dist/ulid/index.js
CHANGED
|
@@ -1,58 +1,48 @@
|
|
|
1
|
-
import { isString as
|
|
2
|
-
import { ulid as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
1
|
+
import { isString as e } from "@tolki/utils";
|
|
2
|
+
import { ulid as t } from "ulid";
|
|
3
|
+
// src/ulid/index.ts
|
|
4
|
+
var n = null;
|
|
5
|
+
function r(e = null) {
|
|
6
|
+
if (n) return n();
|
|
7
|
+
if (e == null) return t();
|
|
8
|
+
let r;
|
|
9
|
+
r = e instanceof Date ? e.getTime() : e;
|
|
10
|
+
let i = Date.now;
|
|
11
|
+
try {
|
|
12
|
+
return Date.now = () => r, t();
|
|
13
|
+
} finally {
|
|
14
|
+
Date.now = i;
|
|
15
|
+
}
|
|
17
16
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
17
|
+
function i() {
|
|
18
|
+
n = null;
|
|
20
19
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
20
|
+
function a(e) {
|
|
21
|
+
n = e;
|
|
23
22
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
23
|
+
function o(e, t = null) {
|
|
24
|
+
let i = 0;
|
|
25
|
+
t ??= function() {
|
|
26
|
+
let e = n;
|
|
27
|
+
n = null;
|
|
28
|
+
let t = r();
|
|
29
|
+
return n = e, i++, t;
|
|
30
|
+
}, a(function() {
|
|
31
|
+
return i < e.length ? e[i++] : t();
|
|
32
|
+
});
|
|
34
33
|
}
|
|
35
|
-
function
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return t;
|
|
34
|
+
function s(e = null) {
|
|
35
|
+
let t = r();
|
|
36
|
+
if (a(() => t), e !== null) try {
|
|
37
|
+
e(t);
|
|
38
|
+
} finally {
|
|
39
|
+
i();
|
|
40
|
+
}
|
|
41
|
+
return t;
|
|
44
42
|
}
|
|
45
|
-
function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return /^[0-9A-HJKMNP-TV-Z]{26}$/.test(t);
|
|
43
|
+
function c(t) {
|
|
44
|
+
if (!e(t)) return !1;
|
|
45
|
+
let n = t.toUpperCase();
|
|
46
|
+
return /^[0-9A-HJKMNP-TV-Z]{26}$/.test(n);
|
|
50
47
|
}
|
|
51
|
-
export {
|
|
52
|
-
a as createUlidsNormally,
|
|
53
|
-
u as createUlidsUsing,
|
|
54
|
-
U as createUlidsUsingSequence,
|
|
55
|
-
p as freezeUlids,
|
|
56
|
-
y as isUlid,
|
|
57
|
-
i as ulid
|
|
58
|
-
};
|
|
48
|
+
export { i as createUlidsNormally, a as createUlidsUsing, o as createUlidsUsingSequence, s as freezeUlids, c as isUlid, r as ulid };
|
package/dist/uuid/index.js
CHANGED
|
@@ -1,50 +1,40 @@
|
|
|
1
|
-
import { isString as
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { isString as e } from "@tolki/utils";
|
|
2
|
+
import { MAX as t, NIL as n, v4 as r, v7 as i, validate as a, version as o } from "uuid";
|
|
3
|
+
// src/uuid/index.ts
|
|
4
|
+
var s = null;
|
|
5
|
+
function c() {
|
|
6
|
+
return s ? s() : r();
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
-
|
|
8
|
+
function l() {
|
|
9
|
+
return s ? s() : i();
|
|
9
10
|
}
|
|
10
|
-
function e
|
|
11
|
-
|
|
11
|
+
function u(e) {
|
|
12
|
+
s = e;
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
function d(e, t = null) {
|
|
15
|
+
let n = 0;
|
|
16
|
+
t ??= function() {
|
|
17
|
+
let e = s;
|
|
18
|
+
s = null;
|
|
19
|
+
let t = c();
|
|
20
|
+
return s = e, n++, t;
|
|
21
|
+
}, u(function() {
|
|
22
|
+
return n < e.length ? e[n++] : t();
|
|
23
|
+
});
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return t;
|
|
25
|
+
function f(e = null) {
|
|
26
|
+
let t = c();
|
|
27
|
+
if (u(() => t), e !== null) try {
|
|
28
|
+
e(t);
|
|
29
|
+
} finally {
|
|
30
|
+
p();
|
|
31
|
+
}
|
|
32
|
+
return t;
|
|
33
33
|
}
|
|
34
|
-
function
|
|
35
|
-
|
|
34
|
+
function p() {
|
|
35
|
+
s = null;
|
|
36
36
|
}
|
|
37
|
-
function
|
|
38
|
-
|
|
39
|
-
n
|
|
40
|
-
) : t === 0 || t === "nil" ? n.toLowerCase() === c : t === "max" ? n.toLowerCase() === d : t < 1 || t > 8 ? !1 : s(n) === t;
|
|
37
|
+
function m(r, i = null) {
|
|
38
|
+
return !e(r) || i !== null && !a(r) ? !1 : i === null ? /^[\da-fA-F]{8}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{4}-[\da-fA-F]{12}$/.test(r) : i === 0 || i === "nil" ? r.toLowerCase() === n : i === "max" ? r.toLowerCase() === t : i < 1 || i > 8 ? !1 : o(r) === i;
|
|
41
39
|
}
|
|
42
|
-
export {
|
|
43
|
-
A as createUuidsNormally,
|
|
44
|
-
e as createUuidsUsing,
|
|
45
|
-
p as createUuidsUsingSequence,
|
|
46
|
-
x as freezeUuids,
|
|
47
|
-
C as isUuid,
|
|
48
|
-
f as uuid,
|
|
49
|
-
g as uuid7
|
|
50
|
-
};
|
|
40
|
+
export { p as createUuidsNormally, u as createUuidsUsing, d as createUuidsUsingSequence, f as freezeUuids, m as isUuid, c as uuid, l as uuid7 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tolki/str",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.1",
|
|
4
4
|
"description": "Utilities for working with strings similar to Laravel's Str & Stringable classes.",
|
|
5
5
|
"author": "Abraham Arango <https://github.com/abetwothree>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,18 +26,18 @@
|
|
|
26
26
|
],
|
|
27
27
|
"sideEffects": false,
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@types/markdown-it": "^14.
|
|
29
|
+
"@types/markdown-it": "^14.2.0",
|
|
30
30
|
"@types/pluralize": "^0.0.33",
|
|
31
31
|
"any-ascii": "^0.3.3",
|
|
32
|
-
"markdown-it": "^14.
|
|
33
|
-
"markdown-it-anchor": "^
|
|
32
|
+
"markdown-it": "^14.3.3",
|
|
33
|
+
"markdown-it-anchor": "^10.0.0",
|
|
34
34
|
"markdown-it-task-lists": "^2.1.1",
|
|
35
35
|
"pluralize": "^8.0.0",
|
|
36
|
-
"transliteration": "^2.
|
|
37
|
-
"ulid": "^
|
|
38
|
-
"uuid": "^
|
|
39
|
-
"@tolki/
|
|
40
|
-
"@tolki/
|
|
36
|
+
"transliteration": "^2.7.0",
|
|
37
|
+
"ulid": "^3.0.2",
|
|
38
|
+
"uuid": "^14.0.3",
|
|
39
|
+
"@tolki/utils": "^1.6.3",
|
|
40
|
+
"@tolki/num": "^2.2.5"
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"dist"
|
|
@@ -66,56 +66,69 @@
|
|
|
66
66
|
"types": "./dist/*"
|
|
67
67
|
},
|
|
68
68
|
"./ascii": {
|
|
69
|
+
"types": "./dist/ascii/index.d.ts",
|
|
69
70
|
"import": "./dist/ascii/index.js",
|
|
70
|
-
"
|
|
71
|
+
"default": "./dist/ascii/index.js"
|
|
71
72
|
},
|
|
72
73
|
"./base64": {
|
|
74
|
+
"types": "./dist/base64/index.d.ts",
|
|
73
75
|
"import": "./dist/base64/index.js",
|
|
74
|
-
"
|
|
76
|
+
"default": "./dist/base64/index.js"
|
|
75
77
|
},
|
|
76
78
|
"./convertcase": {
|
|
79
|
+
"types": "./dist/convertcase/index.d.ts",
|
|
77
80
|
"import": "./dist/convertcase/index.js",
|
|
78
|
-
"
|
|
81
|
+
"default": "./dist/convertcase/index.js"
|
|
79
82
|
},
|
|
80
83
|
"./markdown": {
|
|
84
|
+
"types": "./dist/markdown/index.d.ts",
|
|
81
85
|
"import": "./dist/markdown/index.js",
|
|
82
|
-
"
|
|
86
|
+
"default": "./dist/markdown/index.js"
|
|
83
87
|
},
|
|
84
88
|
"./pluralizer": {
|
|
89
|
+
"types": "./dist/pluralizer/index.d.ts",
|
|
85
90
|
"import": "./dist/pluralizer/index.js",
|
|
86
|
-
"
|
|
91
|
+
"default": "./dist/pluralizer/index.js"
|
|
87
92
|
},
|
|
88
93
|
"./random": {
|
|
94
|
+
"types": "./dist/random/index.d.ts",
|
|
89
95
|
"import": "./dist/random/index.js",
|
|
90
|
-
"
|
|
96
|
+
"default": "./dist/random/index.js"
|
|
91
97
|
},
|
|
92
98
|
"./replacer": {
|
|
99
|
+
"types": "./dist/replacer/index.d.ts",
|
|
93
100
|
"import": "./dist/replacer/index.js",
|
|
94
|
-
"
|
|
101
|
+
"default": "./dist/replacer/index.js"
|
|
95
102
|
},
|
|
96
103
|
"./str": {
|
|
104
|
+
"types": "./dist/str.d.ts",
|
|
97
105
|
"import": "./dist/str.js",
|
|
98
|
-
"
|
|
106
|
+
"default": "./dist/str.js"
|
|
99
107
|
},
|
|
100
108
|
"./stringable": {
|
|
109
|
+
"types": "./dist/stringable/index.d.ts",
|
|
101
110
|
"import": "./dist/stringable/index.js",
|
|
102
|
-
"
|
|
111
|
+
"default": "./dist/stringable/index.js"
|
|
103
112
|
},
|
|
104
113
|
"./transliterate": {
|
|
114
|
+
"types": "./dist/transliterate/index.d.ts",
|
|
105
115
|
"import": "./dist/transliterate/index.js",
|
|
106
|
-
"
|
|
116
|
+
"default": "./dist/transliterate/index.js"
|
|
107
117
|
},
|
|
108
118
|
"./trimmer": {
|
|
119
|
+
"types": "./dist/trimmer/index.d.ts",
|
|
109
120
|
"import": "./dist/trimmer/index.js",
|
|
110
|
-
"
|
|
121
|
+
"default": "./dist/trimmer/index.js"
|
|
111
122
|
},
|
|
112
123
|
"./ulid": {
|
|
124
|
+
"types": "./dist/ulid/index.d.ts",
|
|
113
125
|
"import": "./dist/ulid/index.js",
|
|
114
|
-
"
|
|
126
|
+
"default": "./dist/ulid/index.js"
|
|
115
127
|
},
|
|
116
128
|
"./uuid": {
|
|
129
|
+
"types": "./dist/uuid/index.d.ts",
|
|
117
130
|
"import": "./dist/uuid/index.js",
|
|
118
|
-
"
|
|
131
|
+
"default": "./dist/uuid/index.js"
|
|
119
132
|
}
|
|
120
133
|
}
|
|
121
134
|
}
|