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 +31 -2
- package/LICENSE +1 -1
- package/README.md +6 -10
- package/dist/string-uglify.esm.js +3 -3
- package/dist/string-uglify.umd.js +3 -3
- package/package.json +21 -22
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
|
|
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
|
-
-
|
|
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-
|
|
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
|
|
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 {
|
|
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-
|
|
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
|
|
4
|
-
* @version 3.1
|
|
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
|
|
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
|
|
4
|
-
* @version 3.1
|
|
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
|
|
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
|
|
4
|
-
"description": "Shorten sets of strings deterministically
|
|
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
|
|
44
|
-
"
|
|
45
|
-
"
|
|
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 &&
|
|
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'
|
|
51
|
-
"
|
|
52
|
-
"lint": "
|
|
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": "
|
|
56
|
-
"prettier:format": "
|
|
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
|
-
|
|
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
|
}
|