string-uglify 1.5.0 → 2.0.3
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 +30 -0
- package/README.md +4 -0
- package/dist/string-uglify.esm.js +2 -2
- package/dist/string-uglify.umd.js +2 -2
- package/package.json +50 -42
- package/dist/string-uglify.cjs.js +0 -200
- package/dist/string-uglify.dev.umd.js +0 -258
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,36 @@
|
|
|
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
|
+
## 2.0.3 (2021-11-02)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bump TS and separate ESLint plugins away from this monorepo ([b1ebce1](https://github.com/codsen/codsen/commit/b1ebce1637d8c41c2d848fc24b0ba4058865bd5d))
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
- migrate to ES Modules ([c579dff](https://github.com/codsen/codsen/commit/c579dff3b23205e383035ca10ddcec671e35d0fe))
|
|
15
|
+
|
|
16
|
+
### BREAKING CHANGES
|
|
17
|
+
|
|
18
|
+
- programs now are in ES Modules and won't work with Common JS require()
|
|
19
|
+
|
|
20
|
+
## 2.0.1 (2021-09-13)
|
|
21
|
+
|
|
22
|
+
### Bug Fixes
|
|
23
|
+
|
|
24
|
+
- bump TS and separate ESLint plugins away from this monorepo ([2e07d42](https://github.com/codsen/codsen/commit/2e07d424222b6ffedf5fb45c83ad453627ec2904))
|
|
25
|
+
|
|
26
|
+
## 2.0.0 (2021-09-09)
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
- migrate to ES Modules ([8c9d95d](https://github.com/codsen/codsen/commit/8c9d95d5dea0b769c2f070397141918a4893d575))
|
|
31
|
+
|
|
32
|
+
### BREAKING CHANGES
|
|
33
|
+
|
|
34
|
+
- programs now are in ES Modules and won't work with Common JS require()
|
|
35
|
+
|
|
6
36
|
## 1.5.0 (2021-05-24)
|
|
7
37
|
|
|
8
38
|
### Features
|
package/README.md
CHANGED
|
@@ -26,10 +26,14 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
+
This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required:
|
|
30
|
+
|
|
29
31
|
```bash
|
|
30
32
|
npm i string-uglify
|
|
31
33
|
```
|
|
32
34
|
|
|
35
|
+
If you need a legacy version which works with `require`, use version 1.5.0
|
|
36
|
+
|
|
33
37
|
## Quick Take
|
|
34
38
|
|
|
35
39
|
```js
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-uglify
|
|
3
3
|
* @fileoverview Shorten sets of strings deterministically, to be git-friendly
|
|
4
|
-
* @version
|
|
4
|
+
* @version 2.0.3
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-uglify/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
var version$1 = "
|
|
10
|
+
var version$1 = "2.0.3";
|
|
11
11
|
|
|
12
12
|
const version = version$1;
|
|
13
13
|
function tellcp(str, idNum = 0) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-uglify
|
|
3
3
|
* @fileoverview Shorten sets of strings deterministically, to be git-friendly
|
|
4
|
-
* @version
|
|
4
|
+
* @version 2.0.3
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/string-uglify/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).stringUglify={})}(this,(function(e){"use strict";function t(e,t=0){return e.codePointAt(t)||0}function i(e){const i="abcdefghijklmnopqrstuvwxyz",s="abcdefghijklmnopqrstuvwxyz0123456789",l={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={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},c=[];if(!Array.isArray(e)||!e.length)return e;for(let o=0,u=e.length;o<u;o++){if(e.indexOf(e[o])<o){c.push(c[e.indexOf(e[o])]);continue}const u=".#".includes(e[o][0])?e[o][0]:"",h=Array.from(e[o]).reduce(((e,i)=>e+t(i)),0);if(".#".includes(e[o][0])&&e[o].length<4||!".#".includes(e[o][0])&&e[o].length<3){const t=e[o];if(!c.includes(t)){c.push(t),t.startsWith(".")&&2===t.length&&!1===l[t.slice(1)]?l[t.slice(1)]=!0:t.startsWith("#")&&2===t.length&&!1===n[t.slice(1)]?n[t.slice(1)]=!0:t.startsWith(".")||t.startsWith("#")||1!==t.length||!1!==r[t]||(r[t]=!0);continue}}let f=`${u}${i[h%i.length]}${s[h%s.length]}`;if(c.includes(f)){let i=f,l=0;const n=Array.from(e[o]).reduce(((e,i)=>e<200?e+t(i):(e+t(i))%s.length),0),r=Array.from(e[o]).map((e=>t(e))).reduce(((e,t)=>{let i=e+t;do{i=String(i).split("").reduce(((e,t)=>e+Number.parseInt(t,10)),0)}while(i>=10);return i}),0);for(;c.includes(i);)l+=1,i+=s[n*r*l%s.length];f=i}c.push(f),f.startsWith(".")&&2===f.length&&!1===l[f.slice(1)]?l[f.slice(1)]=!0:f.startsWith("#")&&2===f.length&&!1===n[f.slice(1)]?n[f.slice(1)]=!0:f.startsWith(".")||f.startsWith("#")||1!==f.length||!1!==r[f]||(r[f]=!0)}for(let e=0,t=c.length;e<t;e++)c[e].startsWith(".")?!1===l[c[e].slice(1,2)]?(l[c[e].slice(1,2)]=c[e],c[e]=c[e].slice(0,2)):l[c[e].slice(1,2)]===c[e]&&(c[e]=c[e].slice(0,2)):c[e].startsWith("#")?!1===n[c[e].slice(1,2)]?(n[c[e].slice(1,2)]=c[e],c[e]=c[e].slice(0,2)):n[c[e].slice(1,2)]===c[e]&&(c[e]=c[e].slice(0,2)):c[e].startsWith(".")||c[e].startsWith("#")||(r[c[e].slice(0,1)]?r[c[e].slice(0,1)]===c[e]&&(c[e]=c[e].slice(0,1)):(r[c[e].slice(0,1)]=c[e],c[e]=c[e].slice(0,1)));return c}e.uglifyArr=i,e.uglifyById=function(e,t){return i(e)[t]},e.version="
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).stringUglify={})}(this,(function(e){"use strict";function t(e,t=0){return e.codePointAt(t)||0}function i(e){const i="abcdefghijklmnopqrstuvwxyz",s="abcdefghijklmnopqrstuvwxyz0123456789",l={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={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},c=[];if(!Array.isArray(e)||!e.length)return e;for(let o=0,u=e.length;o<u;o++){if(e.indexOf(e[o])<o){c.push(c[e.indexOf(e[o])]);continue}const u=".#".includes(e[o][0])?e[o][0]:"",h=Array.from(e[o]).reduce(((e,i)=>e+t(i)),0);if(".#".includes(e[o][0])&&e[o].length<4||!".#".includes(e[o][0])&&e[o].length<3){const t=e[o];if(!c.includes(t)){c.push(t),t.startsWith(".")&&2===t.length&&!1===l[t.slice(1)]?l[t.slice(1)]=!0:t.startsWith("#")&&2===t.length&&!1===n[t.slice(1)]?n[t.slice(1)]=!0:t.startsWith(".")||t.startsWith("#")||1!==t.length||!1!==r[t]||(r[t]=!0);continue}}let f=`${u}${i[h%i.length]}${s[h%s.length]}`;if(c.includes(f)){let i=f,l=0;const n=Array.from(e[o]).reduce(((e,i)=>e<200?e+t(i):(e+t(i))%s.length),0),r=Array.from(e[o]).map((e=>t(e))).reduce(((e,t)=>{let i=e+t;do{i=String(i).split("").reduce(((e,t)=>e+Number.parseInt(t,10)),0)}while(i>=10);return i}),0);for(;c.includes(i);)l+=1,i+=s[n*r*l%s.length];f=i}c.push(f),f.startsWith(".")&&2===f.length&&!1===l[f.slice(1)]?l[f.slice(1)]=!0:f.startsWith("#")&&2===f.length&&!1===n[f.slice(1)]?n[f.slice(1)]=!0:f.startsWith(".")||f.startsWith("#")||1!==f.length||!1!==r[f]||(r[f]=!0)}for(let e=0,t=c.length;e<t;e++)c[e].startsWith(".")?!1===l[c[e].slice(1,2)]?(l[c[e].slice(1,2)]=c[e],c[e]=c[e].slice(0,2)):l[c[e].slice(1,2)]===c[e]&&(c[e]=c[e].slice(0,2)):c[e].startsWith("#")?!1===n[c[e].slice(1,2)]?(n[c[e].slice(1,2)]=c[e],c[e]=c[e].slice(0,2)):n[c[e].slice(1,2)]===c[e]&&(c[e]=c[e].slice(0,2)):c[e].startsWith(".")||c[e].startsWith("#")||(r[c[e].slice(0,1)]?r[c[e].slice(0,1)]===c[e]&&(c[e]=c[e].slice(0,1)):(r[c[e].slice(0,1)]=c[e],c[e]=c[e].slice(0,1)));return c}e.uglifyArr=i,e.uglifyById=function(e,t){return i(e)[t]},e.version="2.0.3",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-uglify",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Shorten sets of strings deterministically, to be git-friendly",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"class",
|
|
@@ -32,17 +32,21 @@
|
|
|
32
32
|
"email": "roy@codsen.com",
|
|
33
33
|
"url": "https://codsen.com"
|
|
34
34
|
},
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
|
|
35
|
+
"type": "module",
|
|
36
|
+
"exports": {
|
|
37
|
+
"script": "./dist/string-uglify.umd.js",
|
|
38
|
+
"default": "./dist/string-uglify.esm.js"
|
|
39
|
+
},
|
|
38
40
|
"types": "types/index.d.ts",
|
|
39
41
|
"scripts": {
|
|
40
42
|
"build": "rollup -c",
|
|
41
|
-
"esbuild": "node '../../scripts/esbuild.js'",
|
|
42
|
-
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
43
43
|
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov",
|
|
44
|
+
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
|
|
45
|
+
"clean_types": "../../scripts/cleanTypes.js",
|
|
44
46
|
"dev": "rollup -c --dev",
|
|
45
47
|
"devunittest": "npm run dev && tap --only -R 'base'",
|
|
48
|
+
"esbuild": "node '../../scripts/esbuild.js'",
|
|
49
|
+
"esbuild_dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
46
50
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
47
51
|
"lect": "lect",
|
|
48
52
|
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
|
|
@@ -50,22 +54,22 @@
|
|
|
50
54
|
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
|
|
51
55
|
"republish": "npm publish || :",
|
|
52
56
|
"tap": "tap",
|
|
53
|
-
"tsc": "tsc",
|
|
54
57
|
"pretest": "npm run build",
|
|
55
58
|
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
56
59
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"clean_types": "../../scripts/cleanTypes.js"
|
|
60
|
+
"tsc": "tsc",
|
|
61
|
+
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
60
62
|
},
|
|
61
63
|
"tap": {
|
|
64
|
+
"check-coverage": false,
|
|
62
65
|
"coverage-report": [
|
|
63
66
|
"json-summary",
|
|
64
67
|
"text"
|
|
65
68
|
],
|
|
66
|
-
"
|
|
67
|
-
"--
|
|
68
|
-
"--
|
|
69
|
+
"node-arg": [
|
|
70
|
+
"--no-warnings",
|
|
71
|
+
"--experimental-loader",
|
|
72
|
+
"@istanbuljs/esm-loader-hook"
|
|
69
73
|
],
|
|
70
74
|
"timeout": 0
|
|
71
75
|
},
|
|
@@ -81,43 +85,47 @@
|
|
|
81
85
|
}
|
|
82
86
|
},
|
|
83
87
|
"dependencies": {
|
|
84
|
-
"@babel/runtime": "^7.
|
|
88
|
+
"@babel/runtime": "^7.16.0"
|
|
85
89
|
},
|
|
86
90
|
"devDependencies": {
|
|
87
|
-
"@babel/cli": "^7.
|
|
88
|
-
"@babel/core": "^7.
|
|
89
|
-
"@babel/node": "^7.
|
|
90
|
-
"@babel/plugin-external-helpers": "^7.
|
|
91
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
|
92
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
|
93
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
|
94
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
|
95
|
-
"@babel/plugin-transform-runtime": "^7.
|
|
96
|
-
"@babel/preset-env": "^7.
|
|
97
|
-
"@babel/preset-typescript": "^7.
|
|
98
|
-
"@babel/register": "^7.
|
|
91
|
+
"@babel/cli": "^7.16.0",
|
|
92
|
+
"@babel/core": "^7.16.0",
|
|
93
|
+
"@babel/node": "^7.16.0",
|
|
94
|
+
"@babel/plugin-external-helpers": "^7.16.0",
|
|
95
|
+
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
96
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
97
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
98
|
+
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
99
|
+
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
100
|
+
"@babel/preset-env": "^7.16.0",
|
|
101
|
+
"@babel/preset-typescript": "^7.16.0",
|
|
102
|
+
"@babel/register": "^7.16.0",
|
|
103
|
+
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
99
104
|
"@rollup/plugin-babel": "^5.3.0",
|
|
100
|
-
"@rollup/plugin-commonjs": "^
|
|
105
|
+
"@rollup/plugin-commonjs": "^21.0.1",
|
|
101
106
|
"@rollup/plugin-json": "^4.1.0",
|
|
102
|
-
"@rollup/plugin-node-resolve": "^13.0.
|
|
103
|
-
"@rollup/plugin-strip": "^2.0
|
|
104
|
-
"@rollup/plugin-typescript": "^8.
|
|
105
|
-
"@types/node": "^
|
|
106
|
-
"@types/tap": "^15.0.
|
|
107
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
108
|
-
"@typescript-eslint/parser": "^
|
|
109
|
-
"core-js": "^3.
|
|
107
|
+
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
108
|
+
"@rollup/plugin-strip": "^2.1.0",
|
|
109
|
+
"@rollup/plugin-typescript": "^8.3.0",
|
|
110
|
+
"@types/node": "^16.11.6",
|
|
111
|
+
"@types/tap": "^15.0.5",
|
|
112
|
+
"@typescript-eslint/eslint-plugin": "^5.2.0",
|
|
113
|
+
"@typescript-eslint/parser": "^5.2.0",
|
|
114
|
+
"core-js": "^3.19.0",
|
|
110
115
|
"cross-env": "^7.0.3",
|
|
111
|
-
"eslint": "^
|
|
112
|
-
"lect": "^0.
|
|
113
|
-
"rollup": "^2.
|
|
116
|
+
"eslint": "^8.1.0",
|
|
117
|
+
"lect": "^0.18.3",
|
|
118
|
+
"rollup": "^2.59.0",
|
|
114
119
|
"rollup-plugin-ascii": "^0.0.3",
|
|
115
120
|
"rollup-plugin-banner": "^0.2.1",
|
|
116
121
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
117
|
-
"rollup-plugin-dts": "^
|
|
122
|
+
"rollup-plugin-dts": "^4.0.0",
|
|
118
123
|
"rollup-plugin-terser": "^7.0.2",
|
|
119
|
-
"tap": "^
|
|
120
|
-
"tslib": "^2.
|
|
121
|
-
"typescript": "^4.
|
|
124
|
+
"tap": "^15.0.10",
|
|
125
|
+
"tslib": "^2.3.1",
|
|
126
|
+
"typescript": "^4.4.4"
|
|
127
|
+
},
|
|
128
|
+
"engines": {
|
|
129
|
+
"node": ">=12"
|
|
122
130
|
}
|
|
123
131
|
}
|
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name string-uglify
|
|
3
|
-
* @fileoverview Shorten sets of strings deterministically, to be git-friendly
|
|
4
|
-
* @version 1.5.0
|
|
5
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6
|
-
* @license MIT
|
|
7
|
-
* {@link https://codsen.com/os/string-uglify/}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
'use strict';
|
|
11
|
-
|
|
12
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
13
|
-
|
|
14
|
-
var version$1 = "1.5.0";
|
|
15
|
-
|
|
16
|
-
var version = version$1;
|
|
17
|
-
function tellcp(str) {
|
|
18
|
-
var idNum = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
19
|
-
return str.codePointAt(idNum) || 0;
|
|
20
|
-
}
|
|
21
|
-
function uglifyArr(arr) {
|
|
22
|
-
var letters = "abcdefghijklmnopqrstuvwxyz";
|
|
23
|
-
var lettersAndNumbers = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
24
|
-
var singleClasses = {
|
|
25
|
-
a: false,
|
|
26
|
-
b: false,
|
|
27
|
-
c: false,
|
|
28
|
-
d: false,
|
|
29
|
-
e: false,
|
|
30
|
-
f: false,
|
|
31
|
-
g: false,
|
|
32
|
-
h: false,
|
|
33
|
-
i: false,
|
|
34
|
-
j: false,
|
|
35
|
-
k: false,
|
|
36
|
-
l: false,
|
|
37
|
-
m: false,
|
|
38
|
-
n: false,
|
|
39
|
-
o: false,
|
|
40
|
-
p: false,
|
|
41
|
-
q: false,
|
|
42
|
-
r: false,
|
|
43
|
-
s: false,
|
|
44
|
-
t: false,
|
|
45
|
-
u: false,
|
|
46
|
-
v: false,
|
|
47
|
-
w: false,
|
|
48
|
-
x: false,
|
|
49
|
-
y: false,
|
|
50
|
-
z: false
|
|
51
|
-
};
|
|
52
|
-
var singleIds = {
|
|
53
|
-
a: false,
|
|
54
|
-
b: false,
|
|
55
|
-
c: false,
|
|
56
|
-
d: false,
|
|
57
|
-
e: false,
|
|
58
|
-
f: false,
|
|
59
|
-
g: false,
|
|
60
|
-
h: false,
|
|
61
|
-
i: false,
|
|
62
|
-
j: false,
|
|
63
|
-
k: false,
|
|
64
|
-
l: false,
|
|
65
|
-
m: false,
|
|
66
|
-
n: false,
|
|
67
|
-
o: false,
|
|
68
|
-
p: false,
|
|
69
|
-
q: false,
|
|
70
|
-
r: false,
|
|
71
|
-
s: false,
|
|
72
|
-
t: false,
|
|
73
|
-
u: false,
|
|
74
|
-
v: false,
|
|
75
|
-
w: false,
|
|
76
|
-
x: false,
|
|
77
|
-
y: false,
|
|
78
|
-
z: false
|
|
79
|
-
};
|
|
80
|
-
var singleNameonly = {
|
|
81
|
-
a: false,
|
|
82
|
-
b: false,
|
|
83
|
-
c: false,
|
|
84
|
-
d: false,
|
|
85
|
-
e: false,
|
|
86
|
-
f: false,
|
|
87
|
-
g: false,
|
|
88
|
-
h: false,
|
|
89
|
-
i: false,
|
|
90
|
-
j: false,
|
|
91
|
-
k: false,
|
|
92
|
-
l: false,
|
|
93
|
-
m: false,
|
|
94
|
-
n: false,
|
|
95
|
-
o: false,
|
|
96
|
-
p: false,
|
|
97
|
-
q: false,
|
|
98
|
-
r: false,
|
|
99
|
-
s: false,
|
|
100
|
-
t: false,
|
|
101
|
-
u: false,
|
|
102
|
-
v: false,
|
|
103
|
-
w: false,
|
|
104
|
-
x: false,
|
|
105
|
-
y: false,
|
|
106
|
-
z: false
|
|
107
|
-
};
|
|
108
|
-
var res = [];
|
|
109
|
-
if (!Array.isArray(arr) || !arr.length) {
|
|
110
|
-
return arr;
|
|
111
|
-
}
|
|
112
|
-
for (var id = 0, len = arr.length; id < len; id++) {
|
|
113
|
-
if (arr.indexOf(arr[id]) < id) {
|
|
114
|
-
res.push(res[arr.indexOf(arr[id])]);
|
|
115
|
-
continue;
|
|
116
|
-
}
|
|
117
|
-
var prefix = ".#".includes(arr[id][0]) ? arr[id][0] : "";
|
|
118
|
-
var codePointSum = Array.from(arr[id]).reduce(function (acc, curr) {
|
|
119
|
-
return acc + tellcp(curr);
|
|
120
|
-
}, 0);
|
|
121
|
-
if (".#".includes(arr[id][0]) && arr[id].length < 4 || !".#".includes(arr[id][0]) && arr[id].length < 3) {
|
|
122
|
-
var val = arr[id];
|
|
123
|
-
if (!res.includes(val)) {
|
|
124
|
-
res.push(val);
|
|
125
|
-
if (val.startsWith(".") && val.length === 2 && singleClasses[val.slice(1)] === false) {
|
|
126
|
-
singleClasses[val.slice(1)] = true;
|
|
127
|
-
} else if (val.startsWith("#") && val.length === 2 && singleIds[val.slice(1)] === false) {
|
|
128
|
-
singleIds[val.slice(1)] = true;
|
|
129
|
-
} else if (!val.startsWith(".") && !val.startsWith("#") && val.length === 1 && singleNameonly[val] === false) {
|
|
130
|
-
singleNameonly[val] = true;
|
|
131
|
-
}
|
|
132
|
-
continue;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
var generated = "".concat(prefix).concat(letters[codePointSum % letters.length]).concat(lettersAndNumbers[codePointSum % lettersAndNumbers.length]);
|
|
136
|
-
if (res.includes(generated)) {
|
|
137
|
-
var soFarWeveGot = generated;
|
|
138
|
-
var counter = 0;
|
|
139
|
-
var reducedCodePointSum = Array.from(arr[id]).reduce(function (acc, curr) {
|
|
140
|
-
return acc < 200 ? acc + tellcp(curr) : (acc + tellcp(curr)) % lettersAndNumbers.length;
|
|
141
|
-
}, 0);
|
|
142
|
-
var magicNumber = Array.from(arr[id]).map(function (val) {
|
|
143
|
-
return tellcp(val);
|
|
144
|
-
}).reduce(function (accum, curr) {
|
|
145
|
-
var temp = accum + curr;
|
|
146
|
-
do {
|
|
147
|
-
temp = String(temp).split("").reduce(function (acc, curr1) {
|
|
148
|
-
return acc + Number.parseInt(curr1, 10);
|
|
149
|
-
}, 0);
|
|
150
|
-
} while (temp >= 10);
|
|
151
|
-
return temp;
|
|
152
|
-
}, 0);
|
|
153
|
-
while (res.includes(soFarWeveGot)) {
|
|
154
|
-
counter += 1;
|
|
155
|
-
soFarWeveGot += lettersAndNumbers[reducedCodePointSum * magicNumber * counter % lettersAndNumbers.length];
|
|
156
|
-
}
|
|
157
|
-
generated = soFarWeveGot;
|
|
158
|
-
}
|
|
159
|
-
res.push(generated);
|
|
160
|
-
if (generated.startsWith(".") && generated.length === 2 && singleClasses[generated.slice(1)] === false) {
|
|
161
|
-
singleClasses[generated.slice(1)] = true;
|
|
162
|
-
} else if (generated.startsWith("#") && generated.length === 2 && singleIds[generated.slice(1)] === false) {
|
|
163
|
-
singleIds[generated.slice(1)] = true;
|
|
164
|
-
} else if (!generated.startsWith(".") && !generated.startsWith("#") && generated.length === 1 && singleNameonly[generated] === false) {
|
|
165
|
-
singleNameonly[generated] = true;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
for (var i = 0, _len = res.length; i < _len; i++) {
|
|
169
|
-
if (res[i].startsWith(".")) {
|
|
170
|
-
if (singleClasses[res[i].slice(1, 2)] === false) {
|
|
171
|
-
singleClasses[res[i].slice(1, 2)] = res[i];
|
|
172
|
-
res[i] = res[i].slice(0, 2);
|
|
173
|
-
} else if (singleClasses[res[i].slice(1, 2)] === res[i]) {
|
|
174
|
-
res[i] = res[i].slice(0, 2);
|
|
175
|
-
}
|
|
176
|
-
} else if (res[i].startsWith("#")) {
|
|
177
|
-
if (singleIds[res[i].slice(1, 2)] === false) {
|
|
178
|
-
singleIds[res[i].slice(1, 2)] = res[i];
|
|
179
|
-
res[i] = res[i].slice(0, 2);
|
|
180
|
-
} else if (singleIds[res[i].slice(1, 2)] === res[i]) {
|
|
181
|
-
res[i] = res[i].slice(0, 2);
|
|
182
|
-
}
|
|
183
|
-
} else if (!res[i].startsWith(".") && !res[i].startsWith("#")) {
|
|
184
|
-
if (!singleNameonly[res[i].slice(0, 1)]) {
|
|
185
|
-
singleNameonly[res[i].slice(0, 1)] = res[i];
|
|
186
|
-
res[i] = res[i].slice(0, 1);
|
|
187
|
-
} else if (singleNameonly[res[i].slice(0, 1)] === res[i]) {
|
|
188
|
-
res[i] = res[i].slice(0, 1);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return res;
|
|
193
|
-
}
|
|
194
|
-
function uglifyById(refArr, idNum) {
|
|
195
|
-
return uglifyArr(refArr)[idNum];
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
exports.uglifyArr = uglifyArr;
|
|
199
|
-
exports.uglifyById = uglifyById;
|
|
200
|
-
exports.version = version;
|
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name string-uglify
|
|
3
|
-
* @fileoverview Shorten sets of strings deterministically, to be git-friendly
|
|
4
|
-
* @version 1.5.0
|
|
5
|
-
* @author Roy Revelt, Codsen Ltd
|
|
6
|
-
* @license MIT
|
|
7
|
-
* {@link https://codsen.com/os/string-uglify/}
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
(function (global, factory) {
|
|
11
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
12
|
-
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
13
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.stringUglify = {}));
|
|
14
|
-
}(this, (function (exports) { 'use strict';
|
|
15
|
-
|
|
16
|
-
var version$1 = "1.5.0";
|
|
17
|
-
|
|
18
|
-
const version = version$1;
|
|
19
|
-
// tells code point of a given id number
|
|
20
|
-
function tellcp(str, idNum = 0) {
|
|
21
|
-
return str.codePointAt(idNum) || 0;
|
|
22
|
-
}
|
|
23
|
-
// converts whole array into array uglified names
|
|
24
|
-
function uglifyArr(arr) {
|
|
25
|
-
const letters = "abcdefghijklmnopqrstuvwxyz";
|
|
26
|
-
const lettersAndNumbers = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
27
|
-
const singleClasses = {
|
|
28
|
-
a: false,
|
|
29
|
-
b: false,
|
|
30
|
-
c: false,
|
|
31
|
-
d: false,
|
|
32
|
-
e: false,
|
|
33
|
-
f: false,
|
|
34
|
-
g: false,
|
|
35
|
-
h: false,
|
|
36
|
-
i: false,
|
|
37
|
-
j: false,
|
|
38
|
-
k: false,
|
|
39
|
-
l: false,
|
|
40
|
-
m: false,
|
|
41
|
-
n: false,
|
|
42
|
-
o: false,
|
|
43
|
-
p: false,
|
|
44
|
-
q: false,
|
|
45
|
-
r: false,
|
|
46
|
-
s: false,
|
|
47
|
-
t: false,
|
|
48
|
-
u: false,
|
|
49
|
-
v: false,
|
|
50
|
-
w: false,
|
|
51
|
-
x: false,
|
|
52
|
-
y: false,
|
|
53
|
-
z: false,
|
|
54
|
-
};
|
|
55
|
-
const singleIds = {
|
|
56
|
-
a: false,
|
|
57
|
-
b: false,
|
|
58
|
-
c: false,
|
|
59
|
-
d: false,
|
|
60
|
-
e: false,
|
|
61
|
-
f: false,
|
|
62
|
-
g: false,
|
|
63
|
-
h: false,
|
|
64
|
-
i: false,
|
|
65
|
-
j: false,
|
|
66
|
-
k: false,
|
|
67
|
-
l: false,
|
|
68
|
-
m: false,
|
|
69
|
-
n: false,
|
|
70
|
-
o: false,
|
|
71
|
-
p: false,
|
|
72
|
-
q: false,
|
|
73
|
-
r: false,
|
|
74
|
-
s: false,
|
|
75
|
-
t: false,
|
|
76
|
-
u: false,
|
|
77
|
-
v: false,
|
|
78
|
-
w: false,
|
|
79
|
-
x: false,
|
|
80
|
-
y: false,
|
|
81
|
-
z: false,
|
|
82
|
-
};
|
|
83
|
-
const singleNameonly = {
|
|
84
|
-
a: false,
|
|
85
|
-
b: false,
|
|
86
|
-
c: false,
|
|
87
|
-
d: false,
|
|
88
|
-
e: false,
|
|
89
|
-
f: false,
|
|
90
|
-
g: false,
|
|
91
|
-
h: false,
|
|
92
|
-
i: false,
|
|
93
|
-
j: false,
|
|
94
|
-
k: false,
|
|
95
|
-
l: false,
|
|
96
|
-
m: false,
|
|
97
|
-
n: false,
|
|
98
|
-
o: false,
|
|
99
|
-
p: false,
|
|
100
|
-
q: false,
|
|
101
|
-
r: false,
|
|
102
|
-
s: false,
|
|
103
|
-
t: false,
|
|
104
|
-
u: false,
|
|
105
|
-
v: false,
|
|
106
|
-
w: false,
|
|
107
|
-
x: false,
|
|
108
|
-
y: false,
|
|
109
|
-
z: false,
|
|
110
|
-
};
|
|
111
|
-
// final array we'll assemble and eventually return
|
|
112
|
-
const res = [];
|
|
113
|
-
// quick end
|
|
114
|
-
if (!Array.isArray(arr) || !arr.length) {
|
|
115
|
-
return arr;
|
|
116
|
-
}
|
|
117
|
-
for (let id = 0, len = arr.length; id < len; id++) {
|
|
118
|
-
// insurance against duplicate reference array values
|
|
119
|
-
if (arr.indexOf(arr[id]) < id) {
|
|
120
|
-
// push again the calculated value from "res":
|
|
121
|
-
res.push(res[arr.indexOf(arr[id])]);
|
|
122
|
-
continue;
|
|
123
|
-
}
|
|
124
|
-
const prefix = `.#`.includes(arr[id][0]) ? arr[id][0] : "";
|
|
125
|
-
const codePointSum = Array.from(arr[id]).reduce((acc, curr) => acc + tellcp(curr), 0);
|
|
126
|
-
if ((`.#`.includes(arr[id][0]) && arr[id].length < 4) ||
|
|
127
|
-
(!`.#`.includes(arr[id][0]) && arr[id].length < 3)) {
|
|
128
|
-
const val = arr[id];
|
|
129
|
-
if (!res.includes(val)) {
|
|
130
|
-
res.push(val);
|
|
131
|
-
// the first candidates for single-character value are 2-char long classes:
|
|
132
|
-
if (val.startsWith(".") &&
|
|
133
|
-
val.length === 2 &&
|
|
134
|
-
singleClasses[val.slice(1)] === false) {
|
|
135
|
-
// mark the letter as used
|
|
136
|
-
singleClasses[val.slice(1)] = true;
|
|
137
|
-
}
|
|
138
|
-
else if (val.startsWith("#") &&
|
|
139
|
-
val.length === 2 &&
|
|
140
|
-
singleIds[val.slice(1)] === false) {
|
|
141
|
-
// mark the letter as used
|
|
142
|
-
singleIds[val.slice(1)] = true;
|
|
143
|
-
}
|
|
144
|
-
else if (!val.startsWith(".") &&
|
|
145
|
-
!val.startsWith("#") &&
|
|
146
|
-
val.length === 1 &&
|
|
147
|
-
singleNameonly[val] === false) {
|
|
148
|
-
// mark the letter as used
|
|
149
|
-
singleNameonly[val] = true;
|
|
150
|
-
}
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
let generated = `${prefix}${letters[codePointSum % letters.length]}${lettersAndNumbers[codePointSum % lettersAndNumbers.length]}`;
|
|
155
|
-
if (res.includes(generated)) {
|
|
156
|
-
// add more characters:
|
|
157
|
-
let soFarWeveGot = generated;
|
|
158
|
-
let counter = 0;
|
|
159
|
-
const reducedCodePointSum = Array.from(arr[id]).reduce((acc, curr) => acc < 200
|
|
160
|
-
? acc + tellcp(curr)
|
|
161
|
-
: (acc + tellcp(curr)) % lettersAndNumbers.length, 0);
|
|
162
|
-
const magicNumber = Array.from(arr[id])
|
|
163
|
-
.map((val) => tellcp(val))
|
|
164
|
-
.reduce((accum, curr) => {
|
|
165
|
-
let temp = accum + curr;
|
|
166
|
-
do {
|
|
167
|
-
temp = String(temp)
|
|
168
|
-
.split("")
|
|
169
|
-
.reduce((acc, curr1) => acc + Number.parseInt(curr1, 10), 0);
|
|
170
|
-
} while (temp >= 10);
|
|
171
|
-
return temp;
|
|
172
|
-
}, 0);
|
|
173
|
-
// console.log(
|
|
174
|
-
// `${`\u001b[${33}m${`magicNumber`}\u001b[${39}m`} = ${JSON.stringify(
|
|
175
|
-
// magicNumber,
|
|
176
|
-
// null,
|
|
177
|
-
// 4
|
|
178
|
-
// )}`
|
|
179
|
-
// );
|
|
180
|
-
while (res.includes(soFarWeveGot)) {
|
|
181
|
-
counter += 1;
|
|
182
|
-
soFarWeveGot +=
|
|
183
|
-
lettersAndNumbers[(reducedCodePointSum * magicNumber * counter) %
|
|
184
|
-
lettersAndNumbers.length];
|
|
185
|
-
}
|
|
186
|
-
generated = soFarWeveGot;
|
|
187
|
-
}
|
|
188
|
-
res.push(generated);
|
|
189
|
-
if (generated.startsWith(".") &&
|
|
190
|
-
generated.length === 2 &&
|
|
191
|
-
singleClasses[generated.slice(1)] === false) {
|
|
192
|
-
singleClasses[generated.slice(1)] = true;
|
|
193
|
-
}
|
|
194
|
-
else if (generated.startsWith("#") &&
|
|
195
|
-
generated.length === 2 &&
|
|
196
|
-
singleIds[generated.slice(1)] === false) {
|
|
197
|
-
singleIds[generated.slice(1)] = true;
|
|
198
|
-
}
|
|
199
|
-
else if (!generated.startsWith(".") &&
|
|
200
|
-
!generated.startsWith("#") &&
|
|
201
|
-
generated.length === 1 &&
|
|
202
|
-
singleNameonly[generated] === false) {
|
|
203
|
-
singleNameonly[generated] = true;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
// loop through all uglified values again and if the one letter name that
|
|
207
|
-
// matches current name's first letter (considering it might be id, class or
|
|
208
|
-
// just name), shorten that value up to that single letter.
|
|
209
|
-
for (let i = 0, len = res.length; i < len; i++) {
|
|
210
|
-
if (res[i].startsWith(".")) {
|
|
211
|
-
// if particular class name starts with a letter which hasn't been taken
|
|
212
|
-
if (singleClasses[res[i].slice(1, 2)] === false) {
|
|
213
|
-
singleClasses[res[i].slice(1, 2)] = res[i];
|
|
214
|
-
res[i] = res[i].slice(0, 2);
|
|
215
|
-
}
|
|
216
|
-
else if (singleClasses[res[i].slice(1, 2)] === res[i]) {
|
|
217
|
-
// This means, particular class name was repeated in the list and
|
|
218
|
-
// was shortened. We must shorten it to the same value.
|
|
219
|
-
res[i] = res[i].slice(0, 2);
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
else if (res[i].startsWith("#")) {
|
|
223
|
-
if (singleIds[res[i].slice(1, 2)] === false) {
|
|
224
|
-
singleIds[res[i].slice(1, 2)] = res[i];
|
|
225
|
-
res[i] = res[i].slice(0, 2);
|
|
226
|
-
}
|
|
227
|
-
else if (singleIds[res[i].slice(1, 2)] === res[i]) {
|
|
228
|
-
// This means, particular id name was repeated in the list and
|
|
229
|
-
// was shortened. We must shorten it to the same value.
|
|
230
|
-
res[i] = res[i].slice(0, 2);
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
else if (!res[i].startsWith(".") && !res[i].startsWith("#")) {
|
|
234
|
-
if (!singleNameonly[res[i].slice(0, 1)]) {
|
|
235
|
-
singleNameonly[res[i].slice(0, 1)] = res[i];
|
|
236
|
-
res[i] = res[i].slice(0, 1);
|
|
237
|
-
}
|
|
238
|
-
else if (singleNameonly[res[i].slice(0, 1)] === res[i]) {
|
|
239
|
-
// This means, particular id name was repeated in the list and
|
|
240
|
-
// was shortened. We must shorten it to the same value.
|
|
241
|
-
res[i] = res[i].slice(0, 1);
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
}
|
|
245
|
-
return res;
|
|
246
|
-
}
|
|
247
|
-
// main function - converts n-th string in a given reference array of strings
|
|
248
|
-
function uglifyById(refArr, idNum) {
|
|
249
|
-
return uglifyArr(refArr)[idNum];
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
exports.uglifyArr = uglifyArr;
|
|
253
|
-
exports.uglifyById = uglifyById;
|
|
254
|
-
exports.version = version;
|
|
255
|
-
|
|
256
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
257
|
-
|
|
258
|
-
})));
|