string-uglify 2.0.3 → 2.0.7
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 +0 -20
- package/LICENSE +1 -1
- package/dist/string-uglify.esm.js +195 -163
- package/dist/string-uglify.umd.js +2 -2
- package/package.json +21 -25
package/CHANGELOG.md
CHANGED
|
@@ -3,26 +3,6 @@
|
|
|
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
6
|
## 2.0.0 (2021-09-09)
|
|
27
7
|
|
|
28
8
|
### Features
|
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010
|
|
3
|
+
Copyright (c) 2010-2021 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
|
|
@@ -1,185 +1,217 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name string-uglify
|
|
3
3
|
* @fileoverview Shorten sets of strings deterministically, to be git-friendly
|
|
4
|
-
* @version 2.0.
|
|
4
|
+
* @version 2.0.7
|
|
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 = "2.0.
|
|
10
|
+
var version$1 = "2.0.7";
|
|
11
11
|
|
|
12
12
|
const version = version$1;
|
|
13
13
|
function tellcp(str, idNum = 0) {
|
|
14
|
-
|
|
14
|
+
return str.codePointAt(idNum) || 0;
|
|
15
15
|
}
|
|
16
16
|
function uglifyArr(arr) {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
for (let id = 0, len = arr.length; id < len; id++) {
|
|
108
|
-
if (arr.indexOf(arr[id]) < id) {
|
|
109
|
-
res.push(res[arr.indexOf(arr[id])]);
|
|
110
|
-
continue;
|
|
17
|
+
const letters = "abcdefghijklmnopqrstuvwxyz";
|
|
18
|
+
const lettersAndNumbers = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
19
|
+
const singleClasses = {
|
|
20
|
+
a: false,
|
|
21
|
+
b: false,
|
|
22
|
+
c: false,
|
|
23
|
+
d: false,
|
|
24
|
+
e: false,
|
|
25
|
+
f: false,
|
|
26
|
+
g: false,
|
|
27
|
+
h: false,
|
|
28
|
+
i: false,
|
|
29
|
+
j: false,
|
|
30
|
+
k: false,
|
|
31
|
+
l: false,
|
|
32
|
+
m: false,
|
|
33
|
+
n: false,
|
|
34
|
+
o: false,
|
|
35
|
+
p: false,
|
|
36
|
+
q: false,
|
|
37
|
+
r: false,
|
|
38
|
+
s: false,
|
|
39
|
+
t: false,
|
|
40
|
+
u: false,
|
|
41
|
+
v: false,
|
|
42
|
+
w: false,
|
|
43
|
+
x: false,
|
|
44
|
+
y: false,
|
|
45
|
+
z: false,
|
|
46
|
+
};
|
|
47
|
+
const singleIds = {
|
|
48
|
+
a: false,
|
|
49
|
+
b: false,
|
|
50
|
+
c: false,
|
|
51
|
+
d: false,
|
|
52
|
+
e: false,
|
|
53
|
+
f: false,
|
|
54
|
+
g: false,
|
|
55
|
+
h: false,
|
|
56
|
+
i: false,
|
|
57
|
+
j: false,
|
|
58
|
+
k: false,
|
|
59
|
+
l: false,
|
|
60
|
+
m: false,
|
|
61
|
+
n: false,
|
|
62
|
+
o: false,
|
|
63
|
+
p: false,
|
|
64
|
+
q: false,
|
|
65
|
+
r: false,
|
|
66
|
+
s: false,
|
|
67
|
+
t: false,
|
|
68
|
+
u: false,
|
|
69
|
+
v: false,
|
|
70
|
+
w: false,
|
|
71
|
+
x: false,
|
|
72
|
+
y: false,
|
|
73
|
+
z: false,
|
|
74
|
+
};
|
|
75
|
+
const singleNameonly = {
|
|
76
|
+
a: false,
|
|
77
|
+
b: false,
|
|
78
|
+
c: false,
|
|
79
|
+
d: false,
|
|
80
|
+
e: false,
|
|
81
|
+
f: false,
|
|
82
|
+
g: false,
|
|
83
|
+
h: false,
|
|
84
|
+
i: false,
|
|
85
|
+
j: false,
|
|
86
|
+
k: false,
|
|
87
|
+
l: false,
|
|
88
|
+
m: false,
|
|
89
|
+
n: false,
|
|
90
|
+
o: false,
|
|
91
|
+
p: false,
|
|
92
|
+
q: false,
|
|
93
|
+
r: false,
|
|
94
|
+
s: false,
|
|
95
|
+
t: false,
|
|
96
|
+
u: false,
|
|
97
|
+
v: false,
|
|
98
|
+
w: false,
|
|
99
|
+
x: false,
|
|
100
|
+
y: false,
|
|
101
|
+
z: false,
|
|
102
|
+
};
|
|
103
|
+
const res = [];
|
|
104
|
+
if (!Array.isArray(arr) || !arr.length) {
|
|
105
|
+
return arr;
|
|
111
106
|
}
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
107
|
+
for (let id = 0, len = arr.length; id < len; id++) {
|
|
108
|
+
if (arr.indexOf(arr[id]) < id) {
|
|
109
|
+
res.push(res[arr.indexOf(arr[id])]);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const prefix = `.#`.includes(arr[id][0]) ? arr[id][0] : "";
|
|
113
|
+
const codePointSum = Array.from(arr[id]).reduce((acc, curr) => acc + tellcp(curr), 0);
|
|
114
|
+
if ((`.#`.includes(arr[id][0]) && arr[id].length < 4) ||
|
|
115
|
+
(!`.#`.includes(arr[id][0]) && arr[id].length < 3)) {
|
|
116
|
+
const val = arr[id];
|
|
117
|
+
if (!res.includes(val)) {
|
|
118
|
+
res.push(val);
|
|
119
|
+
if (val.startsWith(".") &&
|
|
120
|
+
val.length === 2 &&
|
|
121
|
+
singleClasses[val.slice(1)] === false) {
|
|
122
|
+
singleClasses[val.slice(1)] = true;
|
|
123
|
+
}
|
|
124
|
+
else if (val.startsWith("#") &&
|
|
125
|
+
val.length === 2 &&
|
|
126
|
+
singleIds[val.slice(1)] === false) {
|
|
127
|
+
singleIds[val.slice(1)] = true;
|
|
128
|
+
}
|
|
129
|
+
else if (!val.startsWith(".") &&
|
|
130
|
+
!val.startsWith("#") &&
|
|
131
|
+
val.length === 1 &&
|
|
132
|
+
singleNameonly[val] === false) {
|
|
133
|
+
singleNameonly[val] = true;
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
let generated = `${prefix}${letters[codePointSum % letters.length]}${lettersAndNumbers[codePointSum % lettersAndNumbers.length]}`;
|
|
139
|
+
if (res.includes(generated)) {
|
|
140
|
+
let soFarWeveGot = generated;
|
|
141
|
+
let counter = 0;
|
|
142
|
+
const reducedCodePointSum = Array.from(arr[id]).reduce((acc, curr) => acc < 200
|
|
143
|
+
? acc + tellcp(curr)
|
|
144
|
+
: (acc + tellcp(curr)) % lettersAndNumbers.length, 0);
|
|
145
|
+
const magicNumber = Array.from(arr[id])
|
|
146
|
+
.map((val) => tellcp(val))
|
|
147
|
+
.reduce((accum, curr) => {
|
|
148
|
+
let temp = accum + curr;
|
|
149
|
+
do {
|
|
150
|
+
temp = String(temp)
|
|
151
|
+
.split("")
|
|
152
|
+
.reduce((acc, curr1) => acc + Number.parseInt(curr1, 10), 0);
|
|
153
|
+
} while (temp >= 10);
|
|
154
|
+
return temp;
|
|
155
|
+
}, 0);
|
|
156
|
+
while (res.includes(soFarWeveGot)) {
|
|
157
|
+
counter += 1;
|
|
158
|
+
soFarWeveGot +=
|
|
159
|
+
lettersAndNumbers[(reducedCodePointSum * magicNumber * counter) %
|
|
160
|
+
lettersAndNumbers.length];
|
|
161
|
+
}
|
|
162
|
+
generated = soFarWeveGot;
|
|
163
|
+
}
|
|
164
|
+
res.push(generated);
|
|
165
|
+
if (generated.startsWith(".") &&
|
|
166
|
+
generated.length === 2 &&
|
|
167
|
+
singleClasses[generated.slice(1)] === false) {
|
|
168
|
+
singleClasses[generated.slice(1)] = true;
|
|
169
|
+
}
|
|
170
|
+
else if (generated.startsWith("#") &&
|
|
171
|
+
generated.length === 2 &&
|
|
172
|
+
singleIds[generated.slice(1)] === false) {
|
|
173
|
+
singleIds[generated.slice(1)] = true;
|
|
174
|
+
}
|
|
175
|
+
else if (!generated.startsWith(".") &&
|
|
176
|
+
!generated.startsWith("#") &&
|
|
177
|
+
generated.length === 1 &&
|
|
178
|
+
singleNameonly[generated] === false) {
|
|
179
|
+
singleNameonly[generated] = true;
|
|
124
180
|
}
|
|
125
|
-
continue;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
let generated = `${prefix}${letters[codePointSum % letters.length]}${lettersAndNumbers[codePointSum % lettersAndNumbers.length]}`;
|
|
129
|
-
if (res.includes(generated)) {
|
|
130
|
-
let soFarWeveGot = generated;
|
|
131
|
-
let counter = 0;
|
|
132
|
-
const reducedCodePointSum = Array.from(arr[id]).reduce((acc, curr) => acc < 200 ? acc + tellcp(curr) : (acc + tellcp(curr)) % lettersAndNumbers.length, 0);
|
|
133
|
-
const magicNumber = Array.from(arr[id]).map(val => tellcp(val)).reduce((accum, curr) => {
|
|
134
|
-
let temp = accum + curr;
|
|
135
|
-
do {
|
|
136
|
-
temp = String(temp).split("").reduce((acc, curr1) => acc + Number.parseInt(curr1, 10), 0);
|
|
137
|
-
} while (temp >= 10);
|
|
138
|
-
return temp;
|
|
139
|
-
}, 0);
|
|
140
|
-
while (res.includes(soFarWeveGot)) {
|
|
141
|
-
counter += 1;
|
|
142
|
-
soFarWeveGot += lettersAndNumbers[reducedCodePointSum * magicNumber * counter % lettersAndNumbers.length];
|
|
143
|
-
}
|
|
144
|
-
generated = soFarWeveGot;
|
|
145
|
-
}
|
|
146
|
-
res.push(generated);
|
|
147
|
-
if (generated.startsWith(".") && generated.length === 2 && singleClasses[generated.slice(1)] === false) {
|
|
148
|
-
singleClasses[generated.slice(1)] = true;
|
|
149
|
-
} else if (generated.startsWith("#") && generated.length === 2 && singleIds[generated.slice(1)] === false) {
|
|
150
|
-
singleIds[generated.slice(1)] = true;
|
|
151
|
-
} else if (!generated.startsWith(".") && !generated.startsWith("#") && generated.length === 1 && singleNameonly[generated] === false) {
|
|
152
|
-
singleNameonly[generated] = true;
|
|
153
181
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
res[i]
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
182
|
+
for (let i = 0, len = res.length; i < len; i++) {
|
|
183
|
+
if (res[i].startsWith(".")) {
|
|
184
|
+
if (singleClasses[res[i].slice(1, 2)] === false) {
|
|
185
|
+
singleClasses[res[i].slice(1, 2)] = res[i];
|
|
186
|
+
res[i] = res[i].slice(0, 2);
|
|
187
|
+
}
|
|
188
|
+
else if (singleClasses[res[i].slice(1, 2)] === res[i]) {
|
|
189
|
+
res[i] = res[i].slice(0, 2);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
else if (res[i].startsWith("#")) {
|
|
193
|
+
if (singleIds[res[i].slice(1, 2)] === false) {
|
|
194
|
+
singleIds[res[i].slice(1, 2)] = res[i];
|
|
195
|
+
res[i] = res[i].slice(0, 2);
|
|
196
|
+
}
|
|
197
|
+
else if (singleIds[res[i].slice(1, 2)] === res[i]) {
|
|
198
|
+
res[i] = res[i].slice(0, 2);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (!res[i].startsWith(".") && !res[i].startsWith("#")) {
|
|
202
|
+
if (!singleNameonly[res[i].slice(0, 1)]) {
|
|
203
|
+
singleNameonly[res[i].slice(0, 1)] = res[i];
|
|
204
|
+
res[i] = res[i].slice(0, 1);
|
|
205
|
+
}
|
|
206
|
+
else if (singleNameonly[res[i].slice(0, 1)] === res[i]) {
|
|
207
|
+
res[i] = res[i].slice(0, 1);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
177
210
|
}
|
|
178
|
-
|
|
179
|
-
return res;
|
|
211
|
+
return res;
|
|
180
212
|
}
|
|
181
213
|
function uglifyById(refArr, idNum) {
|
|
182
|
-
|
|
214
|
+
return uglifyArr(refArr)[idNum];
|
|
183
215
|
}
|
|
184
216
|
|
|
185
217
|
export { uglifyArr, uglifyById, version };
|
|
@@ -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 2.0.
|
|
4
|
+
* @version 2.0.7
|
|
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="2.0.
|
|
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.7",Object.defineProperty(e,"__esModule",{value:!0})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "string-uglify",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"description": "Shorten sets of strings deterministically, to be git-friendly",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"class",
|
|
@@ -40,13 +40,12 @@
|
|
|
40
40
|
"types": "types/index.d.ts",
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "rollup -c",
|
|
43
|
-
"
|
|
44
|
-
"
|
|
43
|
+
"build:esbuild": "node '../../scripts/esbuild.js'",
|
|
44
|
+
"build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
|
|
45
|
+
"ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
|
|
45
46
|
"clean_types": "../../scripts/cleanTypes.js",
|
|
46
47
|
"dev": "rollup -c --dev",
|
|
47
48
|
"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'",
|
|
50
49
|
"format": "npm run lect && npm run prettier && npm run lint",
|
|
51
50
|
"lect": "lect",
|
|
52
51
|
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
|
|
@@ -55,17 +54,14 @@
|
|
|
55
54
|
"republish": "npm publish || :",
|
|
56
55
|
"tap": "tap",
|
|
57
56
|
"pretest": "npm run build",
|
|
58
|
-
"test": "npm run
|
|
57
|
+
"test": "npm run test:ci && npm run perf",
|
|
58
|
+
"test:ci": "npm run unittest && npm run test:examples && npm run format",
|
|
59
59
|
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
60
60
|
"tsc": "tsc",
|
|
61
|
-
"unittest": "tap --no-only --
|
|
61
|
+
"unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
|
|
62
62
|
},
|
|
63
63
|
"tap": {
|
|
64
64
|
"check-coverage": false,
|
|
65
|
-
"coverage-report": [
|
|
66
|
-
"json-summary",
|
|
67
|
-
"text"
|
|
68
|
-
],
|
|
69
65
|
"node-arg": [
|
|
70
66
|
"--no-warnings",
|
|
71
67
|
"--experimental-loader",
|
|
@@ -85,7 +81,7 @@
|
|
|
85
81
|
}
|
|
86
82
|
},
|
|
87
83
|
"dependencies": {
|
|
88
|
-
"@babel/runtime": "^7.16.
|
|
84
|
+
"@babel/runtime": "^7.16.3"
|
|
89
85
|
},
|
|
90
86
|
"devDependencies": {
|
|
91
87
|
"@babel/cli": "^7.16.0",
|
|
@@ -96,8 +92,8 @@
|
|
|
96
92
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
97
93
|
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
98
94
|
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
99
|
-
"@babel/plugin-transform-runtime": "^7.16.
|
|
100
|
-
"@babel/preset-env": "^7.16.
|
|
95
|
+
"@babel/plugin-transform-runtime": "^7.16.4",
|
|
96
|
+
"@babel/preset-env": "^7.16.4",
|
|
101
97
|
"@babel/preset-typescript": "^7.16.0",
|
|
102
98
|
"@babel/register": "^7.16.0",
|
|
103
99
|
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
@@ -107,25 +103,25 @@
|
|
|
107
103
|
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
108
104
|
"@rollup/plugin-strip": "^2.1.0",
|
|
109
105
|
"@rollup/plugin-typescript": "^8.3.0",
|
|
110
|
-
"@types/node": "^16.11.
|
|
106
|
+
"@types/node": "^16.11.10",
|
|
111
107
|
"@types/tap": "^15.0.5",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
113
|
-
"@typescript-eslint/parser": "^5.
|
|
114
|
-
"core-js": "^3.19.
|
|
108
|
+
"@typescript-eslint/eslint-plugin": "^5.5.0",
|
|
109
|
+
"@typescript-eslint/parser": "^5.5.0",
|
|
110
|
+
"core-js": "^3.19.2",
|
|
115
111
|
"cross-env": "^7.0.3",
|
|
116
|
-
"eslint": "^8.
|
|
117
|
-
"lect": "^0.18.
|
|
118
|
-
"rollup": "^2.
|
|
112
|
+
"eslint": "^8.3.0",
|
|
113
|
+
"lect": "^0.18.7",
|
|
114
|
+
"rollup": "^2.60.1",
|
|
119
115
|
"rollup-plugin-ascii": "^0.0.3",
|
|
120
116
|
"rollup-plugin-banner": "^0.2.1",
|
|
121
117
|
"rollup-plugin-cleanup": "^3.2.1",
|
|
122
|
-
"rollup-plugin-dts": "^4.0.
|
|
118
|
+
"rollup-plugin-dts": "^4.0.1",
|
|
123
119
|
"rollup-plugin-terser": "^7.0.2",
|
|
124
|
-
"tap": "^15.
|
|
120
|
+
"tap": "^15.1.5",
|
|
125
121
|
"tslib": "^2.3.1",
|
|
126
|
-
"typescript": "^4.
|
|
122
|
+
"typescript": "^4.5.2"
|
|
127
123
|
},
|
|
128
124
|
"engines": {
|
|
129
|
-
"node": ">=
|
|
125
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
130
126
|
}
|
|
131
127
|
}
|