strc 2.0.0 → 2.0.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/index.js +32 -29
- package/index.min.js +9 -7
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -25,13 +25,15 @@ SOFTWARE.
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/*
|
|
28
|
-
|
|
29
|
-
__ / / __/ __/ ___/
|
|
30
|
-
|
|
31
|
-
\___/___/___/\___/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
__ _______________ __
|
|
29
|
+
\ \ __ / / __/ __/ ___/ / /
|
|
30
|
+
> > / // /\ \_\ \/ /__ < <
|
|
31
|
+
/_/ \___/___/___/\___/ \_\
|
|
32
|
+
|
|
33
|
+
JavaScript String Compressor
|
|
34
|
+
https://jssc.js.org/
|
|
35
|
+
|
|
36
|
+
npm i strc
|
|
35
37
|
|
|
36
38
|
*/
|
|
37
39
|
|
|
@@ -477,21 +479,21 @@ SOFTWARE.
|
|
|
477
479
|
return binToDec(sixteenBits);
|
|
478
480
|
}
|
|
479
481
|
}
|
|
480
|
-
/*
|
|
481
|
-
/*
|
|
482
|
-
/* 00: No
|
|
483
|
-
/* 01: CharCode
|
|
484
|
-
/* 02:
|
|
485
|
-
/* 03:
|
|
486
|
-
/* 04:
|
|
487
|
-
/* 05:
|
|
488
|
-
/* 06:
|
|
489
|
-
/* 07: Frequency
|
|
490
|
-
/* 08: URL
|
|
491
|
-
/* 09:
|
|
492
|
-
/* 10:
|
|
493
|
-
/* 11 - 30:
|
|
494
|
-
/* 31:
|
|
482
|
+
/* Code 1 usage table */
|
|
483
|
+
/* ------------------------------------ */
|
|
484
|
+
/* 00: No Compression */
|
|
485
|
+
/* 01: Two-Digit CharCode Concatenation */
|
|
486
|
+
/* 02: Two-Byte CharCode Concatenation */
|
|
487
|
+
/* 03: Decimal Integer Packing */
|
|
488
|
+
/* 04: Alphabet Encoding */
|
|
489
|
+
/* 05: Character Encoding */
|
|
490
|
+
/* 06: Inline Integer Encoding */
|
|
491
|
+
/* 07: Frequency Map */
|
|
492
|
+
/* 08: URL */
|
|
493
|
+
/* 09: Segmentation */
|
|
494
|
+
/* 10: String Repetition */
|
|
495
|
+
/* 11 - 30: Reserved */
|
|
496
|
+
/* 31: Recursive Compression */
|
|
495
497
|
|
|
496
498
|
const SEQUENCE_MARKER = '\uDBFF'; /* Private Use Area */
|
|
497
499
|
|
|
@@ -971,7 +973,7 @@ SOFTWARE.
|
|
|
971
973
|
const candidates = [];
|
|
972
974
|
|
|
973
975
|
if (/^\d+$/.test(str)) {
|
|
974
|
-
/*
|
|
976
|
+
/* Inline Integer Encoding */
|
|
975
977
|
candidates.push(async () => {
|
|
976
978
|
const out = await (async () => {
|
|
977
979
|
const num = parseInt(str);
|
|
@@ -986,7 +988,7 @@ SOFTWARE.
|
|
|
986
988
|
if (!(await validate(out))) return null;
|
|
987
989
|
return out;
|
|
988
990
|
});
|
|
989
|
-
/*
|
|
991
|
+
/* Decimal Integer Packing */
|
|
990
992
|
candidates.push(async () => {
|
|
991
993
|
const convertNums = {
|
|
992
994
|
'A': 10,
|
|
@@ -1026,6 +1028,7 @@ SOFTWARE.
|
|
|
1026
1028
|
});
|
|
1027
1029
|
}
|
|
1028
1030
|
|
|
1031
|
+
/* Two-Digit CharCode Concatenation */
|
|
1029
1032
|
candidates.push(async () => {
|
|
1030
1033
|
const strdata = stringCodes(str);
|
|
1031
1034
|
if (!(strdata.max === 2 && strdata.min === 2)) return null;
|
|
@@ -1068,7 +1071,7 @@ SOFTWARE.
|
|
|
1068
1071
|
return res;
|
|
1069
1072
|
});
|
|
1070
1073
|
|
|
1071
|
-
/*
|
|
1074
|
+
/* Two-Byte CharCode Concatenation */
|
|
1072
1075
|
candidates.push(async () => {
|
|
1073
1076
|
const strdata = stringCodes(str);
|
|
1074
1077
|
if (strdata.maxCharCode >= 256) return null;
|
|
@@ -1086,7 +1089,7 @@ SOFTWARE.
|
|
|
1086
1089
|
return res;
|
|
1087
1090
|
});
|
|
1088
1091
|
|
|
1089
|
-
/* Character
|
|
1092
|
+
/* Character Encoding */
|
|
1090
1093
|
candidates.push(async () => {
|
|
1091
1094
|
const characterEncodings = new _JSSC.use();
|
|
1092
1095
|
const stringArray = str.split('');
|
|
@@ -1136,7 +1139,7 @@ SOFTWARE.
|
|
|
1136
1139
|
return null;
|
|
1137
1140
|
});
|
|
1138
1141
|
|
|
1139
|
-
/*
|
|
1142
|
+
/* Alphabet Encoding */
|
|
1140
1143
|
candidates.push(async () => {
|
|
1141
1144
|
const uniq = [...new Set(str.split('').map(c => c.charCodeAt(0)))];
|
|
1142
1145
|
if (uniq.length >= 16) return null;
|
|
@@ -1165,7 +1168,7 @@ SOFTWARE.
|
|
|
1165
1168
|
return res;
|
|
1166
1169
|
});
|
|
1167
1170
|
|
|
1168
|
-
/* Frequency
|
|
1171
|
+
/* Frequency Map */
|
|
1169
1172
|
candidates.push(async () => {
|
|
1170
1173
|
for (const splitter of freqMapSplitters) {
|
|
1171
1174
|
const test = freqMap.test(str, splitter);
|
|
@@ -1297,7 +1300,7 @@ SOFTWARE.
|
|
|
1297
1300
|
return res;
|
|
1298
1301
|
});
|
|
1299
1302
|
|
|
1300
|
-
/*
|
|
1303
|
+
/* String Repetition */
|
|
1301
1304
|
const rcheck = str.match(/^(.{1,7}?)(?:\1)+$/);
|
|
1302
1305
|
if (rcheck) candidates.push(async () => {
|
|
1303
1306
|
const main = rcheck[1];
|
package/index.min.js
CHANGED
|
@@ -25,13 +25,15 @@ SOFTWARE.
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
/*
|
|
28
|
-
|
|
29
|
-
__ / / __/ __/ ___/
|
|
30
|
-
|
|
31
|
-
\___/___/___/\___/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
__ _______________ __
|
|
29
|
+
\ \ __ / / __/ __/ ___/ / /
|
|
30
|
+
> > / // /\ \_\ \/ /__ < <
|
|
31
|
+
/_/ \___/___/___/\___/ \_\
|
|
32
|
+
|
|
33
|
+
JavaScript String Compressor
|
|
34
|
+
https://jssc.js.org/
|
|
35
|
+
|
|
36
|
+
npm i strc
|
|
35
37
|
|
|
36
38
|
*/
|
|
37
39
|
|