@citruslime/utils 1.3.1-beta.0 → 1.3.2-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,4 +1,4 @@
1
- function p(t, ...n) {
1
+ function g(t, ...n) {
2
2
  let e = 0;
3
3
  return t.replace(/{\d+}/g, () => typeof n[e] < "u" ? n[e++] : "");
4
4
  }
@@ -16,7 +16,7 @@ String.prototype.similarity = function(t) {
16
16
  o = e, e = i;
17
17
  }
18
18
  const r = e.length;
19
- return r === 0 ? n = 100 : n = Math.round((r - g(e, o)) / r * 100), n;
19
+ return r === 0 ? n = 100 : n = Math.round((r - p(e, o)) / r * 100), n;
20
20
  };
21
21
  String.prototype.trimChar = function(t) {
22
22
  return this.trimStartChar(t).trimEndChar(t);
@@ -44,12 +44,12 @@ String.prototype.removeNonNumeric = function() {
44
44
  return this.replace(/[^0-9]/g, "");
45
45
  };
46
46
  String.prototype.replacePlaceholders = function(...t) {
47
- return p(this, ...t);
47
+ return g(this, ...t);
48
48
  };
49
49
  String.prototype.toDateFromTime = function() {
50
50
  return /* @__PURE__ */ new Date(`${(/* @__PURE__ */ new Date()).toISOString().substr(0, 11)}${this}`);
51
51
  };
52
- function g(t, n) {
52
+ function p(t, n) {
53
53
  if (t.length === 0)
54
54
  return n.length;
55
55
  if (n.length === 0)
@@ -85,13 +85,13 @@ function* f(t, n) {
85
85
  function y() {
86
86
  return Math.random().toString(36).slice(2, 8);
87
87
  }
88
- function C(t) {
88
+ function x(t) {
89
89
  return t;
90
90
  }
91
91
  function d(t, n, e) {
92
92
  return t[e] < n[e] ? -1 : t[e] > n[e] ? 1 : 0;
93
93
  }
94
- function x(t, n) {
94
+ function C(t, n) {
95
95
  let e = "";
96
96
  const o = decodeURIComponent(t), r = "[\\?&]" + n + "=([^&#]*)", h = new RegExp(r).exec(o);
97
97
  return h && h[1] && (e = decodeURIComponent(h[1].replace(/\+/g, " "))), e;
@@ -100,13 +100,17 @@ function w(t, n) {
100
100
  const e = Object.keys(t).find((o) => o.toLowerCase() === n.toLowerCase());
101
101
  return e ? t[e] : null;
102
102
  }
103
+ function v(t) {
104
+ return !!t && /^[^@]+@[^@]+\.[^@]+$/.exec(t) !== null;
105
+ }
103
106
  export {
104
107
  f as chunk,
105
108
  d as compareByProperty,
106
109
  y as generateStringId,
107
110
  w as getCaseInsensitiveQueryParam,
108
- x as getParamsByName,
111
+ C as getParamsByName,
109
112
  m as highlightText,
110
- C as nameOf,
111
- p as replacePlaceholders
113
+ x as nameOf,
114
+ g as replacePlaceholders,
115
+ v as validateEmail
112
116
  };
@@ -1 +1 @@
1
- (function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.CitrusLimeUtils={}))})(this,function(i){"use strict";function a(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"){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 a(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 h=1;h<=e.length;h++){if(u===e[h-1])o=t[h-1];else{const c=l+1,g=t[h]+1,s=c-(c-g&g-c>>7),p=t[h-1]+1;o=s-(s-p&p-s>>7)}t[h-1]=l,l=o}t[e.length]=l}return t[e.length]}function*y(e,n){for(let t=0;t<e.length;t+=n)yield e.slice(t,t+n)}function d(){return Math.random().toString(36).slice(2,8)}function C(e){return e}function P(e,n,t){return e[t]<n[t]?-1:e[t]>n[t]?1:0}function v(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}i.chunk=y,i.compareByProperty=P,i.generateStringId=d,i.getCaseInsensitiveQueryParam=w,i.getParamsByName=v,i.highlightText=m,i.nameOf=C,i.replacePlaceholders=a,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,a){typeof exports=="object"&&typeof module<"u"?a(exports):typeof define=="function"&&define.amd?define(["exports"],a):(i=typeof globalThis<"u"?globalThis:i||self,a(i.CitrusLimeUtils={}))})(this,function(i){"use strict";function a(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"){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 a(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 h=1;h<=e.length;h++){if(u===e[h-1])o=t[h-1];else{const c=l+1,g=t[h]+1,s=c-(c-g&g-c>>7),p=t[h-1]+1;o=s-(s-p&p-s>>7)}t[h-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 T(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=a,i.validateEmail=T,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
@@ -5,3 +5,4 @@ export * from './name-of';
5
5
  export * from './sort';
6
6
  export * from './strings';
7
7
  export * from './url-params';
8
+ export * from './validation';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Performs basic validation for an email address.
3
+ *
4
+ * @param value The value to validate.
5
+ * @returns `true` if the value is a valid email address, `false` otherwise.
6
+ */
7
+ export declare function validateEmail(value: string): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citruslime/utils",
3
- "version": "1.3.1-beta.0",
3
+ "version": "1.3.2-beta.0",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Citrus-Lime Ltd",