string-uglify 3.1.3 → 3.2.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/CHANGELOG.md CHANGED
@@ -3,11 +3,40 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
- ## 3.1.0 (2025-10-15)
6
+ ## 3.2.1 (2026-09-01)
7
+
8
+ ### Bug Fixes
9
+
10
+ - preserve Unicode uglify mappings ([9d8d1b6](https://github.com/codsen/codsen/commit/9d8d1b650dc4c1550f6a661ee00f8f6146d389e1))
11
+ - return an isolated empty uglify result ([16ac475](https://github.com/codsen/codsen/commit/16ac4758f74e0140cae409aceae7dd636b702e0b))
12
+ - validate string uglify inputs ([de630e5](https://github.com/codsen/codsen/commit/de630e50a5ca1e69448cabf4fe786ef5273f99ac))
13
+
14
+ ### Performance Improvements
15
+
16
+ - bound string uglify collisions ([f01b4ce](https://github.com/codsen/codsen/commit/f01b4ce7d763555f5576abb44255d94ec380004f))
17
+ - optimise package hot paths and JSON editing ([f3112bd](https://github.com/codsen/codsen/commit/f3112bd7fc0d7c9bc09312d3744c950691d72ca5))
18
+ - stabilize string uglify validation ([bec9147](https://github.com/codsen/codsen/commit/bec9147eb3dd779250ff73e2665898c5ec68506f))
19
+
20
+ ## 3.2.0 (2026-08-19)
21
+
22
+ ### Bug Fixes
23
+
24
+ - resolve various review findings ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
25
+ - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
7
26
 
8
27
  ### Features
9
28
 
10
- - if value to be added is a number, keep it as is, don't stringify ([ce3e1a5](https://github.com/codsen/codsen/commit/ce3e1a525998ca3c0abf0142affef95b14cd1990))
29
+ - add codsen-glob and migrate glob consumers ([5595a2b](https://github.com/codsen/codsen/commit/5595a2b267eaa6cb60072d037aef00b7a28edd42))
30
+ - refresh the tooling and generate with the latest dependencies ([781f802](https://github.com/codsen/codsen/commit/781f802911066a82a4533b0e5a3fcbd742d0dd83))
31
+
32
+ ### Performance Improvements
33
+
34
+ - index generated names and validate uglifyById ([989a11c](https://github.com/codsen/codsen/commit/989a11c52b9f878ff473caa96024ca91762fbbb4))
35
+
36
+ ### Reverts
37
+
38
+ - Revert "Merge pull request #128 from codsen/release/npm-32198404552-1" ([5baeeaa](https://github.com/codsen/codsen/commit/5baeeaaa677b86f1eaa6396cadf3aea32b06416e)), closes [#128](https://github.com/codsen/codsen/issues/128)
39
+ - Revert "Merge pull request #127 from codsen/release/npm-32194020886-1" ([5f1e94d](https://github.com/codsen/codsen/commit/5f1e94deef910ce735266b16aeee08a76de7a862)), closes [#127](https://github.com/codsen/codsen/issues/127)
11
40
 
12
41
  ## 3.0.0 (2022-12-01)
13
42
 
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright © 2010-2025 Roy Revelt and other contributors
3
+ Copyright © 2010-2026 Roy Revelt and other contributors
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <h1 align="center">string-uglify</h1>
2
2
 
3
- <p align="center">Shorten sets of strings deterministically, to be git-friendly</p>
3
+ <p align="center">Shorten sets of strings deterministically</p>
4
4
 
5
5
  <p align="center">
6
6
  <a href="https://codsen.com/os/string-uglify" rel="nofollow noreferrer noopener">
@@ -32,9 +32,9 @@ npm i string-uglify
32
32
  ## Quick Take
33
33
 
34
34
  ```js
35
- import { strict as assert } from "assert";
35
+ import { strict as assert } from "node:assert";
36
36
 
37
- import { uglifyById, uglifyArr, version } from "string-uglify";
37
+ import { uglifyArr } from "string-uglify";
38
38
 
39
39
  // notice we put dots and hashes for classes and id's but algorithm will work
40
40
  // fine too if you won't.
@@ -45,17 +45,13 @@ const names = [
45
45
  "#zzz",
46
46
  ];
47
47
 
48
- // notice we put dots and hashes for classes and id's but algorithm will work
49
- // fine too if you won't.
50
48
  assert.deepEqual(uglifyArr(names), [".o", ".s", ".z", "#l"]);
51
-
52
- // uglify a particular id number (inefficient):
53
- assert.equal(uglifyById(names, 3), "#l");
54
49
  ```
55
50
 
51
+
56
52
  ## Documentation
57
53
 
58
- Please [visit codsen.com](https://codsen.com/os/string-uglify/) for a full description of the API.
54
+ Please [visit codsen.com](https://codsen.com/os/string-uglify/) for a full description of the API. If you’re looking for the **Changelog**, it’s [here](https://github.com/codsen/codsen/blob/main/packages/string-uglify/CHANGELOG.md).
59
55
 
60
56
  ## Contributing
61
57
 
@@ -65,6 +61,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
65
61
 
66
62
  MIT License
67
63
 
68
- Copyright © 2010-2025 Roy Revelt and other contributors
64
+ Copyright © 2010-2026 Roy Revelt and other contributors
69
65
 
70
66
  <p align="center"><img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center"></p>
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name string-uglify
3
- * @fileoverview Shorten sets of strings deterministically, to be git-friendly
4
- * @version 3.1.3
3
+ * @fileoverview Shorten sets of strings deterministically
4
+ * @version 3.2.1
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-uglify/}
8
8
  */
9
9
 
10
- var $="3.1.3";var D=$;function d(l,o=0){return l.codePointAt(o)||0}function w(l){let o="abcdefghijklmnopqrstuvwxyz",u="abcdefghijklmnopqrstuvwxyz0123456789",n={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},r={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},f={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},s=[];if(!Array.isArray(l)||!l.length)return l;for(let e=0,p=l.length;e<p;e++){if(l.indexOf(l[e])<e){s.push(s[l.indexOf(l[e])]);continue}let b=".#".includes(l[e][0])?l[e][0]:"",h=Array.from(l[e]).reduce((t,c)=>t+d(c),0);if(".#".includes(l[e][0])&&l[e].length<4||!".#".includes(l[e][0])&&l[e].length<3){let t=l[e];if(!s.includes(t)){s.push(t),t.startsWith(".")&&t.length===2&&n[t.slice(1)]===!1?n[t.slice(1)]=!0:t.startsWith("#")&&t.length===2&&r[t.slice(1)]===!1?r[t.slice(1)]=!0:!t.startsWith(".")&&!t.startsWith("#")&&t.length===1&&f[t]===!1&&(f[t]=!0);continue}}let i=`${b}${o[h%o.length]}${u[h%u.length]}`;if(s.includes(i)){let t=i,c=0,y=Array.from(l[e]).reduce((a,g)=>a<200?a+d(g):(a+d(g))%u.length,0),x=Array.from(l[e]).map(a=>d(a)).reduce((a,g)=>{let m=a+g;do m=String(m).split("").reduce((v,j)=>v+Number.parseInt(j,10),0);while(m>=10);return m},0);for(;s.includes(t);)c+=1,t+=u[y*x*c%u.length];i=t}s.push(i),i.startsWith(".")&&i.length===2&&n[i.slice(1)]===!1?n[i.slice(1)]=!0:i.startsWith("#")&&i.length===2&&r[i.slice(1)]===!1?r[i.slice(1)]=!0:!i.startsWith(".")&&!i.startsWith("#")&&i.length===1&&f[i]===!1&&(f[i]=!0)}for(let e=0,p=s.length;e<p;e++)s[e].startsWith(".")?n[s[e].slice(1,2)]===!1?(n[s[e].slice(1,2)]=s[e],s[e]=s[e].slice(0,2)):n[s[e].slice(1,2)]===s[e]&&(s[e]=s[e].slice(0,2)):s[e].startsWith("#")?r[s[e].slice(1,2)]===!1?(r[s[e].slice(1,2)]=s[e],s[e]=s[e].slice(0,2)):r[s[e].slice(1,2)]===s[e]&&(s[e]=s[e].slice(0,2)):!s[e].startsWith(".")&&!s[e].startsWith("#")&&(f[s[e].slice(0,1)]?f[s[e].slice(0,1)]===s[e]&&(s[e]=s[e].slice(0,1)):(f[s[e].slice(0,1)]=s[e],s[e]=s[e].slice(0,1)));return s}function A(l,o){return w(l)[o]}export{w as uglifyArr,A as uglifyById,D as version};
10
+ var x="3.2.1";var E=x;function C(s,e=0){return s.codePointAt(e)||0}function y(s,e=0){let r=s.codePointAt(e);return r===void 0?"":s.slice(e,e+(r>65535?2:1))}function O(s,e){let r=s,o="";do o=e[r%e.length]+o,r=Math.floor(r/e.length);while(r>0);return o}function I(s,e){let r=!1;try{r=Array.isArray(s)}catch{}if(!r)throw new TypeError(`string-uglify/${e}(): [THROW_ID_01] The first input argument must be an array of strings. It was given as type ${s===null?"null":typeof s}.`)}function v(s,e,r,o=!1){throw new TypeError(o?`string-uglify/${s}(): [THROW_ID_02] The first input argument contains an unreadable item at index ${e}.`:`string-uglify/${s}(): [THROW_ID_02] The first input argument contains a non-string item at index ${e} (type ${typeof r}).`)}function P(s,e){I(s,e);let r=s,o=0;try{o=r.length}catch{throw new TypeError(`string-uglify/${e}(): [THROW_ID_02] The first input argument must be a readable array of strings.`)}for(let f=0;f<o;f+=1){let u;try{u=r[f]}catch{v(e,f,void 0,!0)}typeof u!="string"&&v(e,f,u)}}function W(s){I(s,"uglifyArr");let e="abcdefghijklmnopqrstuvwxyz",r="abcdefghijklmnopqrstuvwxyz0123456789",o={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},f={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},u={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},n=[];if(!s.length)return[];let g=s.length>=48?new Set:void 0,c=g?new Map:void 0,p;for(let i=0,h=s.length;i<h;i++){let t=s[i];typeof t!="string"&&v("uglifyArr",i,t);let d;if(c)d=c.get(t);else{let a=s.indexOf(t);a<i&&(d=n[a])}if(d!==void 0){n.push(d);continue}let $=".#".includes(t[0])?t[0]:"",b=0,k=0;for(let a of t)b+=C(a),k+=1;let m=k-($?1:0);if(m<3){let a=t;if(!(g?g.has(a):n.includes(a))){n.push(a),g&&c&&(g.add(a),c.set(t,a));let w=y(a,$?1:0);a.startsWith(".")&&m===1?o[w]=!0:a.startsWith("#")&&m===1?f[w]=!0:!a.startsWith(".")&&!a.startsWith("#")&&m===1&&(u[w]=!0);continue}}let l=`${$}${e[b%e.length]}${r[b%r.length]}`;if(g?g.has(l):n.includes(l)){p||=new Map;let a=p.get(l)||0;p.set(l,a+1),l+=O(a,r)}n.push(l),g&&c&&(g.add(l),c.set(t,l)),l.startsWith(".")&&l.length===2&&o[l.slice(1)]===!1?o[l.slice(1)]=!0:l.startsWith("#")&&l.length===2&&f[l.slice(1)]===!1?f[l.slice(1)]=!0:!l.startsWith(".")&&!l.startsWith("#")&&l.length===1&&u[l]===!1&&(u[l]=!0)}for(let i=0,h=n.length;i<h;i++)if(n[i].startsWith(".")){let t=y(n[i],1);o[t]?o[t]===n[i]&&(n[i]=`.${t}`):(o[t]=n[i],n[i]=`.${t}`)}else if(n[i].startsWith("#")){let t=y(n[i],1);f[t]?f[t]===n[i]&&(n[i]=`#${t}`):(f[t]=n[i],n[i]=`#${t}`)}else if(!n[i].startsWith(".")&&!n[i].startsWith("#")){let t=y(n[i]);u[t]?u[t]===n[i]&&(n[i]=t):(u[t]=n[i],n[i]=t)}return n}function A(s,e){if(P(s,"uglifyById"),!Number.isInteger(e))throw new TypeError(`string-uglify/uglifyById(): [THROW_ID_03] The second input argument, idNum, must be an integer. It was given as type ${e===null?"null":typeof e}${typeof e=="number"?` with value ${String(e)}`:""}.`);if(e<0||e>=s.length)throw new RangeError(`string-uglify/uglifyById(): [THROW_ID_04] The second input argument, idNum, must point to an item in refArr. It was given as ${e}, while refArr contains ${s.length} item${s.length===1?"":"s"}.`);return W(s)[e]}export{W as uglifyArr,A as uglifyById,E as version};
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name string-uglify
3
- * @fileoverview Shorten sets of strings deterministically, to be git-friendly
4
- * @version 3.1.3
3
+ * @fileoverview Shorten sets of strings deterministically
4
+ * @version 3.2.1
5
5
  * @author Roy Revelt
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/string-uglify/}
8
8
  */
9
9
 
10
- "use strict";var stringUglify=(()=>{var h=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var A=(l,n)=>{for(var f in n)h(l,f,{get:n[f],enumerable:!0})},N=(l,n,f,a)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of k(n))!D.call(l,r)&&r!==f&&h(l,r,{get:()=>n[r],enumerable:!(a=E(n,r))||a.enumerable});return l};var O=l=>N(h({},"__esModule",{value:!0}),l);var I={};A(I,{uglifyArr:()=>y,uglifyById:()=>S,version:()=>C});var b="3.1.3";var C=b;function d(l,n=0){return l.codePointAt(n)||0}function y(l){let n="abcdefghijklmnopqrstuvwxyz",f="abcdefghijklmnopqrstuvwxyz0123456789",a={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},r={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},o={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},s=[];if(!Array.isArray(l)||!l.length)return l;for(let e=0,p=l.length;e<p;e++){if(l.indexOf(l[e])<e){s.push(s[l.indexOf(l[e])]);continue}let x=".#".includes(l[e][0])?l[e][0]:"",$=Array.from(l[e]).reduce((t,c)=>t+d(c),0);if(".#".includes(l[e][0])&&l[e].length<4||!".#".includes(l[e][0])&&l[e].length<3){let t=l[e];if(!s.includes(t)){s.push(t),t.startsWith(".")&&t.length===2&&a[t.slice(1)]===!1?a[t.slice(1)]=!0:t.startsWith("#")&&t.length===2&&r[t.slice(1)]===!1?r[t.slice(1)]=!0:!t.startsWith(".")&&!t.startsWith("#")&&t.length===1&&o[t]===!1&&(o[t]=!0);continue}}let i="".concat(x).concat(n[$%n.length]).concat(f[$%f.length]);if(s.includes(i)){let t=i,c=0,v=Array.from(l[e]).reduce((u,g)=>u<200?u+d(g):(u+d(g))%f.length,0),j=Array.from(l[e]).map(u=>d(u)).reduce((u,g)=>{let m=u+g;do m=String(m).split("").reduce((W,w)=>W+Number.parseInt(w,10),0);while(m>=10);return m},0);for(;s.includes(t);)c+=1,t+=f[v*j*c%f.length];i=t}s.push(i),i.startsWith(".")&&i.length===2&&a[i.slice(1)]===!1?a[i.slice(1)]=!0:i.startsWith("#")&&i.length===2&&r[i.slice(1)]===!1?r[i.slice(1)]=!0:!i.startsWith(".")&&!i.startsWith("#")&&i.length===1&&o[i]===!1&&(o[i]=!0)}for(let e=0,p=s.length;e<p;e++)s[e].startsWith(".")?a[s[e].slice(1,2)]===!1?(a[s[e].slice(1,2)]=s[e],s[e]=s[e].slice(0,2)):a[s[e].slice(1,2)]===s[e]&&(s[e]=s[e].slice(0,2)):s[e].startsWith("#")?r[s[e].slice(1,2)]===!1?(r[s[e].slice(1,2)]=s[e],s[e]=s[e].slice(0,2)):r[s[e].slice(1,2)]===s[e]&&(s[e]=s[e].slice(0,2)):!s[e].startsWith(".")&&!s[e].startsWith("#")&&(o[s[e].slice(0,1)]?o[s[e].slice(0,1)]===s[e]&&(s[e]=s[e].slice(0,1)):(o[s[e].slice(0,1)]=s[e],s[e]=s[e].slice(0,1)));return s}function S(l,n){return y(l)[n]}return O(I);})();
10
+ "use strict";var stringUglify=(()=>{var v=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var T=(s,e)=>{for(var l in e)v(s,l,{get:e[l],enumerable:!0})},D=(s,e,l,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of P(e))!W.call(s,o)&&o!==l&&v(s,o,{get:()=>e[o],enumerable:!(a=O(e,o))||a.enumerable});return s};var E=s=>D(v({},"__esModule",{value:!0}),s);var V={};T(V,{uglifyArr:()=>C,uglifyById:()=>S,version:()=>_});var I="3.2.1";var _=I;function R(s,e=0){return s.codePointAt(e)||0}function p(s,e=0){let l=s.codePointAt(e);return l===void 0?"":s.slice(e,e+(l>65535?2:1))}function B(s,e){let l=s,a="";do a=e[l%e.length]+a,l=Math.floor(l/e.length);while(l>0);return a}function j(s,e){let l=!1;try{l=Array.isArray(s)}catch(a){}if(!l)throw new TypeError("string-uglify/".concat(e,"(): [THROW_ID_01] The first input argument must be an array of strings. It was given as type ").concat(s===null?"null":typeof s,"."))}function k(s,e,l,a=!1){throw new TypeError(a?"string-uglify/".concat(s,"(): [THROW_ID_02] The first input argument contains an unreadable item at index ").concat(e,"."):"string-uglify/".concat(s,"(): [THROW_ID_02] The first input argument contains a non-string item at index ").concat(e," (type ").concat(typeof l,")."))}function N(s,e){j(s,e);let l=s,a=0;try{a=l.length}catch(o){throw new TypeError("string-uglify/".concat(e,"(): [THROW_ID_02] The first input argument must be a readable array of strings."))}for(let o=0;o<a;o+=1){let u;try{u=l[o]}catch(t){k(e,o,void 0,!0)}typeof u!="string"&&k(e,o,u)}}function C(s){j(s,"uglifyArr");let e="abcdefghijklmnopqrstuvwxyz",l="abcdefghijklmnopqrstuvwxyz0123456789",a={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},o={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},u={a:!1,b:!1,c:!1,d:!1,e:!1,f:!1,g:!1,h:!1,i:!1,j:!1,k:!1,l:!1,m:!1,n:!1,o:!1,p:!1,q:!1,r:!1,s:!1,t:!1,u:!1,v:!1,w:!1,x:!1,y:!1,z:!1},t=[];if(!s.length)return[];let g=s.length>=48?new Set:void 0,c=g?new Map:void 0,d;for(let i=0,h=s.length;i<h;i++){let n=s[i];typeof n!="string"&&k("uglifyArr",i,n);let m;if(c)m=c.get(n);else{let f=s.indexOf(n);f<i&&(m=t[f])}if(m!==void 0){t.push(m);continue}let $=".#".includes(n[0])?n[0]:"",b=0,x=0;for(let f of n)b+=R(f),x+=1;let y=x-($?1:0);if(y<3){let f=n;if(!(g?g.has(f):t.includes(f))){t.push(f),g&&c&&(g.add(f),c.set(n,f));let w=p(f,$?1:0);f.startsWith(".")&&y===1?a[w]=!0:f.startsWith("#")&&y===1?o[w]=!0:!f.startsWith(".")&&!f.startsWith("#")&&y===1&&(u[w]=!0);continue}}let r="".concat($).concat(e[b%e.length]).concat(l[b%l.length]);if(g?g.has(r):t.includes(r)){d||(d=new Map);let f=d.get(r)||0;d.set(r,f+1),r+=B(f,l)}t.push(r),g&&c&&(g.add(r),c.set(n,r)),r.startsWith(".")&&r.length===2&&a[r.slice(1)]===!1?a[r.slice(1)]=!0:r.startsWith("#")&&r.length===2&&o[r.slice(1)]===!1?o[r.slice(1)]=!0:!r.startsWith(".")&&!r.startsWith("#")&&r.length===1&&u[r]===!1&&(u[r]=!0)}for(let i=0,h=t.length;i<h;i++)if(t[i].startsWith(".")){let n=p(t[i],1);a[n]?a[n]===t[i]&&(t[i]=".".concat(n)):(a[n]=t[i],t[i]=".".concat(n))}else if(t[i].startsWith("#")){let n=p(t[i],1);o[n]?o[n]===t[i]&&(t[i]="#".concat(n)):(o[n]=t[i],t[i]="#".concat(n))}else if(!t[i].startsWith(".")&&!t[i].startsWith("#")){let n=p(t[i]);u[n]?u[n]===t[i]&&(t[i]=n):(u[n]=t[i],t[i]=n)}return t}function S(s,e){if(N(s,"uglifyById"),!Number.isInteger(e))throw new TypeError("string-uglify/uglifyById(): [THROW_ID_03] The second input argument, idNum, must be an integer. It was given as type ".concat(e===null?"null":typeof e).concat(typeof e=="number"?" with value ".concat(String(e)):"","."));if(e<0||e>=s.length)throw new RangeError("string-uglify/uglifyById(): [THROW_ID_04] The second input argument, idNum, must point to an item in refArr. It was given as ".concat(e,", while refArr contains ").concat(s.length," item").concat(s.length===1?"":"s","."));return C(s)[e]}return E(V);})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "string-uglify",
3
- "version": "3.1.3",
4
- "description": "Shorten sets of strings deterministically, to be git-friendly",
3
+ "version": "3.2.1",
4
+ "description": "Shorten sets of strings deterministically",
5
5
  "keywords": [
6
6
  "class",
7
7
  "classes",
@@ -40,42 +40,41 @@
40
40
  },
41
41
  "types": "types/index.d.ts",
42
42
  "scripts": {
43
- "build": "node '../../ops/scripts/esbuild.js' && npm run dts",
44
- "cjs-off": "exit 0",
45
- "cjs-on": "exit 0",
46
- "dev": "DEV=true node '../../ops/scripts/esbuild.js' && npm run dts",
43
+ "build": "node ../../ops/scripts/esbuild.js && npm run dts",
44
+ "coverage": "c8 uvu test",
45
+ "dev": "node ../../ops/scripts/esbuild.js --dev && npm run dts",
47
46
  "devtest": "c8 npm run unit && npm run examples && npm run lint",
48
- "dts": "rollup -c && npm run prettier -- 'types/index.d.ts' --write --log-level 'silent'",
47
+ "dts": "rollup -c && biome format --write --config-path=../../biome.json --vcs-enabled=false --use-editorconfig=false types/index.d.ts",
49
48
  "examples": "node '../../ops/scripts/run-examples.js'",
50
- "lect": "node '../../ops/lect/lect.js' && npm run prettier -- 'README.md' '.all-contributorsrc' 'rollup.config.js' --write",
51
- "letspublish": "npm publish --provenance || :",
52
- "lint": "eslint . --fix --concurrency=auto --cache",
49
+ "lect": "node '../../ops/lect/lect.js'",
50
+ "lect:check": "node '../../ops/lect/lect.js' --check",
51
+ "lint": "biome lint --error-on-warnings . && npm run typecheck",
52
+ "lint:fix": "biome lint --write --error-on-warnings . && npm run typecheck",
53
53
  "perf": "node perf/check.js",
54
54
  "prep": "echo 'ready'",
55
- "prettier": "prettier",
56
- "prettier:format": "npm run prettier -- --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern --log-level 'silent'",
57
- "pretest": "npm run lect && npm run build",
55
+ "prettier": "biome format",
56
+ "prettier:format": "biome format --write .",
57
+ "pretest": "npm run lect:check && npm run build",
58
58
  "test": "npm run devtest",
59
+ "typecheck": "tsc --noEmit --pretty false --project tsconfig.json",
59
60
  "unit": "uvu test"
60
61
  },
61
- "engines": {
62
- "node": ">=14.18.0"
63
- },
64
62
  "c8": {
63
+ "all": true,
65
64
  "check-coverage": true,
66
- "exclude": [
67
- "**/test/**/*.*"
68
- ],
65
+ "exclude": ["**/test/**/*.*"],
66
+ "include": ["dist/*.esm.js"],
69
67
  "lines": 100
70
68
  },
71
69
  "lect": {
72
70
  "licence": {
73
- "extras": [
74
- ""
75
- ]
71
+ "extras": [""]
76
72
  },
77
73
  "various": {}
78
74
  },
75
+ "engines": {
76
+ "node": ">=18.20.8"
77
+ },
79
78
  "publishConfig": {
80
79
  "registry": "https://registry.npmjs.org/"
81
80
  }