string-uglify 3.2.0 → 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,25 @@
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.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
+
6
20
  ## 3.2.0 (2026-08-19)
7
21
 
8
22
  ### Bug Fixes
9
23
 
10
- - resolve review findings REV-004 through REV-007 ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
24
+ - resolve various review findings ([b60e9ee](https://github.com/codsen/codsen/commit/b60e9eeb499af94685cfb87b4970fe025be1fc10))
11
25
  - retire direct publish aliases ([f98e31e](https://github.com/codsen/codsen/commit/f98e31eb89bc185471225664e610b55f34fbf648))
12
26
 
13
27
  ### Features
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * @name string-uglify
3
3
  * @fileoverview Shorten sets of strings deterministically
4
- * @version 3.2.0
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 v="3.2.0";var E=v;function w(t,n=0){return t.codePointAt(n)||0}function W(t){let n="abcdefghijklmnopqrstuvwxyz",g="abcdefghijklmnopqrstuvwxyz0123456789",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},c={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(t)||!t.length)return t;let f=t.length>=48?new Set:void 0,u=f?new Map:void 0;for(let e=0,h=t.length;e<h;e++){let m;if(u)m=u.get(t[e]);else{let l=t.indexOf(t[e]);l<e&&(m=s[l])}if(m!==void 0){s.push(m);continue}let j=".#".includes(t[e][0])?t[e][0]:"",p=0;for(let l of t[e])p+=w(l);if(".#".includes(t[e][0])&&t[e].length<4||!".#".includes(t[e][0])&&t[e].length<3){let l=t[e];if(!(f?f.has(l):s.includes(l))){s.push(l),f&&u&&(f.add(l),u.set(t[e],l)),l.startsWith(".")&&l.length===2&&r[l.slice(1)]===!1?r[l.slice(1)]=!0:l.startsWith("#")&&l.length===2&&o[l.slice(1)]===!1?o[l.slice(1)]=!0:!l.startsWith(".")&&!l.startsWith("#")&&l.length===1&&c[l]===!1&&(c[l]=!0);continue}}let i=`${j}${n[p%n.length]}${g[p%g.length]}`;if(f?f.has(i):s.includes(i)){let l=i,y=0,d=0,a=0;for(let x of t[e]){let $=w(x);for(d=d<200?d+$:(d+$)%g.length,a+=$;a>=10;){let b=0;for(;a>0;)b+=a%10,a=Math.floor(a/10);a=b}}for(;f?f.has(l):s.includes(l);)y+=1,l+=g[d*a*y%g.length];i=l}s.push(i),f&&u&&(f.add(i),u.set(t[e],i)),i.startsWith(".")&&i.length===2&&r[i.slice(1)]===!1?r[i.slice(1)]=!0:i.startsWith("#")&&i.length===2&&o[i.slice(1)]===!1?o[i.slice(1)]=!0:!i.startsWith(".")&&!i.startsWith("#")&&i.length===1&&c[i]===!1&&(c[i]=!0)}for(let e=0,h=s.length;e<h;e++)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("#")?o[s[e].slice(1,2)]===!1?(o[s[e].slice(1,2)]=s[e],s[e]=s[e].slice(0,2)):o[s[e].slice(1,2)]===s[e]&&(s[e]=s[e].slice(0,2)):!s[e].startsWith(".")&&!s[e].startsWith("#")&&(c[s[e].slice(0,1)]?c[s[e].slice(0,1)]===s[e]&&(s[e]=s[e].slice(0,1)):(c[s[e].slice(0,1)]=s[e],s[e]=s[e].slice(0,1)));return s}function D(t,n){if(!Number.isInteger(n))throw new TypeError(`string-uglify/uglifyById(): [THROW_ID_01] The second input argument, idNum, must be an integer. It was given as ${String(n)} (type ${typeof n}).`);if(n<0||n>=t.length)throw new RangeError(`string-uglify/uglifyById(): [THROW_ID_02] The second input argument, idNum, must point to an item in refArr. It was given as ${n}, while refArr contains ${t.length} item${t.length===1?"":"s"}.`);return W(t)[n]}export{W as uglifyArr,D as uglifyById,E 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
3
  * @fileoverview Shorten sets of strings deterministically
4
- * @version 3.2.0
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 y=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var E=Object.prototype.hasOwnProperty;var D=(l,i)=>{for(var r in i)y(l,r,{get:i[r],enumerable:!0})},S=(l,i,r,o)=>{if(i&&typeof i=="object"||typeof i=="function")for(let f of I(i))!E.call(l,f)&&f!==r&&y(l,f,{get:()=>i[f],enumerable:!(o=O(i,f))||o.enumerable});return l};var C=l=>S(y({},"__esModule",{value:!0}),l);var T={};D(T,{uglifyArr:()=>x,uglifyById:()=>R,version:()=>N});var w="3.2.0";var N=w;function j(l,i=0){return l.codePointAt(i)||0}function x(l){let i="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},s=[];if(!Array.isArray(l)||!l.length)return l;let a=l.length>=48?new Set:void 0,g=a?new Map:void 0;for(let e=0,h=l.length;e<h;e++){let m;if(g)m=g.get(l[e]);else{let t=l.indexOf(l[e]);t<e&&(m=s[t])}if(m!==void 0){s.push(m);continue}let k=".#".includes(l[e][0])?l[e][0]:"",p=0;for(let t of l[e])p+=j(t);if(".#".includes(l[e][0])&&l[e].length<4||!".#".includes(l[e][0])&&l[e].length<3){let t=l[e];if(!(a?a.has(t):s.includes(t))){s.push(t),a&&g&&(a.add(t),g.set(l[e],t)),t.startsWith(".")&&t.length===2&&o[t.slice(1)]===!1?o[t.slice(1)]=!0:t.startsWith("#")&&t.length===2&&f[t.slice(1)]===!1?f[t.slice(1)]=!0:!t.startsWith(".")&&!t.startsWith("#")&&t.length===1&&u[t]===!1&&(u[t]=!0);continue}}let n="".concat(k).concat(i[p%i.length]).concat(r[p%r.length]);if(a?a.has(n):s.includes(n)){let t=n,b=0,d=0,c=0;for(let W of l[e]){let $=j(W);for(d=d<200?d+$:(d+$)%r.length,c+=$;c>=10;){let v=0;for(;c>0;)v+=c%10,c=Math.floor(c/10);c=v}}for(;a?a.has(t):s.includes(t);)b+=1,t+=r[d*c*b%r.length];n=t}s.push(n),a&&g&&(a.add(n),g.set(l[e],n)),n.startsWith(".")&&n.length===2&&o[n.slice(1)]===!1?o[n.slice(1)]=!0:n.startsWith("#")&&n.length===2&&f[n.slice(1)]===!1?f[n.slice(1)]=!0:!n.startsWith(".")&&!n.startsWith("#")&&n.length===1&&u[n]===!1&&(u[n]=!0)}for(let e=0,h=s.length;e<h;e++)s[e].startsWith(".")?o[s[e].slice(1,2)]===!1?(o[s[e].slice(1,2)]=s[e],s[e]=s[e].slice(0,2)):o[s[e].slice(1,2)]===s[e]&&(s[e]=s[e].slice(0,2)):s[e].startsWith("#")?f[s[e].slice(1,2)]===!1?(f[s[e].slice(1,2)]=s[e],s[e]=s[e].slice(0,2)):f[s[e].slice(1,2)]===s[e]&&(s[e]=s[e].slice(0,2)):!s[e].startsWith(".")&&!s[e].startsWith("#")&&(u[s[e].slice(0,1)]?u[s[e].slice(0,1)]===s[e]&&(s[e]=s[e].slice(0,1)):(u[s[e].slice(0,1)]=s[e],s[e]=s[e].slice(0,1)));return s}function R(l,i){if(!Number.isInteger(i))throw new TypeError("string-uglify/uglifyById(): [THROW_ID_01] The second input argument, idNum, must be an integer. It was given as ".concat(String(i)," (type ").concat(typeof i,")."));if(i<0||i>=l.length)throw new RangeError("string-uglify/uglifyById(): [THROW_ID_02] The second input argument, idNum, must point to an item in refArr. It was given as ".concat(i,", while refArr contains ").concat(l.length," item").concat(l.length===1?"":"s","."));return x(l)[i]}return C(T);})();
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,6 +1,6 @@
1
1
  {
2
2
  "name": "string-uglify",
3
- "version": "3.2.0",
3
+ "version": "3.2.1",
4
4
  "description": "Shorten sets of strings deterministically",
5
5
  "keywords": [
6
6
  "class",