@citruslime/utils 2.0.2 → 2.0.4-beta.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.
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
function
|
|
1
|
+
function p(t, ...n) {
|
|
2
2
|
let e = 0;
|
|
3
3
|
return t.replace(/{\d+}/g, () => typeof n[e] < "u" ? n[e++] : "");
|
|
4
4
|
}
|
|
5
5
|
function m(t, n, e = "cl-bg-primary-light cl-font-bold cl-px-0.5") {
|
|
6
|
+
n = n.map((r) => r.replace(/\\/g, "\\\\"));
|
|
6
7
|
const o = n.map((r) => `(${r})`).join("|");
|
|
7
8
|
return t.replace(
|
|
8
9
|
new RegExp(o, "ig"),
|
|
@@ -16,7 +17,7 @@ String.prototype.similarity = function(t) {
|
|
|
16
17
|
o = e, e = i;
|
|
17
18
|
}
|
|
18
19
|
const r = e.length;
|
|
19
|
-
return r === 0 ? n = 100 : n = Math.round((r -
|
|
20
|
+
return r === 0 ? n = 100 : n = Math.round((r - g(e, o)) / r * 100), n;
|
|
20
21
|
};
|
|
21
22
|
String.prototype.trimChar = function(t) {
|
|
22
23
|
return this.trimStartChar(t).trimEndChar(t);
|
|
@@ -44,12 +45,12 @@ String.prototype.removeNonNumeric = function() {
|
|
|
44
45
|
return this.replace(/[^0-9]/g, "");
|
|
45
46
|
};
|
|
46
47
|
String.prototype.replacePlaceholders = function(...t) {
|
|
47
|
-
return
|
|
48
|
+
return p(this, ...t);
|
|
48
49
|
};
|
|
49
50
|
String.prototype.toDateFromTime = function() {
|
|
50
51
|
return /* @__PURE__ */ new Date(`${(/* @__PURE__ */ new Date()).toISOString().substr(0, 11)}${this}`);
|
|
51
52
|
};
|
|
52
|
-
function
|
|
53
|
+
function g(t, n) {
|
|
53
54
|
if (t.length === 0)
|
|
54
55
|
return n.length;
|
|
55
56
|
if (n.length === 0)
|
|
@@ -69,8 +70,8 @@ function p(t, n) {
|
|
|
69
70
|
if (h === t[l - 1])
|
|
70
71
|
o = e[l - 1];
|
|
71
72
|
else {
|
|
72
|
-
const c = i + 1,
|
|
73
|
-
o =
|
|
73
|
+
const c = i + 1, u = e[l] + 1, a = c - (c - u & u - c >> 7), s = e[l - 1] + 1;
|
|
74
|
+
o = a - (a - s & s - a >> 7);
|
|
74
75
|
}
|
|
75
76
|
e[l - 1] = i, i = o;
|
|
76
77
|
}
|
|
@@ -111,6 +112,6 @@ export {
|
|
|
111
112
|
C as getParamsByName,
|
|
112
113
|
m as highlightText,
|
|
113
114
|
x as nameOf,
|
|
114
|
-
|
|
115
|
+
p as replacePlaceholders,
|
|
115
116
|
v as validateEmail
|
|
116
117
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,
|
|
1
|
+
(function(i,h){typeof exports=="object"&&typeof module<"u"?h(exports):typeof define=="function"&&define.amd?define(["exports"],h):(i=typeof globalThis<"u"?globalThis:i||self,h(i.CitrusLimeUtils={}))})(this,function(i){"use strict";function h(e,...n){let t=0;return e.replace(/{\d+}/g,()=>typeof n[t]<"u"?n[t++]:"")}function m(e,n,t="cl-bg-primary-light cl-font-bold cl-px-0.5"){n=n.map(r=>r.replace(/\\/g,"\\\\"));const o=n.map(r=>`(${r})`).join("|");return e.replace(new RegExp(o,"ig"),r=>`<span class="${t}">${r}</span>`)}String.prototype.similarity=function(e){let n=0,t=this.toLowerCase(),o=e.toLowerCase();if(t<o){const l=o;o=t,t=l}const r=t.length;return r===0?n=100:n=Math.round((r-f(t,o))/r*100),n},String.prototype.trimChar=function(e){return this.trimStartChar(e).trimEndChar(e)},String.prototype.trimStartChar=function(e){return e!==""&&this.startsWith(e)?this.slice(1):this},String.prototype.trimEndChar=function(e){return e!==""&&this.endsWith(e)?this.slice(0,-1):this},String.prototype.trimToLength=function(e,n=!1){const t=this.length<e?this.length:e;return n&&t>=4&&t<this.length?`${this.slice(0,Math.max(t-3,1))}...`:this.slice(0,Math.max(t,1))},String.prototype.removeWhitespace=function(){return this.replace(/\s/g,"")},String.prototype.removeNonAlphanumeric=function(){return this.replace(/[^a-zA-Z0-9]/g,"")},String.prototype.removeNonAlphabetic=function(){return this.replace(/[^a-zA-Z]/g,"")},String.prototype.removeNonNumeric=function(){return this.replace(/[^0-9]/g,"")},String.prototype.replacePlaceholders=function(...e){return h(this,...e)},String.prototype.toDateFromTime=function(){return new Date(`${new Date().toISOString().substr(0,11)}${this}`)};function f(e,n){if(e.length===0)return n.length;if(n.length===0)return e.length;if(e.length>n.length){const r=e;e=n,n=r}const t=new Int8Array(e.length+1);for(let r=0;r<=e.length;r++)t[r]=r;let o;for(let r=1;r<=n.length;r++){let l=r;const u=n[r-1];for(let a=1;a<=e.length;a++){if(u===e[a-1])o=t[a-1];else{const c=l+1,g=t[a]+1,s=c-(c-g&g-c>>7),p=t[a-1]+1;o=s-(s-p&p-s>>7)}t[a-1]=l,l=o}t[e.length]=l}return t[e.length]}function*d(e,n){for(let t=0;t<e.length;t+=n)yield e.slice(t,t+n)}function y(){return Math.random().toString(36).slice(2,8)}function C(e){return e}function v(e,n,t){return e[t]<n[t]?-1:e[t]>n[t]?1:0}function P(e,n){let t="";const o=decodeURIComponent(e),r="[\\?&]"+n+"=([^&#]*)",u=new RegExp(r).exec(o);return u&&u[1]&&(t=decodeURIComponent(u[1].replace(/\+/g," "))),t}function w(e,n){const t=Object.keys(e).find(o=>o.toLowerCase()===n.toLowerCase());return t?e[t]:null}function b(e){return!!e&&/^[^@]+@[^@]+\.[^@]+$/.exec(e)!==null}i.chunk=d,i.compareByProperty=v,i.generateStringId=y,i.getCaseInsensitiveQueryParam=w,i.getParamsByName=P,i.highlightText=m,i.nameOf=C,i.replacePlaceholders=h,i.validateEmail=b,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|