@karmaniverous/entity-manager 5.0.9 → 6.0.0
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/README.md +15 -438
- package/dist/cjs/_virtual/_commonjsHelpers.js +7 -0
- package/dist/cjs/_virtual/lz-string.js +5 -0
- package/dist/cjs/node_modules/@karmaniverous/entity-tools/dist/mjs/Nil.js +14 -0
- package/dist/cjs/node_modules/@karmaniverous/entity-tools/dist/mjs/defaultTranscodes.js +94 -0
- package/dist/cjs/node_modules/@karmaniverous/entity-tools/dist/mjs/sort.js +52 -0
- package/dist/cjs/node_modules/lz-string/libs/lz-string.js +517 -0
- package/dist/cjs/node_modules/radash/dist/esm/array.js +90 -0
- package/dist/cjs/node_modules/radash/dist/esm/async.js +62 -0
- package/dist/cjs/node_modules/radash/dist/esm/object.js +25 -0
- package/dist/cjs/node_modules/radash/dist/esm/typed.js +35 -0
- package/dist/cjs/node_modules/string-hash/index.js +23 -0
- package/dist/cjs/node_modules/tslib/tslib.es6.js +39 -0
- package/dist/cjs/node_modules/zod/lib/index.js +4342 -0
- package/dist/cjs/src/EntityManager.js +93 -0
- package/dist/cjs/src/ParsedConfig.js +227 -0
- package/dist/cjs/src/addKeys.js +47 -0
- package/dist/cjs/src/decodeEntityElement.js +37 -0
- package/dist/cjs/src/decodeGeneratedProperty.js +48 -0
- package/dist/cjs/src/dehydrateIndexItem.js +52 -0
- package/dist/cjs/src/dehydratePageKeyMap.js +75 -0
- package/dist/cjs/src/encodeEntityElement.js +36 -0
- package/dist/cjs/src/encodeGeneratedProperty.js +44 -0
- package/dist/cjs/src/getHashKeySpace.js +41 -0
- package/dist/cjs/src/getShardBump.js +24 -0
- package/dist/cjs/src/index.js +7 -0
- package/dist/cjs/src/query.js +104 -0
- package/dist/cjs/src/rehydrateIndexItem.js +48 -0
- package/dist/cjs/src/rehydratePageKeyMap.js +66 -0
- package/dist/cjs/src/removeKeys.js +33 -0
- package/dist/cjs/src/unwrapIndex.js +40 -0
- package/dist/cjs/src/updateItemHashKey.js +55 -0
- package/dist/cjs/src/updateItemRangeKey.js +45 -0
- package/dist/cjs/src/validateEntityGeneratedProperty.js +29 -0
- package/dist/cjs/src/validateEntityIndexToken.js +22 -0
- package/dist/cjs/src/validateEntityToken.js +17 -0
- package/dist/index.d.cts +826 -0
- package/dist/index.d.mts +826 -0
- package/dist/index.d.ts +826 -0
- package/dist/mjs/_virtual/_commonjsHelpers.js +5 -0
- package/dist/mjs/_virtual/lz-string.js +3 -0
- package/dist/mjs/node_modules/@karmaniverous/entity-tools/dist/mjs/Nil.js +12 -0
- package/dist/mjs/node_modules/@karmaniverous/entity-tools/dist/mjs/defaultTranscodes.js +92 -0
- package/dist/mjs/node_modules/@karmaniverous/entity-tools/dist/mjs/sort.js +50 -0
- package/dist/mjs/node_modules/lz-string/libs/lz-string.js +515 -0
- package/dist/mjs/node_modules/radash/dist/esm/array.js +80 -0
- package/dist/mjs/node_modules/radash/dist/esm/async.js +58 -0
- package/dist/mjs/node_modules/radash/dist/esm/object.js +22 -0
- package/dist/mjs/node_modules/radash/dist/esm/typed.js +28 -0
- package/dist/mjs/node_modules/string-hash/index.js +21 -0
- package/dist/mjs/node_modules/tslib/tslib.es6.js +36 -0
- package/dist/mjs/node_modules/zod/lib/index.js +4233 -0
- package/dist/mjs/src/EntityManager.js +91 -0
- package/dist/mjs/src/ParsedConfig.js +225 -0
- package/dist/mjs/src/addKeys.js +45 -0
- package/dist/mjs/src/decodeEntityElement.js +35 -0
- package/dist/mjs/src/decodeGeneratedProperty.js +46 -0
- package/dist/mjs/src/dehydrateIndexItem.js +50 -0
- package/dist/mjs/src/dehydratePageKeyMap.js +73 -0
- package/dist/mjs/src/encodeEntityElement.js +34 -0
- package/dist/mjs/src/encodeGeneratedProperty.js +42 -0
- package/dist/mjs/src/getHashKeySpace.js +39 -0
- package/dist/mjs/src/getShardBump.js +22 -0
- package/dist/mjs/src/index.js +1 -0
- package/dist/mjs/src/query.js +102 -0
- package/dist/mjs/src/rehydrateIndexItem.js +46 -0
- package/dist/mjs/src/rehydratePageKeyMap.js +64 -0
- package/dist/mjs/src/removeKeys.js +31 -0
- package/dist/mjs/src/unwrapIndex.js +38 -0
- package/dist/mjs/src/updateItemHashKey.js +53 -0
- package/dist/mjs/src/updateItemRangeKey.js +43 -0
- package/dist/mjs/src/validateEntityGeneratedProperty.js +27 -0
- package/dist/mjs/src/validateEntityIndexToken.js +20 -0
- package/dist/mjs/src/validateEntityToken.js +15 -0
- package/package.json +107 -58
- package/.env +0 -1
- package/.github/FUNDING.yml +0 -3
- package/dist/default/lib/EntityManager/EntityManager.js +0 -423
- package/dist/default/lib/EntityManager/PrivateEntityManager.js +0 -421
- package/dist/default/lib/index.js +0 -12
- package/dist/package.json +0 -3
- package/lib/EntityManager/EntityManager.js +0 -396
- package/lib/EntityManager/PrivateEntityManager.js +0 -436
- package/lib/index.js +0 -1
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var _commonjsHelpers = require('../../../_virtual/_commonjsHelpers.js');
|
|
4
|
+
var lzString$1 = require('../../../_virtual/lz-string.js');
|
|
5
|
+
|
|
6
|
+
lzString$1.__module.exports;
|
|
7
|
+
|
|
8
|
+
(function (module) {
|
|
9
|
+
// Copyright (c) 2013 Pieroxy <pieroxy@pieroxy.net>
|
|
10
|
+
// This work is free. You can redistribute it and/or modify it
|
|
11
|
+
// under the terms of the WTFPL, Version 2
|
|
12
|
+
// For more information see LICENSE.txt or http://www.wtfpl.net/
|
|
13
|
+
//
|
|
14
|
+
// For more information, the home page:
|
|
15
|
+
// http://pieroxy.net/blog/pages/lz-string/testing.html
|
|
16
|
+
//
|
|
17
|
+
// LZ-based compression algorithm, version 1.4.5
|
|
18
|
+
var LZString = (function() {
|
|
19
|
+
|
|
20
|
+
// private property
|
|
21
|
+
var f = String.fromCharCode;
|
|
22
|
+
var keyStrBase64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
23
|
+
var keyStrUriSafe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$";
|
|
24
|
+
var baseReverseDic = {};
|
|
25
|
+
|
|
26
|
+
function getBaseValue(alphabet, character) {
|
|
27
|
+
if (!baseReverseDic[alphabet]) {
|
|
28
|
+
baseReverseDic[alphabet] = {};
|
|
29
|
+
for (var i=0 ; i<alphabet.length ; i++) {
|
|
30
|
+
baseReverseDic[alphabet][alphabet.charAt(i)] = i;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return baseReverseDic[alphabet][character];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
var LZString = {
|
|
37
|
+
compressToBase64 : function (input) {
|
|
38
|
+
if (input == null) return "";
|
|
39
|
+
var res = LZString._compress(input, 6, function(a){return keyStrBase64.charAt(a);});
|
|
40
|
+
switch (res.length % 4) { // To produce valid Base64
|
|
41
|
+
default: // When could this happen ?
|
|
42
|
+
case 0 : return res;
|
|
43
|
+
case 1 : return res+"===";
|
|
44
|
+
case 2 : return res+"==";
|
|
45
|
+
case 3 : return res+"=";
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
decompressFromBase64 : function (input) {
|
|
50
|
+
if (input == null) return "";
|
|
51
|
+
if (input == "") return null;
|
|
52
|
+
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrBase64, input.charAt(index)); });
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
compressToUTF16 : function (input) {
|
|
56
|
+
if (input == null) return "";
|
|
57
|
+
return LZString._compress(input, 15, function(a){return f(a+32);}) + " ";
|
|
58
|
+
},
|
|
59
|
+
|
|
60
|
+
decompressFromUTF16: function (compressed) {
|
|
61
|
+
if (compressed == null) return "";
|
|
62
|
+
if (compressed == "") return null;
|
|
63
|
+
return LZString._decompress(compressed.length, 16384, function(index) { return compressed.charCodeAt(index) - 32; });
|
|
64
|
+
},
|
|
65
|
+
|
|
66
|
+
//compress into uint8array (UCS-2 big endian format)
|
|
67
|
+
compressToUint8Array: function (uncompressed) {
|
|
68
|
+
var compressed = LZString.compress(uncompressed);
|
|
69
|
+
var buf=new Uint8Array(compressed.length*2); // 2 bytes per character
|
|
70
|
+
|
|
71
|
+
for (var i=0, TotalLen=compressed.length; i<TotalLen; i++) {
|
|
72
|
+
var current_value = compressed.charCodeAt(i);
|
|
73
|
+
buf[i*2] = current_value >>> 8;
|
|
74
|
+
buf[i*2+1] = current_value % 256;
|
|
75
|
+
}
|
|
76
|
+
return buf;
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
//decompress from uint8array (UCS-2 big endian format)
|
|
80
|
+
decompressFromUint8Array:function (compressed) {
|
|
81
|
+
if (compressed===null || compressed===undefined){
|
|
82
|
+
return LZString.decompress(compressed);
|
|
83
|
+
} else {
|
|
84
|
+
var buf=new Array(compressed.length/2); // 2 bytes per character
|
|
85
|
+
for (var i=0, TotalLen=buf.length; i<TotalLen; i++) {
|
|
86
|
+
buf[i]=compressed[i*2]*256+compressed[i*2+1];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
var result = [];
|
|
90
|
+
buf.forEach(function (c) {
|
|
91
|
+
result.push(f(c));
|
|
92
|
+
});
|
|
93
|
+
return LZString.decompress(result.join(''));
|
|
94
|
+
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
//compress into a string that is already URI encoded
|
|
101
|
+
compressToEncodedURIComponent: function (input) {
|
|
102
|
+
if (input == null) return "";
|
|
103
|
+
return LZString._compress(input, 6, function(a){return keyStrUriSafe.charAt(a);});
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
//decompress from an output of compressToEncodedURIComponent
|
|
107
|
+
decompressFromEncodedURIComponent:function (input) {
|
|
108
|
+
if (input == null) return "";
|
|
109
|
+
if (input == "") return null;
|
|
110
|
+
input = input.replace(/ /g, "+");
|
|
111
|
+
return LZString._decompress(input.length, 32, function(index) { return getBaseValue(keyStrUriSafe, input.charAt(index)); });
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
compress: function (uncompressed) {
|
|
115
|
+
return LZString._compress(uncompressed, 16, function(a){return f(a);});
|
|
116
|
+
},
|
|
117
|
+
_compress: function (uncompressed, bitsPerChar, getCharFromInt) {
|
|
118
|
+
if (uncompressed == null) return "";
|
|
119
|
+
var i, value,
|
|
120
|
+
context_dictionary= {},
|
|
121
|
+
context_dictionaryToCreate= {},
|
|
122
|
+
context_c="",
|
|
123
|
+
context_wc="",
|
|
124
|
+
context_w="",
|
|
125
|
+
context_enlargeIn= 2, // Compensate for the first entry which should not count
|
|
126
|
+
context_dictSize= 3,
|
|
127
|
+
context_numBits= 2,
|
|
128
|
+
context_data=[],
|
|
129
|
+
context_data_val=0,
|
|
130
|
+
context_data_position=0,
|
|
131
|
+
ii;
|
|
132
|
+
|
|
133
|
+
for (ii = 0; ii < uncompressed.length; ii += 1) {
|
|
134
|
+
context_c = uncompressed.charAt(ii);
|
|
135
|
+
if (!Object.prototype.hasOwnProperty.call(context_dictionary,context_c)) {
|
|
136
|
+
context_dictionary[context_c] = context_dictSize++;
|
|
137
|
+
context_dictionaryToCreate[context_c] = true;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
context_wc = context_w + context_c;
|
|
141
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionary,context_wc)) {
|
|
142
|
+
context_w = context_wc;
|
|
143
|
+
} else {
|
|
144
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
|
145
|
+
if (context_w.charCodeAt(0)<256) {
|
|
146
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
147
|
+
context_data_val = (context_data_val << 1);
|
|
148
|
+
if (context_data_position == bitsPerChar-1) {
|
|
149
|
+
context_data_position = 0;
|
|
150
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
151
|
+
context_data_val = 0;
|
|
152
|
+
} else {
|
|
153
|
+
context_data_position++;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
value = context_w.charCodeAt(0);
|
|
157
|
+
for (i=0 ; i<8 ; i++) {
|
|
158
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
159
|
+
if (context_data_position == bitsPerChar-1) {
|
|
160
|
+
context_data_position = 0;
|
|
161
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
162
|
+
context_data_val = 0;
|
|
163
|
+
} else {
|
|
164
|
+
context_data_position++;
|
|
165
|
+
}
|
|
166
|
+
value = value >> 1;
|
|
167
|
+
}
|
|
168
|
+
} else {
|
|
169
|
+
value = 1;
|
|
170
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
171
|
+
context_data_val = (context_data_val << 1) | value;
|
|
172
|
+
if (context_data_position ==bitsPerChar-1) {
|
|
173
|
+
context_data_position = 0;
|
|
174
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
175
|
+
context_data_val = 0;
|
|
176
|
+
} else {
|
|
177
|
+
context_data_position++;
|
|
178
|
+
}
|
|
179
|
+
value = 0;
|
|
180
|
+
}
|
|
181
|
+
value = context_w.charCodeAt(0);
|
|
182
|
+
for (i=0 ; i<16 ; i++) {
|
|
183
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
184
|
+
if (context_data_position == bitsPerChar-1) {
|
|
185
|
+
context_data_position = 0;
|
|
186
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
187
|
+
context_data_val = 0;
|
|
188
|
+
} else {
|
|
189
|
+
context_data_position++;
|
|
190
|
+
}
|
|
191
|
+
value = value >> 1;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
context_enlargeIn--;
|
|
195
|
+
if (context_enlargeIn == 0) {
|
|
196
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
197
|
+
context_numBits++;
|
|
198
|
+
}
|
|
199
|
+
delete context_dictionaryToCreate[context_w];
|
|
200
|
+
} else {
|
|
201
|
+
value = context_dictionary[context_w];
|
|
202
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
203
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
204
|
+
if (context_data_position == bitsPerChar-1) {
|
|
205
|
+
context_data_position = 0;
|
|
206
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
207
|
+
context_data_val = 0;
|
|
208
|
+
} else {
|
|
209
|
+
context_data_position++;
|
|
210
|
+
}
|
|
211
|
+
value = value >> 1;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
}
|
|
216
|
+
context_enlargeIn--;
|
|
217
|
+
if (context_enlargeIn == 0) {
|
|
218
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
219
|
+
context_numBits++;
|
|
220
|
+
}
|
|
221
|
+
// Add wc to the dictionary.
|
|
222
|
+
context_dictionary[context_wc] = context_dictSize++;
|
|
223
|
+
context_w = String(context_c);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
// Output the code for w.
|
|
228
|
+
if (context_w !== "") {
|
|
229
|
+
if (Object.prototype.hasOwnProperty.call(context_dictionaryToCreate,context_w)) {
|
|
230
|
+
if (context_w.charCodeAt(0)<256) {
|
|
231
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
232
|
+
context_data_val = (context_data_val << 1);
|
|
233
|
+
if (context_data_position == bitsPerChar-1) {
|
|
234
|
+
context_data_position = 0;
|
|
235
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
236
|
+
context_data_val = 0;
|
|
237
|
+
} else {
|
|
238
|
+
context_data_position++;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
value = context_w.charCodeAt(0);
|
|
242
|
+
for (i=0 ; i<8 ; i++) {
|
|
243
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
244
|
+
if (context_data_position == bitsPerChar-1) {
|
|
245
|
+
context_data_position = 0;
|
|
246
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
247
|
+
context_data_val = 0;
|
|
248
|
+
} else {
|
|
249
|
+
context_data_position++;
|
|
250
|
+
}
|
|
251
|
+
value = value >> 1;
|
|
252
|
+
}
|
|
253
|
+
} else {
|
|
254
|
+
value = 1;
|
|
255
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
256
|
+
context_data_val = (context_data_val << 1) | value;
|
|
257
|
+
if (context_data_position == bitsPerChar-1) {
|
|
258
|
+
context_data_position = 0;
|
|
259
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
260
|
+
context_data_val = 0;
|
|
261
|
+
} else {
|
|
262
|
+
context_data_position++;
|
|
263
|
+
}
|
|
264
|
+
value = 0;
|
|
265
|
+
}
|
|
266
|
+
value = context_w.charCodeAt(0);
|
|
267
|
+
for (i=0 ; i<16 ; i++) {
|
|
268
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
269
|
+
if (context_data_position == bitsPerChar-1) {
|
|
270
|
+
context_data_position = 0;
|
|
271
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
272
|
+
context_data_val = 0;
|
|
273
|
+
} else {
|
|
274
|
+
context_data_position++;
|
|
275
|
+
}
|
|
276
|
+
value = value >> 1;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
context_enlargeIn--;
|
|
280
|
+
if (context_enlargeIn == 0) {
|
|
281
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
282
|
+
context_numBits++;
|
|
283
|
+
}
|
|
284
|
+
delete context_dictionaryToCreate[context_w];
|
|
285
|
+
} else {
|
|
286
|
+
value = context_dictionary[context_w];
|
|
287
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
288
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
289
|
+
if (context_data_position == bitsPerChar-1) {
|
|
290
|
+
context_data_position = 0;
|
|
291
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
292
|
+
context_data_val = 0;
|
|
293
|
+
} else {
|
|
294
|
+
context_data_position++;
|
|
295
|
+
}
|
|
296
|
+
value = value >> 1;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
}
|
|
301
|
+
context_enlargeIn--;
|
|
302
|
+
if (context_enlargeIn == 0) {
|
|
303
|
+
context_enlargeIn = Math.pow(2, context_numBits);
|
|
304
|
+
context_numBits++;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
// Mark the end of the stream
|
|
309
|
+
value = 2;
|
|
310
|
+
for (i=0 ; i<context_numBits ; i++) {
|
|
311
|
+
context_data_val = (context_data_val << 1) | (value&1);
|
|
312
|
+
if (context_data_position == bitsPerChar-1) {
|
|
313
|
+
context_data_position = 0;
|
|
314
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
315
|
+
context_data_val = 0;
|
|
316
|
+
} else {
|
|
317
|
+
context_data_position++;
|
|
318
|
+
}
|
|
319
|
+
value = value >> 1;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
// Flush the last char
|
|
323
|
+
while (true) {
|
|
324
|
+
context_data_val = (context_data_val << 1);
|
|
325
|
+
if (context_data_position == bitsPerChar-1) {
|
|
326
|
+
context_data.push(getCharFromInt(context_data_val));
|
|
327
|
+
break;
|
|
328
|
+
}
|
|
329
|
+
else context_data_position++;
|
|
330
|
+
}
|
|
331
|
+
return context_data.join('');
|
|
332
|
+
},
|
|
333
|
+
|
|
334
|
+
decompress: function (compressed) {
|
|
335
|
+
if (compressed == null) return "";
|
|
336
|
+
if (compressed == "") return null;
|
|
337
|
+
return LZString._decompress(compressed.length, 32768, function(index) { return compressed.charCodeAt(index); });
|
|
338
|
+
},
|
|
339
|
+
|
|
340
|
+
_decompress: function (length, resetValue, getNextValue) {
|
|
341
|
+
var dictionary = [],
|
|
342
|
+
enlargeIn = 4,
|
|
343
|
+
dictSize = 4,
|
|
344
|
+
numBits = 3,
|
|
345
|
+
entry = "",
|
|
346
|
+
result = [],
|
|
347
|
+
i,
|
|
348
|
+
w,
|
|
349
|
+
bits, resb, maxpower, power,
|
|
350
|
+
c,
|
|
351
|
+
data = {val:getNextValue(0), position:resetValue, index:1};
|
|
352
|
+
|
|
353
|
+
for (i = 0; i < 3; i += 1) {
|
|
354
|
+
dictionary[i] = i;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
bits = 0;
|
|
358
|
+
maxpower = Math.pow(2,2);
|
|
359
|
+
power=1;
|
|
360
|
+
while (power!=maxpower) {
|
|
361
|
+
resb = data.val & data.position;
|
|
362
|
+
data.position >>= 1;
|
|
363
|
+
if (data.position == 0) {
|
|
364
|
+
data.position = resetValue;
|
|
365
|
+
data.val = getNextValue(data.index++);
|
|
366
|
+
}
|
|
367
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
368
|
+
power <<= 1;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
switch (bits) {
|
|
372
|
+
case 0:
|
|
373
|
+
bits = 0;
|
|
374
|
+
maxpower = Math.pow(2,8);
|
|
375
|
+
power=1;
|
|
376
|
+
while (power!=maxpower) {
|
|
377
|
+
resb = data.val & data.position;
|
|
378
|
+
data.position >>= 1;
|
|
379
|
+
if (data.position == 0) {
|
|
380
|
+
data.position = resetValue;
|
|
381
|
+
data.val = getNextValue(data.index++);
|
|
382
|
+
}
|
|
383
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
384
|
+
power <<= 1;
|
|
385
|
+
}
|
|
386
|
+
c = f(bits);
|
|
387
|
+
break;
|
|
388
|
+
case 1:
|
|
389
|
+
bits = 0;
|
|
390
|
+
maxpower = Math.pow(2,16);
|
|
391
|
+
power=1;
|
|
392
|
+
while (power!=maxpower) {
|
|
393
|
+
resb = data.val & data.position;
|
|
394
|
+
data.position >>= 1;
|
|
395
|
+
if (data.position == 0) {
|
|
396
|
+
data.position = resetValue;
|
|
397
|
+
data.val = getNextValue(data.index++);
|
|
398
|
+
}
|
|
399
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
400
|
+
power <<= 1;
|
|
401
|
+
}
|
|
402
|
+
c = f(bits);
|
|
403
|
+
break;
|
|
404
|
+
case 2:
|
|
405
|
+
return "";
|
|
406
|
+
}
|
|
407
|
+
dictionary[3] = c;
|
|
408
|
+
w = c;
|
|
409
|
+
result.push(c);
|
|
410
|
+
while (true) {
|
|
411
|
+
if (data.index > length) {
|
|
412
|
+
return "";
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
bits = 0;
|
|
416
|
+
maxpower = Math.pow(2,numBits);
|
|
417
|
+
power=1;
|
|
418
|
+
while (power!=maxpower) {
|
|
419
|
+
resb = data.val & data.position;
|
|
420
|
+
data.position >>= 1;
|
|
421
|
+
if (data.position == 0) {
|
|
422
|
+
data.position = resetValue;
|
|
423
|
+
data.val = getNextValue(data.index++);
|
|
424
|
+
}
|
|
425
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
426
|
+
power <<= 1;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
switch (c = bits) {
|
|
430
|
+
case 0:
|
|
431
|
+
bits = 0;
|
|
432
|
+
maxpower = Math.pow(2,8);
|
|
433
|
+
power=1;
|
|
434
|
+
while (power!=maxpower) {
|
|
435
|
+
resb = data.val & data.position;
|
|
436
|
+
data.position >>= 1;
|
|
437
|
+
if (data.position == 0) {
|
|
438
|
+
data.position = resetValue;
|
|
439
|
+
data.val = getNextValue(data.index++);
|
|
440
|
+
}
|
|
441
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
442
|
+
power <<= 1;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
dictionary[dictSize++] = f(bits);
|
|
446
|
+
c = dictSize-1;
|
|
447
|
+
enlargeIn--;
|
|
448
|
+
break;
|
|
449
|
+
case 1:
|
|
450
|
+
bits = 0;
|
|
451
|
+
maxpower = Math.pow(2,16);
|
|
452
|
+
power=1;
|
|
453
|
+
while (power!=maxpower) {
|
|
454
|
+
resb = data.val & data.position;
|
|
455
|
+
data.position >>= 1;
|
|
456
|
+
if (data.position == 0) {
|
|
457
|
+
data.position = resetValue;
|
|
458
|
+
data.val = getNextValue(data.index++);
|
|
459
|
+
}
|
|
460
|
+
bits |= (resb>0 ? 1 : 0) * power;
|
|
461
|
+
power <<= 1;
|
|
462
|
+
}
|
|
463
|
+
dictionary[dictSize++] = f(bits);
|
|
464
|
+
c = dictSize-1;
|
|
465
|
+
enlargeIn--;
|
|
466
|
+
break;
|
|
467
|
+
case 2:
|
|
468
|
+
return result.join('');
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
if (enlargeIn == 0) {
|
|
472
|
+
enlargeIn = Math.pow(2, numBits);
|
|
473
|
+
numBits++;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
if (dictionary[c]) {
|
|
477
|
+
entry = dictionary[c];
|
|
478
|
+
} else {
|
|
479
|
+
if (c === dictSize) {
|
|
480
|
+
entry = w + w.charAt(0);
|
|
481
|
+
} else {
|
|
482
|
+
return null;
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
result.push(entry);
|
|
486
|
+
|
|
487
|
+
// Add w+entry[0] to the dictionary.
|
|
488
|
+
dictionary[dictSize++] = w + entry.charAt(0);
|
|
489
|
+
enlargeIn--;
|
|
490
|
+
|
|
491
|
+
w = entry;
|
|
492
|
+
|
|
493
|
+
if (enlargeIn == 0) {
|
|
494
|
+
enlargeIn = Math.pow(2, numBits);
|
|
495
|
+
numBits++;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
};
|
|
501
|
+
return LZString;
|
|
502
|
+
})();
|
|
503
|
+
|
|
504
|
+
if( module != null ) {
|
|
505
|
+
module.exports = LZString;
|
|
506
|
+
} else if( typeof angular !== 'undefined' && angular != null ) {
|
|
507
|
+
angular.module('LZString', [])
|
|
508
|
+
.factory('LZString', function () {
|
|
509
|
+
return LZString;
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
} (lzString$1.__module));
|
|
513
|
+
|
|
514
|
+
var lzStringExports = lzString$1.__module.exports;
|
|
515
|
+
var lzString = /*@__PURE__*/_commonjsHelpers.getDefaultExportFromCjs(lzStringExports);
|
|
516
|
+
|
|
517
|
+
module.exports = lzString;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var typed = require('./typed.js');
|
|
4
|
+
|
|
5
|
+
function zipToObject(keys, values) {
|
|
6
|
+
if (!keys || !keys.length) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
const getValue = typed.isFunction(values) ? values : typed.isArray(values) ? (_k, i) => values[i] : (_k, _i) => values;
|
|
10
|
+
return keys.reduce((acc, key, idx) => {
|
|
11
|
+
acc[key] = getValue(key, idx);
|
|
12
|
+
return acc;
|
|
13
|
+
}, {});
|
|
14
|
+
}
|
|
15
|
+
const sort = (array, getter, desc = false) => {
|
|
16
|
+
if (!array)
|
|
17
|
+
return [];
|
|
18
|
+
const asc = (a, b) => getter(a) - getter(b);
|
|
19
|
+
const dsc = (a, b) => getter(b) - getter(a);
|
|
20
|
+
return array.slice().sort(desc === true ? dsc : asc);
|
|
21
|
+
};
|
|
22
|
+
const counting = (list2, identity) => {
|
|
23
|
+
if (!list2)
|
|
24
|
+
return {};
|
|
25
|
+
return list2.reduce((acc, item) => {
|
|
26
|
+
const id = identity(item);
|
|
27
|
+
acc[id] = (acc[id] ?? 0) + 1;
|
|
28
|
+
return acc;
|
|
29
|
+
}, {});
|
|
30
|
+
};
|
|
31
|
+
const objectify = (array, getKey, getValue = (item) => item) => {
|
|
32
|
+
return array.reduce((acc, item) => {
|
|
33
|
+
acc[getKey(item)] = getValue(item);
|
|
34
|
+
return acc;
|
|
35
|
+
}, {});
|
|
36
|
+
};
|
|
37
|
+
const cluster = (list2, size = 2) => {
|
|
38
|
+
const clusterCount = Math.ceil(list2.length / size);
|
|
39
|
+
return new Array(clusterCount).fill(null).map((_c, i) => {
|
|
40
|
+
return list2.slice(i * size, i * size + size);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
const unique = (array, toKey) => {
|
|
44
|
+
const valueMap = array.reduce((acc, item) => {
|
|
45
|
+
const key = toKey ? toKey(item) : item;
|
|
46
|
+
if (acc[key])
|
|
47
|
+
return acc;
|
|
48
|
+
acc[key] = item;
|
|
49
|
+
return acc;
|
|
50
|
+
}, {});
|
|
51
|
+
return Object.values(valueMap);
|
|
52
|
+
};
|
|
53
|
+
function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
|
|
54
|
+
const mapper = typed.isFunction(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
|
|
55
|
+
const start = end ? startOrLength : 0;
|
|
56
|
+
const final = end ?? startOrLength;
|
|
57
|
+
for (let i = start; i <= final; i += step) {
|
|
58
|
+
yield mapper(i);
|
|
59
|
+
if (i + step > final)
|
|
60
|
+
break;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const list = (startOrLength, end, valueOrMapper, step) => {
|
|
64
|
+
return Array.from(range(startOrLength, end, valueOrMapper, step));
|
|
65
|
+
};
|
|
66
|
+
const fork = (list2, condition) => {
|
|
67
|
+
if (!list2)
|
|
68
|
+
return [[], []];
|
|
69
|
+
return list2.reduce(
|
|
70
|
+
(acc, item) => {
|
|
71
|
+
const [a, b] = acc;
|
|
72
|
+
if (condition(item)) {
|
|
73
|
+
return [[...a, item], b];
|
|
74
|
+
} else {
|
|
75
|
+
return [a, [...b, item]];
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
[[], []]
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
exports.cluster = cluster;
|
|
83
|
+
exports.counting = counting;
|
|
84
|
+
exports.fork = fork;
|
|
85
|
+
exports.list = list;
|
|
86
|
+
exports.objectify = objectify;
|
|
87
|
+
exports.range = range;
|
|
88
|
+
exports.sort = sort;
|
|
89
|
+
exports.unique = unique;
|
|
90
|
+
exports.zipToObject = zipToObject;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var array = require('./array.js');
|
|
4
|
+
var typed = require('./typed.js');
|
|
5
|
+
|
|
6
|
+
class AggregateError extends Error {
|
|
7
|
+
constructor(errors = []) {
|
|
8
|
+
super();
|
|
9
|
+
const name = errors.find((e) => e.name)?.name ?? "";
|
|
10
|
+
this.name = `AggregateError(${name}...)`;
|
|
11
|
+
this.message = `AggregateError with ${errors.length} errors`;
|
|
12
|
+
this.stack = errors.find((e) => e.stack)?.stack ?? this.stack;
|
|
13
|
+
this.errors = errors;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
const parallel = async (limit, array$1, func) => {
|
|
17
|
+
const work = array$1.map((item, index) => ({
|
|
18
|
+
index,
|
|
19
|
+
item
|
|
20
|
+
}));
|
|
21
|
+
const processor = async (res) => {
|
|
22
|
+
const results2 = [];
|
|
23
|
+
while (true) {
|
|
24
|
+
const next = work.pop();
|
|
25
|
+
if (!next)
|
|
26
|
+
return res(results2);
|
|
27
|
+
const [error, result] = await tryit(func)(next.item);
|
|
28
|
+
results2.push({
|
|
29
|
+
error,
|
|
30
|
+
result,
|
|
31
|
+
index: next.index
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const queues = array.list(1, limit).map(() => new Promise(processor));
|
|
36
|
+
const itemResults = await Promise.all(queues);
|
|
37
|
+
const [errors, results] = array.fork(
|
|
38
|
+
array.sort(itemResults.flat(), (r) => r.index),
|
|
39
|
+
(x) => !!x.error
|
|
40
|
+
);
|
|
41
|
+
if (errors.length > 0) {
|
|
42
|
+
throw new AggregateError(errors.map((error) => error.error));
|
|
43
|
+
}
|
|
44
|
+
return results.map((r) => r.result);
|
|
45
|
+
};
|
|
46
|
+
const tryit = (func) => {
|
|
47
|
+
return (...args) => {
|
|
48
|
+
try {
|
|
49
|
+
const result = func(...args);
|
|
50
|
+
if (typed.isPromise(result)) {
|
|
51
|
+
return result.then((value) => [void 0, value]).catch((err) => [err, void 0]);
|
|
52
|
+
}
|
|
53
|
+
return [void 0, result];
|
|
54
|
+
} catch (err) {
|
|
55
|
+
return [err, void 0];
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
exports.AggregateError = AggregateError;
|
|
61
|
+
exports.parallel = parallel;
|
|
62
|
+
exports.tryit = tryit;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const shake = (obj, filter = (x) => x === void 0) => {
|
|
4
|
+
if (!obj)
|
|
5
|
+
return {};
|
|
6
|
+
const keys2 = Object.keys(obj);
|
|
7
|
+
return keys2.reduce((acc, key) => {
|
|
8
|
+
if (filter(obj[key])) {
|
|
9
|
+
return acc;
|
|
10
|
+
} else {
|
|
11
|
+
acc[key] = obj[key];
|
|
12
|
+
return acc;
|
|
13
|
+
}
|
|
14
|
+
}, {});
|
|
15
|
+
};
|
|
16
|
+
const mapValues = (obj, mapFunc) => {
|
|
17
|
+
const keys2 = Object.keys(obj);
|
|
18
|
+
return keys2.reduce((acc, key) => {
|
|
19
|
+
acc[key] = mapFunc(obj[key], key);
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
exports.mapValues = mapValues;
|
|
25
|
+
exports.shake = shake;
|