@citruslime/utils 2.0.7 → 3.0.0-beta.1

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Citrus-Lime Utils
2
2
 
3
- A package containing utilities for JavaScript & TypeScript projects. Used by [Citrus-Lime UI](https://www.npmjs.com/package/@citruslime/ui).
3
+ A utilities library, for JavaScript & TypeScript projects. Used by [Citrus-Lime UI](https://www.npmjs.com/package/@citruslime/ui).
4
4
 
5
5
  ![version](https://img.shields.io/npm/v/@citruslime/utils/latest)
6
6
  ![version next](https://img.shields.io/npm/v/@citruslime/utils/next)
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -1,8 +1,9 @@
1
1
  /**
2
2
  * A generator function which splits a string or array into chunks.
3
3
  *
4
+ * @template T The type of the value to split.
4
5
  * @param value The value to split.
5
6
  * @param size The size of each chunk.
6
- * @yields The chunks.
7
+ * @yields {string | T[]} The chunks.
7
8
  */
8
9
  export declare function chunk<T>(value: string | T[], size: number): Generator<string | T[], any, undefined>;
@@ -2,7 +2,7 @@
2
2
  * Replace placeholders within a string.
3
3
  *
4
4
  * @param value The string to replace the placeholders for.
5
- * @param {...any} replacements The replacements.
5
+ * @param {...string} replacements The replacements.
6
6
  * @returns The original value with the replacements replaced.
7
7
  */
8
8
  export declare function replacePlaceholders(value: string, ...replacements: string[]): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@citruslime/utils",
3
- "version": "2.0.7",
3
+ "version": "3.0.0-beta.1",
4
4
  "type": "module",
5
5
  "author": {
6
6
  "name": "Citrus-Lime Ltd",
@@ -17,21 +17,30 @@
17
17
  "maintainers": [
18
18
  "Citrus-Lime"
19
19
  ],
20
- "main": "dist/citrus-lime-utils.umd.js",
21
- "module": "dist/citrus-lime-utils.es.js",
22
- "types": "dist/main.d.ts",
23
20
  "exports": {
24
21
  ".": {
25
- "types": "./dist/main.d.ts",
26
- "import": "./dist/citrus-lime-utils.es.js",
27
- "require": "./dist/citrus-lime-utils.umd.js"
22
+ "import": "./dist/citrus-lime-utils.js",
23
+ "types": "./dist/main.d.ts"
28
24
  }
29
25
  },
26
+ "devDependencies": {
27
+ "@citruslime/config": "~0.0.0",
28
+ "@citruslime/tsconfig": "~0.0.0",
29
+ "@types/jsdom": "^27.0.0",
30
+ "@types/node": "^25.3.0",
31
+ "@vitejs/plugin-vue": "^6.0.1",
32
+ "jsdom": "^28.1.0",
33
+ "npm-run-all": "^4.1.5",
34
+ "typescript": "^5.9.2",
35
+ "vite": "^7.1.3",
36
+ "vitest": "^4.0.18",
37
+ "vue-tsc": "^3.2.5"
38
+ },
30
39
  "scripts": {
31
- "build": "run-p build-source build-types",
32
- "build-source": "vite build",
33
- "build-types": "vue-tsc --declaration --emitDeclarationOnly --declarationDir ./dist --project ./tsconfig.app.json --composite false",
34
- "lint": "eslint . --fix",
40
+ "build": "run-p build-only build-types",
41
+ "build-only": "vite build",
42
+ "build-types": "vue-tsc -p ./tsconfig.d.json",
43
+ "lint": "eslint . --fix --cache",
35
44
  "test": "vitest"
36
45
  }
37
46
  }
@@ -1 +0,0 @@
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"){const o=n.filter(r=>!!r?.trim()).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 w(e,n){const t=Object.keys(e).find(o=>o.toLowerCase()===n.toLowerCase());return t?e[t]:null}function x(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=w,i.getParamsByName=P,i.highlightText=f,i.isTouchDevice=S,i.nameOf=C,i.replacePlaceholders=c,i.validateEmail=x,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));