string-uglify 3.2.0 → 3.2.2
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 +15 -1
- package/README.md +3 -1
- package/dist/string-uglify.esm.js +2 -2
- package/dist/string-uglify.umd.js +2 -2
- package/package.json +1 -1
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
|
|
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
|
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
<img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg?style=flat-square" alt="MIT Licence">
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
|
+
**No dependencies whatsoever.** This package declares no dependencies or devDependencies.
|
|
25
|
+
|
|
24
26
|
## Install
|
|
25
27
|
|
|
26
28
|
This package is [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you're not ready yet, install an older version of this program, 1.5.0 (`npm i string-uglify@1.5.0`).
|
|
@@ -51,7 +53,7 @@ assert.deepEqual(uglifyArr(names), [".o", ".s", ".z", "#l"]);
|
|
|
51
53
|
|
|
52
54
|
## Documentation
|
|
53
55
|
|
|
54
|
-
Please [visit codsen.com](https://codsen.com/os/string-uglify/) for a full description of the API.
|
|
56
|
+
Please [visit codsen.com](https://codsen.com/os/string-uglify/) for a full description of the API. For **Changelog**, see [raw md on GitHub](https://github.com/codsen/codsen/blob/main/packages/string-uglify/CHANGELOG.md) or [the website](https://codsen.com/os/string-uglify/changelog).
|
|
55
57
|
|
|
56
58
|
## Contributing
|
|
57
59
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-uglify
|
|
3
3
|
* @fileoverview Shorten sets of strings deterministically
|
|
4
|
-
* @version 3.2.
|
|
4
|
+
* @version 3.2.2
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-uglify/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var
|
|
10
|
+
var x="3.2.2";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.
|
|
4
|
+
* @version 3.2.2
|
|
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
|
|
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.2";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);})();
|