@citruslime/utils 2.0.4 → 2.0.5

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.
@@ -67,13 +67,13 @@ function m(t, n) {
67
67
  let o;
68
68
  for (let r = 1; r <= n.length; r++) {
69
69
  let i = r;
70
- const h = n[r - 1];
70
+ const c = n[r - 1];
71
71
  for (let l = 1; l <= t.length; l++) {
72
- if (h === t[l - 1])
72
+ if (c === t[l - 1])
73
73
  o = e[l - 1];
74
74
  else {
75
- const c = i + 1, s = e[l] + 1, a = c - (c - s & s - c >> 7), u = e[l - 1] + 1;
76
- o = a - (a - u & u - a >> 7);
75
+ const h = i + 1, u = e[l] + 1, a = h - (h - u & u - h >> 7), s = e[l - 1] + 1;
76
+ o = a - (a - s & s - a >> 7);
77
77
  }
78
78
  e[l - 1] = i, i = o;
79
79
  }
@@ -94,27 +94,31 @@ function d(t) {
94
94
  function C(t, n, e) {
95
95
  return t[e] < n[e] ? -1 : t[e] > n[e] ? 1 : 0;
96
96
  }
97
- function w(t, n) {
97
+ function v(t, n) {
98
98
  let e = "";
99
- const o = decodeURIComponent(t), r = "[\\?&]" + n + "=([^&#]*)", h = new RegExp(r).exec(o);
100
- return h && h[1] && (e = decodeURIComponent(h[1].replace(/\+/g, " "))), e;
99
+ const o = decodeURIComponent(t), r = "[\\?&]" + n + "=([^&#]*)", c = new RegExp(r).exec(o);
100
+ return c && c[1] && (e = decodeURIComponent(c[1].replace(/\+/g, " "))), e;
101
101
  }
102
- function $(t, n) {
102
+ function w(t, n) {
103
103
  const e = Object.keys(t).find((o) => o.toLowerCase() === n.toLowerCase());
104
104
  return e ? t[e] : null;
105
105
  }
106
- function v(t) {
106
+ function T(t) {
107
107
  return !!t && /^[^@]+@[^@]+\.[^@]+$/.exec(t) !== null;
108
108
  }
109
+ function $() {
110
+ return navigator && "maxTouchPoints" in navigator && navigator.maxTouchPoints > 0;
111
+ }
109
112
  export {
110
113
  y as chunk,
111
114
  C as compareByProperty,
112
115
  p as escapeStringForRegExp,
113
116
  x as generateStringId,
114
- $ as getCaseInsensitiveQueryParam,
115
- w as getParamsByName,
117
+ w as getCaseInsensitiveQueryParam,
118
+ v as getParamsByName,
116
119
  f as highlightText,
120
+ $ as isTouchDevice,
117
121
  d as nameOf,
118
122
  g as replacePlaceholders,
119
- v as validateEmail
123
+ T as validateEmail
120
124
  };
@@ -1 +1 @@
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 f(e,n,t="cl-bg-primary-light cl-font-bold cl-px-0.5"){const o=n.map(r=>`(${g(r)})`).join("|");return e.replace(new RegExp(o,"ig"),r=>`<span class="${t}">${r}</span>`)}function g(e){return e.replace(/[-[\]{}()*+?.,\\/^$|]/g,"\\$&")}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-d(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 d(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 c=n[r-1];for(let a=1;a<=e.length;a++){if(c===e[a-1])o=t[a-1];else{const u=l+1,p=t[a]+1,s=u-(u-p&p-u>>7),m=t[a-1]+1;o=s-(s-m&m-s>>7)}t[a-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 C(){return Math.random().toString(36).slice(2,8)}function v(e){return e}function P(e,n,t){return e[t]<n[t]?-1:e[t]>n[t]?1:0}function w(e,n){let t="";const o=decodeURIComponent(e),r="[\\?&]"+n+"=([^&#]*)",c=new RegExp(r).exec(o);return c&&c[1]&&(t=decodeURIComponent(c[1].replace(/\+/g," "))),t}function x(e,n){const t=Object.keys(e).find(o=>o.toLowerCase()===n.toLowerCase());return t?e[t]:null}function S(e){return!!e&&/^[^@]+@[^@]+\.[^@]+$/.exec(e)!==null}i.chunk=y,i.compareByProperty=P,i.escapeStringForRegExp=g,i.generateStringId=C,i.getCaseInsensitiveQueryParam=x,i.getParamsByName=w,i.highlightText=f,i.nameOf=v,i.replacePlaceholders=h,i.validateEmail=S,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
1
+ (function(i,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(i=typeof globalThis<"u"?globalThis:i||self,c(i.CitrusLimeUtils={}))})(this,function(i){"use strict";function c(e,...n){let t=0;return e.replace(/{\d+}/g,()=>typeof n[t]<"u"?n[t++]:"")}function f(e,n,t="cl-bg-primary-light cl-font-bold cl-px-0.5"){const o=n.map(r=>`(${g(r)})`).join("|");return e.replace(new RegExp(o,"ig"),r=>`<span class="${t}">${r}</span>`)}function g(e){return e.replace(/[-[\]{}()*+?.,\\/^$|]/g,"\\$&")}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-d(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 c(this,...e)},String.prototype.toDateFromTime=function(){return new Date(`${new Date().toISOString().substr(0,11)}${this}`)};function d(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 h=n[r-1];for(let a=1;a<=e.length;a++){if(h===e[a-1])o=t[a-1];else{const u=l+1,p=t[a]+1,s=u-(u-p&p-u>>7),m=t[a-1]+1;o=s-(s-m&m-s>>7)}t[a-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 v(){return Math.random().toString(36).slice(2,8)}function C(e){return e}function T(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+"=([^&#]*)",h=new RegExp(r).exec(o);return h&&h[1]&&(t=decodeURIComponent(h[1].replace(/\+/g," "))),t}function x(e,n){const t=Object.keys(e).find(o=>o.toLowerCase()===n.toLowerCase());return t?e[t]:null}function w(e){return!!e&&/^[^@]+@[^@]+\.[^@]+$/.exec(e)!==null}function S(){return navigator&&"maxTouchPoints"in navigator&&navigator.maxTouchPoints>0}i.chunk=y,i.compareByProperty=T,i.escapeStringForRegExp=g,i.generateStringId=v,i.getCaseInsensitiveQueryParam=x,i.getParamsByName=P,i.highlightText=f,i.isTouchDevice=S,i.nameOf=C,i.replacePlaceholders=c,i.validateEmail=w,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
@@ -6,3 +6,4 @@ export * from './sort';
6
6
  export * from './strings';
7
7
  export * from './url-params';
8
8
  export * from './validation';
9
+ export * from './navigator';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Checks if the device is a touch device.
3
+ *
4
+ * @returns True if the device is a touch device, false otherwise.
5
+ */
6
+ export declare function isTouchDevice(): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citruslime/utils",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Citrus-Lime Ltd",