@citruslime/utils 1.3.0-beta.0 → 1.3.1-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.
@@ -69,8 +69,8 @@ function g(t, n) {
69
69
  if (h === t[l - 1])
70
70
  o = e[l - 1];
71
71
  else {
72
- const c = i + 1, s = e[l] + 1, u = c - (c - s & s - c >> 7), a = e[l - 1] + 1;
73
- o = u - (u - a & a - u >> 7);
72
+ const c = i + 1, a = e[l] + 1, s = c - (c - a & a - c >> 7), u = e[l - 1] + 1;
73
+ o = s - (s - u & u - s >> 7);
74
74
  }
75
75
  e[l - 1] = i, i = o;
76
76
  }
@@ -85,23 +85,28 @@ function* f(t, n) {
85
85
  function y() {
86
86
  return Math.random().toString(36).slice(2, 8);
87
87
  }
88
- function x(t) {
88
+ function C(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 C(t, n) {
94
+ function x(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;
98
98
  }
99
+ function w(t, n) {
100
+ const e = Object.keys(t).find((o) => o.toLowerCase() === n.toLowerCase());
101
+ return e ? t[e] : null;
102
+ }
99
103
  export {
100
104
  f as chunk,
101
105
  d as compareByProperty,
102
106
  y as generateStringId,
103
- C as getParamsByName,
107
+ w as getCaseInsensitiveQueryParam,
108
+ x as getParamsByName,
104
109
  m as highlightText,
105
- x as nameOf,
110
+ C as nameOf,
106
111
  p as replacePlaceholders
107
112
  };
@@ -1 +1 @@
1
- (function(o,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(o=typeof globalThis<"u"?globalThis:o||self,c(o.CitrusLimeUtils={}))})(this,function(o){"use strict";function c(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 i=n.map(r=>`(${r})`).join("|");return e.replace(new RegExp(i,"ig"),r=>`<span class="${t}">${r}</span>`)}String.prototype.similarity=function(e){let n=0,t=this.toLowerCase(),i=e.toLowerCase();if(t<i){const l=i;i=t,t=l}const r=t.length;return r===0?n=100:n=Math.round((r-f(t,i))/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 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 i;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])i=t[h-1];else{const a=l+1,g=t[h]+1,s=a-(a-g&g-a>>7),p=t[h-1]+1;i=s-(s-p&p-s>>7)}t[h-1]=l,l=i}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 T(e,n,t){return e[t]<n[t]?-1:e[t]>n[t]?1:0}function b(e,n){let t="";const i=decodeURIComponent(e),r="[\\?&]"+n+"=([^&#]*)",u=new RegExp(r).exec(i);return u&&u[1]&&(t=decodeURIComponent(u[1].replace(/\+/g," "))),t}o.chunk=d,o.compareByProperty=T,o.generateStringId=y,o.getParamsByName=b,o.highlightText=m,o.nameOf=C,o.replacePlaceholders=c,Object.defineProperty(o,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*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"})});
@@ -6,3 +6,12 @@
6
6
  * @returns The param, if found, or an empty string.
7
7
  */
8
8
  export declare function getParamsByName(stringToSearch: string, paramToFind: string): string;
9
+ /**
10
+ * Gets a query param (case insensitive).
11
+ *
12
+ * @param query The query params.
13
+ * @param key The key for the param.
14
+ *
15
+ * @returns The value for the query param.
16
+ */
17
+ export declare function getCaseInsensitiveQueryParam(query: Record<string, unknown>, key: string): unknown | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citruslime/utils",
3
- "version": "1.3.0-beta.0",
3
+ "version": "1.3.1-beta.0",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Citrus-Lime Ltd",
@@ -30,6 +30,7 @@
30
30
  "scripts": {
31
31
  "build": "run-p build-source build-types",
32
32
  "build-source": "vite build",
33
- "build-types": "vue-tsc --declaration --emitDeclarationOnly --declarationDir ./dist --project ./tsconfig.app.json --composite false"
33
+ "build-types": "vue-tsc --declaration --emitDeclarationOnly --declarationDir ./dist --project ./tsconfig.app.json --composite false",
34
+ "test": "vitest"
34
35
  }
35
36
  }