string-filters 0.3.1 → 0.3.2
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/string-filters.js +53 -67
- package/dist/string-filters.umd.cjs +1 -1
- package/package.json +2 -4
package/dist/string-filters.js
CHANGED
|
@@ -1,72 +1,58 @@
|
|
|
1
|
-
function a(
|
|
2
|
-
let
|
|
3
|
-
return
|
|
4
|
-
}
|
|
5
|
-
function
|
|
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
|
-
let
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const l = typeof e.lower < "u" ? e.lower : !1;
|
|
47
|
-
return t.map((u) => a(u, l)).join(" ");
|
|
48
|
-
}
|
|
49
|
-
function m(r, e = { numbers: !1, lower: !1 }) {
|
|
50
|
-
let n = /[\p{L}-]+/gu;
|
|
51
|
-
typeof e.numbers < "u" && e.numbers && (n = /[\p{L}\p{N}-]+/gu);
|
|
52
|
-
let t = r.match(n);
|
|
53
|
-
if (t.length <= 1)
|
|
54
|
-
return null;
|
|
55
|
-
const l = typeof e.lower < "u" ? e.lower : !1;
|
|
56
|
-
return t.map((u) => a(u, l)).join("-");
|
|
57
|
-
}
|
|
58
|
-
function g(r, e = 32, n = "...") {
|
|
59
|
-
return r.substring(0, e) + n;
|
|
1
|
+
function a(n, t = !1) {
|
|
2
|
+
let r = n.charAt(0).toUpperCase(), e = n.slice(1);
|
|
3
|
+
return t && (e = e.toLowerCase()), `${r}${e}`;
|
|
4
|
+
}
|
|
5
|
+
function o(n, t = { numbers: !1, lower: !1 }) {
|
|
6
|
+
const r = t?.numbers ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu;
|
|
7
|
+
let e = n.match(r);
|
|
8
|
+
if (e.length <= 1) return null;
|
|
9
|
+
let l = e.shift();
|
|
10
|
+
const u = t?.lower;
|
|
11
|
+
return u && (l = l.toLowerCase()), e = e.map((s) => a(s, u)), e.unshift(l), e.join("");
|
|
12
|
+
}
|
|
13
|
+
function p(n, t = !1) {
|
|
14
|
+
let r = t ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu, e = n.match(r);
|
|
15
|
+
return e.length <= 1 ? null : e.map((l) => l.toLowerCase()).join("");
|
|
16
|
+
}
|
|
17
|
+
function f(n, t = !1) {
|
|
18
|
+
let r = t ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu, e = n.match(r);
|
|
19
|
+
return e.length <= 1 ? null : e.map((l) => l.toLowerCase()).join("-");
|
|
20
|
+
}
|
|
21
|
+
function i(n, t, r = " ") {
|
|
22
|
+
const e = Math.floor((t - n.length) / 2) + n.length;
|
|
23
|
+
return n.padStart(e, r).padEnd(t, r);
|
|
24
|
+
}
|
|
25
|
+
function c(n, t = { numbers: !1, lower: !1 }) {
|
|
26
|
+
const r = t?.numbers ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu;
|
|
27
|
+
let e = n.match(r);
|
|
28
|
+
return e.length <= 1 ? null : e.map((l) => a(l, t?.lower)).join("");
|
|
29
|
+
}
|
|
30
|
+
function m(n, t = !1) {
|
|
31
|
+
let r = t ? /[\p{L}\p{N}_]+/gu : /[\p{L}_]+/gu, e = n.match(r);
|
|
32
|
+
return e.length <= 1 ? null : e.map((l) => l.toLowerCase()).join("_");
|
|
33
|
+
}
|
|
34
|
+
function g(n, t = { numbers: !1, lower: !1 }) {
|
|
35
|
+
const r = t?.numbers ? /[\p{L}\p{N}]+/gu : /[\p{L}]+/gu;
|
|
36
|
+
let e = n.match(r);
|
|
37
|
+
return e.length <= 1 ? null : e.map((l) => a(l, t?.lower)).join(" ");
|
|
38
|
+
}
|
|
39
|
+
function w(n, t = { numbers: !1, lower: !1 }) {
|
|
40
|
+
const r = t?.numbers ? /[\p{L}\p{N}-]+/gu : /[\p{L}-]+/gu;
|
|
41
|
+
let e = n.match(r);
|
|
42
|
+
return e.length <= 1 ? null : e.map((l) => a(l, t?.lower)).join("-");
|
|
43
|
+
}
|
|
44
|
+
function L(n, t = 32, r = "...") {
|
|
45
|
+
return n.substring(0, t) + r;
|
|
60
46
|
}
|
|
61
47
|
export {
|
|
62
|
-
|
|
48
|
+
o as camelCase,
|
|
63
49
|
a as capitalize,
|
|
64
|
-
|
|
65
|
-
|
|
50
|
+
p as flatCase,
|
|
51
|
+
f as kebabCase,
|
|
66
52
|
i as pad,
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
53
|
+
c as pascalCase,
|
|
54
|
+
m as snakeCase,
|
|
55
|
+
g as titleCase,
|
|
56
|
+
w as trainCase,
|
|
57
|
+
L as truncate
|
|
72
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(r=typeof globalThis<"u"?globalThis:r||self,u(r.StringFilters={}))})(this,(function(r){"use strict";function u(
|
|
1
|
+
(function(r,u){typeof exports=="object"&&typeof module<"u"?u(exports):typeof define=="function"&&define.amd?define(["exports"],u):(r=typeof globalThis<"u"?globalThis:r||self,u(r.StringFilters={}))})(this,(function(r){"use strict";function u(n,t=!1){let a=n.charAt(0).toUpperCase(),e=n.slice(1);return t&&(e=e.toLowerCase()),`${a}${e}`}function f(n,t={numbers:!1,lower:!1}){const a=t?.numbers?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu;let e=n.match(a);if(e.length<=1)return null;let l=e.shift();const s=t?.lower;return s&&(l=l.toLowerCase()),e=e.map(w=>u(w,s)),e.unshift(l),e.join("")}function i(n,t=!1){let a=t?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu,e=n.match(a);return e.length<=1?null:e.map(l=>l.toLowerCase()).join("")}function o(n,t=!1){let a=t?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu,e=n.match(a);return e.length<=1?null:e.map(l=>l.toLowerCase()).join("-")}function p(n,t,a=" "){const e=Math.floor((t-n.length)/2)+n.length;return n.padStart(e,a).padEnd(t,a)}function c(n,t={numbers:!1,lower:!1}){const a=t?.numbers?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu;let e=n.match(a);return e.length<=1?null:e.map(l=>u(l,t?.lower)).join("")}function m(n,t=!1){let a=t?/[\p{L}\p{N}_]+/gu:/[\p{L}_]+/gu,e=n.match(a);return e.length<=1?null:e.map(l=>l.toLowerCase()).join("_")}function g(n,t={numbers:!1,lower:!1}){const a=t?.numbers?/[\p{L}\p{N}]+/gu:/[\p{L}]+/gu;let e=n.match(a);return e.length<=1?null:e.map(l=>u(l,t?.lower)).join(" ")}function d(n,t={numbers:!1,lower:!1}){const a=t?.numbers?/[\p{L}\p{N}-]+/gu:/[\p{L}-]+/gu;let e=n.match(a);return e.length<=1?null:e.map(l=>u(l,t?.lower)).join("-")}function h(n,t=32,a="..."){return n.substring(0,t)+a}r.camelCase=f,r.capitalize=u,r.flatCase=i,r.kebabCase=o,r.pad=p,r.pascalCase=c,r.snakeCase=m,r.titleCase=g,r.trainCase=d,r.truncate=h,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-filters",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "Fast native javascript string filters library.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
],
|
|
6
|
+
"files": ["dist"],
|
|
9
7
|
"main": "./dist/string-filters.umd.cjs",
|
|
10
8
|
"module": "./dist/string-filters.js",
|
|
11
9
|
"exports": {
|