lib0 0.2.38 → 0.2.42
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 +6 -4
- package/broadcastchannel.js +1 -1
- package/component.d.ts.map +1 -1
- package/decoding.d.ts +0 -12
- package/decoding.d.ts.map +1 -1
- package/decoding.js +8 -8
- package/diff.d.ts.map +1 -1
- package/dist/{broadcastchannel-cb74c2ae.cjs → broadcastchannel-8a61b21a.cjs} +3 -3
- package/dist/broadcastchannel-8a61b21a.cjs.map +1 -0
- package/dist/broadcastchannel.cjs +3 -3
- package/dist/{buffer-097552c3.cjs → buffer-ac2cdedf.cjs} +15 -14
- package/dist/buffer-ac2cdedf.cjs.map +1 -0
- package/dist/buffer.cjs +2 -2
- package/dist/component.d.ts.map +1 -1
- package/dist/decoding.cjs +2 -2
- package/dist/decoding.d.ts +0 -12
- package/dist/decoding.d.ts.map +1 -1
- package/dist/diff.d.ts.map +1 -1
- package/dist/encoding.cjs +2 -2
- package/dist/encoding.d.ts.map +1 -1
- package/dist/{environment-bf1f625d.cjs → environment-7e2ffaea.cjs} +1 -1
- package/dist/{environment-bf1f625d.cjs.map → environment-7e2ffaea.cjs.map} +1 -1
- package/dist/environment.cjs +1 -1
- package/dist/index.cjs +5 -5
- package/dist/{logging-4941d274.cjs → logging-7cc36806.cjs} +2 -2
- package/dist/{logging-4941d274.cjs.map → logging-7cc36806.cjs.map} +1 -1
- package/dist/logging.cjs +2 -2
- package/dist/observable.d.ts.map +1 -1
- package/dist/pair.d.ts.map +1 -1
- package/dist/{prng-70808343.cjs → prng-695120cc.cjs} +2 -2
- package/dist/{prng-70808343.cjs.map → prng-695120cc.cjs.map} +1 -1
- package/dist/prng.cjs +3 -3
- package/dist/storage.cjs +16 -4
- package/dist/storage.cjs.map +1 -1
- package/dist/storage.d.ts +5 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.test.d.ts +3 -0
- package/dist/storage.test.d.ts.map +1 -0
- package/dist/test.cjs +234 -200
- package/dist/test.cjs.map +1 -1
- package/dist/test.js +235 -201
- package/dist/test.js.map +1 -1
- package/dist/testing.cjs +9 -9
- package/dist/testing.cjs.map +1 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.test.d.ts +1 -1
- package/dist/tree.d.ts +1 -1
- package/dist/tree.d.ts.map +1 -1
- package/encoding.d.ts.map +1 -1
- package/encoding.js +5 -4
- package/observable.d.ts.map +1 -1
- package/package.json +10 -9
- package/pair.d.ts.map +1 -1
- package/storage.d.ts +5 -0
- package/storage.d.ts.map +1 -1
- package/storage.js +15 -4
- package/storage.test.d.ts +3 -0
- package/storage.test.d.ts.map +1 -0
- package/test.js +3 -1
- package/testing.d.ts +1 -1
- package/testing.js +4 -4
- package/testing.test.d.ts +1 -1
- package/tree.d.ts +1 -1
- package/tree.d.ts.map +1 -1
- package/dist/broadcastchannel-cb74c2ae.cjs.map +0 -1
- package/dist/buffer-097552c3.cjs.map +0 -1
package/dist/test.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
*
|
|
16
16
|
* @function
|
|
17
17
|
*/
|
|
18
|
-
const create = () => new Map();
|
|
18
|
+
const create$7 = () => new Map();
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Copy a Map object into a fresh Map object.
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
* @return {Map<X,Y>}
|
|
27
27
|
*/
|
|
28
28
|
const copy = m => {
|
|
29
|
-
const r = create();
|
|
29
|
+
const r = create$7();
|
|
30
30
|
m.forEach((v, k) => { r.set(k, v); });
|
|
31
31
|
return r
|
|
32
32
|
};
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
* @param {function(V,K):R} f
|
|
66
66
|
* @return {Array<R>}
|
|
67
67
|
*/
|
|
68
|
-
const map = (m, f) => {
|
|
68
|
+
const map$3 = (m, f) => {
|
|
69
69
|
const res = [];
|
|
70
70
|
for (const [key, value] of m) {
|
|
71
71
|
res.push(f(value, key));
|
|
@@ -202,7 +202,7 @@
|
|
|
202
202
|
/* istanbul ignore next */
|
|
203
203
|
const undefinedToNull = v => v === undefined ? null : v;
|
|
204
204
|
|
|
205
|
-
/* global localStorage */
|
|
205
|
+
/* global localStorage, addEventListener */
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
208
|
* Isomorphic variable storage.
|
|
@@ -220,10 +220,10 @@
|
|
|
220
220
|
|
|
221
221
|
/**
|
|
222
222
|
* @param {string} key
|
|
223
|
-
* @param {any}
|
|
223
|
+
* @param {any} newValue
|
|
224
224
|
*/
|
|
225
|
-
setItem (key,
|
|
226
|
-
this.map.set(key,
|
|
225
|
+
setItem (key, newValue) {
|
|
226
|
+
this.map.set(key, newValue);
|
|
227
227
|
}
|
|
228
228
|
|
|
229
229
|
/**
|
|
@@ -239,12 +239,14 @@
|
|
|
239
239
|
* @type {any}
|
|
240
240
|
*/
|
|
241
241
|
let _localStorage = new VarStoragePolyfill();
|
|
242
|
+
let usePolyfill = true;
|
|
242
243
|
|
|
243
244
|
try {
|
|
244
245
|
// if the same-origin rule is violated, accessing localStorage might thrown an error
|
|
245
246
|
/* istanbul ignore next */
|
|
246
247
|
if (typeof localStorage !== 'undefined') {
|
|
247
248
|
_localStorage = localStorage;
|
|
249
|
+
usePolyfill = false;
|
|
248
250
|
}
|
|
249
251
|
} catch (e) { }
|
|
250
252
|
|
|
@@ -254,6 +256,15 @@
|
|
|
254
256
|
*/
|
|
255
257
|
const varStorage = _localStorage;
|
|
256
258
|
|
|
259
|
+
/* istanbul ignore next */
|
|
260
|
+
/**
|
|
261
|
+
* A polyfill for `addEventListener('storage', event => {..})` that does nothing if the polyfill is being used.
|
|
262
|
+
*
|
|
263
|
+
* @param {function({ key: string, newValue: string, oldValue: string }): void} eventHandler
|
|
264
|
+
* @function
|
|
265
|
+
*/
|
|
266
|
+
const onChange = eventHandler => usePolyfill || addEventListener('storage', /** @type {any} */ (eventHandler));
|
|
267
|
+
|
|
257
268
|
/**
|
|
258
269
|
* Isomorphic module to work access the environment (query params, env variables).
|
|
259
270
|
*
|
|
@@ -277,7 +288,7 @@
|
|
|
277
288
|
const computeParams = () => {
|
|
278
289
|
if (params === undefined) {
|
|
279
290
|
if (isNode) {
|
|
280
|
-
params = create();
|
|
291
|
+
params = create$7();
|
|
281
292
|
const pargs = process.argv;
|
|
282
293
|
let currParamName = null;
|
|
283
294
|
/* istanbul ignore next */
|
|
@@ -300,7 +311,7 @@
|
|
|
300
311
|
}
|
|
301
312
|
// in ReactNative for example this would not be true (unless connected to the Remote Debugger)
|
|
302
313
|
} else if (typeof location === 'object') {
|
|
303
|
-
params = create()
|
|
314
|
+
params = create$7()
|
|
304
315
|
// eslint-disable-next-line no-undef
|
|
305
316
|
;(location.search || '?').slice(1).split('&').forEach(kv => {
|
|
306
317
|
if (kv.length !== 0) {
|
|
@@ -310,7 +321,7 @@
|
|
|
310
321
|
}
|
|
311
322
|
});
|
|
312
323
|
} else {
|
|
313
|
-
params = create();
|
|
324
|
+
params = create$7();
|
|
314
325
|
}
|
|
315
326
|
}
|
|
316
327
|
return params
|
|
@@ -360,7 +371,7 @@
|
|
|
360
371
|
*
|
|
361
372
|
* @return {Symbol}
|
|
362
373
|
*/
|
|
363
|
-
const create$
|
|
374
|
+
const create$6 = Symbol;
|
|
364
375
|
|
|
365
376
|
/**
|
|
366
377
|
* Working with value pairs.
|
|
@@ -388,7 +399,7 @@
|
|
|
388
399
|
* @param {R} right
|
|
389
400
|
* @return {Pair<L,R>}
|
|
390
401
|
*/
|
|
391
|
-
const create$
|
|
402
|
+
const create$5 = (left, right) => new Pair(left, right);
|
|
392
403
|
|
|
393
404
|
/**
|
|
394
405
|
* @template L,R
|
|
@@ -403,7 +414,7 @@
|
|
|
403
414
|
* @param {Array<Pair<L,R>>} arr
|
|
404
415
|
* @param {function(L, R):any} f
|
|
405
416
|
*/
|
|
406
|
-
const forEach = (arr, f) => arr.forEach(p => f(p.left, p.right));
|
|
417
|
+
const forEach$1 = (arr, f) => arr.forEach(p => f(p.left, p.right));
|
|
407
418
|
|
|
408
419
|
/**
|
|
409
420
|
* @template L,R,X
|
|
@@ -411,7 +422,7 @@
|
|
|
411
422
|
* @param {function(L, R):X} f
|
|
412
423
|
* @return {Array<X>}
|
|
413
424
|
*/
|
|
414
|
-
const map$
|
|
425
|
+
const map$2 = (arr, f) => arr.map(p => f(p.left, p.right));
|
|
415
426
|
|
|
416
427
|
/* eslint-env browser */
|
|
417
428
|
|
|
@@ -451,7 +462,7 @@
|
|
|
451
462
|
*/
|
|
452
463
|
/* istanbul ignore next */
|
|
453
464
|
const setAttributes = (el, attrs) => {
|
|
454
|
-
forEach(attrs, (key, value) => {
|
|
465
|
+
forEach$1(attrs, (key, value) => {
|
|
455
466
|
if (value === false) {
|
|
456
467
|
el.removeAttribute(key);
|
|
457
468
|
} else if (value === true) {
|
|
@@ -530,7 +541,7 @@
|
|
|
530
541
|
* @return {string}
|
|
531
542
|
*/
|
|
532
543
|
/* istanbul ignore next */
|
|
533
|
-
const mapToStyleString = m => map(m, (value, key) => `${key}:${value};`).join('');
|
|
544
|
+
const mapToStyleString = m => map$3(m, (value, key) => `${key}:${value};`).join('');
|
|
534
545
|
|
|
535
546
|
/**
|
|
536
547
|
* @param {Node} parent
|
|
@@ -565,21 +576,21 @@
|
|
|
565
576
|
/**
|
|
566
577
|
* @type {Array<function>}
|
|
567
578
|
*/
|
|
568
|
-
let queue = [];
|
|
579
|
+
let queue$1 = [];
|
|
569
580
|
|
|
570
581
|
const _runQueue = () => {
|
|
571
|
-
for (let i = 0; i < queue.length; i++) {
|
|
572
|
-
queue[i]();
|
|
582
|
+
for (let i = 0; i < queue$1.length; i++) {
|
|
583
|
+
queue$1[i]();
|
|
573
584
|
}
|
|
574
|
-
queue = [];
|
|
585
|
+
queue$1 = [];
|
|
575
586
|
};
|
|
576
587
|
|
|
577
588
|
/**
|
|
578
589
|
* @param {function():void} f
|
|
579
590
|
*/
|
|
580
|
-
const enqueue = f => {
|
|
581
|
-
queue.push(f);
|
|
582
|
-
if (queue.length === 1) {
|
|
591
|
+
const enqueue$1 = f => {
|
|
592
|
+
queue$1.push(f);
|
|
593
|
+
if (queue$1.length === 1) {
|
|
583
594
|
setTimeout(_runQueue, 0);
|
|
584
595
|
}
|
|
585
596
|
};
|
|
@@ -666,7 +677,7 @@
|
|
|
666
677
|
* @param {number} b
|
|
667
678
|
* @return {number} The sum of a and b
|
|
668
679
|
*/
|
|
669
|
-
const add = (a, b) => a + b;
|
|
680
|
+
const add$1 = (a, b) => a + b;
|
|
670
681
|
|
|
671
682
|
/**
|
|
672
683
|
* @function
|
|
@@ -684,7 +695,7 @@
|
|
|
684
695
|
*/
|
|
685
696
|
const max = (a, b) => a > b ? a : b;
|
|
686
697
|
|
|
687
|
-
const isNaN = Number.isNaN;
|
|
698
|
+
const isNaN$1 = Number.isNaN;
|
|
688
699
|
/**
|
|
689
700
|
* Base 10 exponential function. Returns the value of 10 raised to the power of pow.
|
|
690
701
|
*
|
|
@@ -817,7 +828,7 @@
|
|
|
817
828
|
* @param {function(ITEM, number, Array<ITEM>):boolean} f
|
|
818
829
|
* @return {boolean}
|
|
819
830
|
*/
|
|
820
|
-
const every = (arr, f) => arr.every(f);
|
|
831
|
+
const every$1 = (arr, f) => arr.every(f);
|
|
821
832
|
|
|
822
833
|
/**
|
|
823
834
|
* @template ELEM
|
|
@@ -826,7 +837,7 @@
|
|
|
826
837
|
* @param {Array<ELEM>} b
|
|
827
838
|
* @return {boolean}
|
|
828
839
|
*/
|
|
829
|
-
const equalFlat = (a, b) => a.length === b.length && every(a, (item, index) => item === b[index]);
|
|
840
|
+
const equalFlat$1 = (a, b) => a.length === b.length && every$1(a, (item, index) => item === b[index]);
|
|
830
841
|
|
|
831
842
|
/**
|
|
832
843
|
* @template ELEM
|
|
@@ -844,7 +855,7 @@
|
|
|
844
855
|
/**
|
|
845
856
|
* @return {Object<string,any>} obj
|
|
846
857
|
*/
|
|
847
|
-
const create$
|
|
858
|
+
const create$4 = () => Object.create(null);
|
|
848
859
|
|
|
849
860
|
/**
|
|
850
861
|
* Object.assign
|
|
@@ -860,7 +871,7 @@
|
|
|
860
871
|
* @param {Object<string,any>} obj
|
|
861
872
|
* @param {function(any,string):any} f
|
|
862
873
|
*/
|
|
863
|
-
const forEach
|
|
874
|
+
const forEach = (obj, f) => {
|
|
864
875
|
for (const key in obj) {
|
|
865
876
|
f(obj[key], key);
|
|
866
877
|
}
|
|
@@ -872,7 +883,7 @@
|
|
|
872
883
|
* @param {function(any,string):R} f
|
|
873
884
|
* @return {Array<R>}
|
|
874
885
|
*/
|
|
875
|
-
const map$
|
|
886
|
+
const map$1 = (obj, f) => {
|
|
876
887
|
const results = [];
|
|
877
888
|
for (const key in obj) {
|
|
878
889
|
results.push(f(obj[key], key));
|
|
@@ -884,7 +895,7 @@
|
|
|
884
895
|
* @param {Object<string,any>} obj
|
|
885
896
|
* @return {number}
|
|
886
897
|
*/
|
|
887
|
-
const length = obj => keys(obj).length;
|
|
898
|
+
const length$1 = obj => keys(obj).length;
|
|
888
899
|
|
|
889
900
|
/**
|
|
890
901
|
* @param {Object<string,any>} obj
|
|
@@ -905,7 +916,7 @@
|
|
|
905
916
|
* @param {function(any,string):boolean} f
|
|
906
917
|
* @return {boolean}
|
|
907
918
|
*/
|
|
908
|
-
const every
|
|
919
|
+
const every = (obj, f) => {
|
|
909
920
|
for (const key in obj) {
|
|
910
921
|
if (!f(obj[key], key)) {
|
|
911
922
|
return false
|
|
@@ -928,7 +939,7 @@
|
|
|
928
939
|
* @param {Object<string,any>} b
|
|
929
940
|
* @return {boolean}
|
|
930
941
|
*/
|
|
931
|
-
const equalFlat
|
|
942
|
+
const equalFlat = (a, b) => a === b || (length$1(a) === length$1(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && b[key] === val));
|
|
932
943
|
|
|
933
944
|
/**
|
|
934
945
|
* Common functions and function call helpers.
|
|
@@ -952,7 +963,7 @@
|
|
|
952
963
|
* @param {Array<T>|object} b
|
|
953
964
|
* @return {boolean}
|
|
954
965
|
*/
|
|
955
|
-
const equalityFlat = (a, b) => a === b || (a != null && b != null && a.constructor === b.constructor && ((a instanceof Array && equalFlat(a, /** @type {Array<T>} */ (b))) || (typeof a === 'object' && equalFlat
|
|
966
|
+
const equalityFlat = (a, b) => a === b || (a != null && b != null && a.constructor === b.constructor && ((a instanceof Array && equalFlat$1(a, /** @type {Array<T>} */ (b))) || (typeof a === 'object' && equalFlat(a, b))));
|
|
956
967
|
|
|
957
968
|
/**
|
|
958
969
|
* @param {any} a
|
|
@@ -1008,7 +1019,7 @@
|
|
|
1008
1019
|
break
|
|
1009
1020
|
}
|
|
1010
1021
|
case Object:
|
|
1011
|
-
if (length(a) !== length(b)) {
|
|
1022
|
+
if (length$1(a) !== length$1(b)) {
|
|
1012
1023
|
return false
|
|
1013
1024
|
}
|
|
1014
1025
|
for (const key in a) {
|
|
@@ -1039,29 +1050,29 @@
|
|
|
1039
1050
|
* @module logging
|
|
1040
1051
|
*/
|
|
1041
1052
|
|
|
1042
|
-
const BOLD = create$
|
|
1043
|
-
const UNBOLD = create$
|
|
1044
|
-
const BLUE = create$
|
|
1045
|
-
const GREY = create$
|
|
1046
|
-
const GREEN = create$
|
|
1047
|
-
const RED = create$
|
|
1048
|
-
const PURPLE = create$
|
|
1049
|
-
const ORANGE = create$
|
|
1050
|
-
const UNCOLOR = create$
|
|
1053
|
+
const BOLD = create$6();
|
|
1054
|
+
const UNBOLD = create$6();
|
|
1055
|
+
const BLUE = create$6();
|
|
1056
|
+
const GREY = create$6();
|
|
1057
|
+
const GREEN = create$6();
|
|
1058
|
+
const RED = create$6();
|
|
1059
|
+
const PURPLE = create$6();
|
|
1060
|
+
const ORANGE = create$6();
|
|
1061
|
+
const UNCOLOR = create$6();
|
|
1051
1062
|
|
|
1052
1063
|
/**
|
|
1053
1064
|
* @type {Object<Symbol,pair.Pair<string,string>>}
|
|
1054
1065
|
*/
|
|
1055
1066
|
const _browserStyleMap = {
|
|
1056
|
-
[BOLD]: create$
|
|
1057
|
-
[UNBOLD]: create$
|
|
1058
|
-
[BLUE]: create$
|
|
1059
|
-
[GREEN]: create$
|
|
1060
|
-
[GREY]: create$
|
|
1061
|
-
[RED]: create$
|
|
1062
|
-
[PURPLE]: create$
|
|
1063
|
-
[ORANGE]: create$
|
|
1064
|
-
[UNCOLOR]: create$
|
|
1067
|
+
[BOLD]: create$5('font-weight', 'bold'),
|
|
1068
|
+
[UNBOLD]: create$5('font-weight', 'normal'),
|
|
1069
|
+
[BLUE]: create$5('color', 'blue'),
|
|
1070
|
+
[GREEN]: create$5('color', 'green'),
|
|
1071
|
+
[GREY]: create$5('color', 'grey'),
|
|
1072
|
+
[RED]: create$5('color', 'red'),
|
|
1073
|
+
[PURPLE]: create$5('color', 'purple'),
|
|
1074
|
+
[ORANGE]: create$5('color', 'orange'), // not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
1075
|
+
[UNCOLOR]: create$5('color', 'black')
|
|
1065
1076
|
};
|
|
1066
1077
|
|
|
1067
1078
|
const _nodeStyleMap = {
|
|
@@ -1084,7 +1095,7 @@
|
|
|
1084
1095
|
const computeBrowserLoggingArgs = args => {
|
|
1085
1096
|
const strBuilder = [];
|
|
1086
1097
|
const styles = [];
|
|
1087
|
-
const currentStyle = create();
|
|
1098
|
+
const currentStyle = create$7();
|
|
1088
1099
|
/**
|
|
1089
1100
|
* @type {Array<string|Object|number>}
|
|
1090
1101
|
*/
|
|
@@ -1213,7 +1224,7 @@
|
|
|
1213
1224
|
/**
|
|
1214
1225
|
* @param {Array<string|Symbol|Object|number>} args
|
|
1215
1226
|
*/
|
|
1216
|
-
const group = (...args) => {
|
|
1227
|
+
const group$1 = (...args) => {
|
|
1217
1228
|
console.group(...computeLoggingArgs(args));
|
|
1218
1229
|
/* istanbul ignore next */
|
|
1219
1230
|
vconsoles.forEach(vc => vc.group(args));
|
|
@@ -1239,7 +1250,7 @@
|
|
|
1239
1250
|
* @param {HTMLCanvasElement} canvas
|
|
1240
1251
|
* @param {number} height
|
|
1241
1252
|
*/
|
|
1242
|
-
const printCanvas = (canvas, height) => printImg(canvas.toDataURL(), height);
|
|
1253
|
+
const printCanvas$1 = (canvas, height) => printImg(canvas.toDataURL(), height);
|
|
1243
1254
|
|
|
1244
1255
|
const vconsoles = new Set();
|
|
1245
1256
|
|
|
@@ -1262,7 +1273,7 @@
|
|
|
1262
1273
|
} else {
|
|
1263
1274
|
if (arg.constructor === String || arg.constructor === Number) {
|
|
1264
1275
|
// @ts-ignore
|
|
1265
|
-
const span = element('span', [create$
|
|
1276
|
+
const span = element('span', [create$5('style', mapToStyleString(currentStyle))], [text(arg)]);
|
|
1266
1277
|
if (span.innerHTML === '') {
|
|
1267
1278
|
span.innerHTML = ' ';
|
|
1268
1279
|
}
|
|
@@ -1307,11 +1318,11 @@
|
|
|
1307
1318
|
* @param {boolean} collapsed
|
|
1308
1319
|
*/
|
|
1309
1320
|
group (args, collapsed = false) {
|
|
1310
|
-
enqueue(() => {
|
|
1311
|
-
const triangleDown = element('span', [create$
|
|
1312
|
-
const triangleRight = element('span', [create$
|
|
1313
|
-
const content = element('div', [create$
|
|
1314
|
-
const nextContainer = element('div', [create$
|
|
1321
|
+
enqueue$1(() => {
|
|
1322
|
+
const triangleDown = element('span', [create$5('hidden', collapsed), create$5('style', 'color:grey;font-size:120%;')], [text('▼')]);
|
|
1323
|
+
const triangleRight = element('span', [create$5('hidden', !collapsed), create$5('style', 'color:grey;font-size:125%;')], [text('▶')]);
|
|
1324
|
+
const content = element('div', [create$5('style', `${lineStyle};padding-left:${this.depth * 10}px`)], [triangleDown, triangleRight, text(' ')].concat(_computeLineSpans(args)));
|
|
1325
|
+
const nextContainer = element('div', [create$5('hidden', collapsed)]);
|
|
1315
1326
|
const nextLine = element('div', [], [content, nextContainer]);
|
|
1316
1327
|
append(this.ccontainer, [nextLine]);
|
|
1317
1328
|
this.ccontainer = nextContainer;
|
|
@@ -1333,7 +1344,7 @@
|
|
|
1333
1344
|
}
|
|
1334
1345
|
|
|
1335
1346
|
groupEnd () {
|
|
1336
|
-
enqueue(() => {
|
|
1347
|
+
enqueue$1(() => {
|
|
1337
1348
|
if (this.depth > 0) {
|
|
1338
1349
|
this.depth--;
|
|
1339
1350
|
// @ts-ignore
|
|
@@ -1346,8 +1357,8 @@
|
|
|
1346
1357
|
* @param {Array<string|Symbol|Object|number>} args
|
|
1347
1358
|
*/
|
|
1348
1359
|
print (args) {
|
|
1349
|
-
enqueue(() => {
|
|
1350
|
-
append(this.ccontainer, [element('div', [create$
|
|
1360
|
+
enqueue$1(() => {
|
|
1361
|
+
append(this.ccontainer, [element('div', [create$5('style', `${lineStyle};padding-left:${this.depth * 10}px`)], _computeLineSpans(args))]);
|
|
1351
1362
|
});
|
|
1352
1363
|
}
|
|
1353
1364
|
|
|
@@ -1363,8 +1374,8 @@
|
|
|
1363
1374
|
* @param {number} height
|
|
1364
1375
|
*/
|
|
1365
1376
|
printImg (url, height) {
|
|
1366
|
-
enqueue(() => {
|
|
1367
|
-
append(this.ccontainer, [element('img', [create$
|
|
1377
|
+
enqueue$1(() => {
|
|
1378
|
+
append(this.ccontainer, [element('img', [create$5('src', url), create$5('height', `${round(height * 1.5)}px`)])]);
|
|
1368
1379
|
});
|
|
1369
1380
|
}
|
|
1370
1381
|
|
|
@@ -1372,13 +1383,13 @@
|
|
|
1372
1383
|
* @param {Node} node
|
|
1373
1384
|
*/
|
|
1374
1385
|
printDom (node) {
|
|
1375
|
-
enqueue(() => {
|
|
1386
|
+
enqueue$1(() => {
|
|
1376
1387
|
append(this.ccontainer, [node]);
|
|
1377
1388
|
});
|
|
1378
1389
|
}
|
|
1379
1390
|
|
|
1380
1391
|
destroy () {
|
|
1381
|
-
enqueue(() => {
|
|
1392
|
+
enqueue$1(() => {
|
|
1382
1393
|
vconsoles.delete(this);
|
|
1383
1394
|
});
|
|
1384
1395
|
}
|
|
@@ -1488,7 +1499,7 @@
|
|
|
1488
1499
|
};
|
|
1489
1500
|
|
|
1490
1501
|
/* eslint-env browser */
|
|
1491
|
-
const performance = typeof window
|
|
1502
|
+
const performance = typeof window === 'undefined' ? null : (typeof window.performance !== 'undefined' && window.performance) || null;
|
|
1492
1503
|
|
|
1493
1504
|
const isoCrypto = typeof crypto === 'undefined' ? null : crypto;
|
|
1494
1505
|
|
|
@@ -1514,12 +1525,12 @@
|
|
|
1514
1525
|
};
|
|
1515
1526
|
|
|
1516
1527
|
/* istanbul ignore next */
|
|
1517
|
-
const uint32 = () => new Uint32Array(cryptoRandomBuffer(4))[0];
|
|
1528
|
+
const uint32$1 = () => new Uint32Array(cryptoRandomBuffer(4))[0];
|
|
1518
1529
|
|
|
1519
1530
|
// @ts-ignore
|
|
1520
1531
|
const uuidv4Template = [1e7] + -1e3 + -4e3 + -8e3 + -1e11;
|
|
1521
1532
|
const uuidv4 = () => uuidv4Template.replace(/[018]/g, /** @param {number} c */ c =>
|
|
1522
|
-
(c ^ uint32() & 15 >> c / 4).toString(16)
|
|
1533
|
+
(c ^ uint32$1() & 15 >> c / 4).toString(16)
|
|
1523
1534
|
);
|
|
1524
1535
|
|
|
1525
1536
|
/* eslint-env browser */
|
|
@@ -1613,7 +1624,7 @@
|
|
|
1613
1624
|
*/
|
|
1614
1625
|
const BITS32 = 0xFFFFFFFF;
|
|
1615
1626
|
|
|
1616
|
-
var binary = /*#__PURE__*/Object.freeze({
|
|
1627
|
+
var binary$1 = /*#__PURE__*/Object.freeze({
|
|
1617
1628
|
__proto__: null,
|
|
1618
1629
|
BIT1: BIT1,
|
|
1619
1630
|
BIT2: BIT2,
|
|
@@ -1846,7 +1857,7 @@
|
|
|
1846
1857
|
|
|
1847
1858
|
/* istanbul ignore next */
|
|
1848
1859
|
const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && floor(num) === num);
|
|
1849
|
-
const isNaN
|
|
1860
|
+
const isNaN = Number.isNaN;
|
|
1850
1861
|
|
|
1851
1862
|
/**
|
|
1852
1863
|
* Efficient schema-less binary encoding with support for variable length encoding.
|
|
@@ -1903,7 +1914,7 @@
|
|
|
1903
1914
|
* @param {Encoder} encoder
|
|
1904
1915
|
* @return {number}
|
|
1905
1916
|
*/
|
|
1906
|
-
const length
|
|
1917
|
+
const length = encoder => {
|
|
1907
1918
|
let len = encoder.cpos;
|
|
1908
1919
|
for (let i = 0; i < encoder.bufs.length; i++) {
|
|
1909
1920
|
len += encoder.bufs[i].length;
|
|
@@ -1919,7 +1930,7 @@
|
|
|
1919
1930
|
* @return {Uint8Array} The created ArrayBuffer.
|
|
1920
1931
|
*/
|
|
1921
1932
|
const toUint8Array = encoder => {
|
|
1922
|
-
const uint8arr = new Uint8Array(length
|
|
1933
|
+
const uint8arr = new Uint8Array(length(encoder));
|
|
1923
1934
|
let curPos = 0;
|
|
1924
1935
|
for (let i = 0; i < encoder.bufs.length; i++) {
|
|
1925
1936
|
const d = encoder.bufs[i];
|
|
@@ -2218,19 +2229,19 @@
|
|
|
2218
2229
|
* @param {Encoder} encoder
|
|
2219
2230
|
* @param {number} num
|
|
2220
2231
|
*/
|
|
2221
|
-
const writeFloat32 = (encoder, num) => writeOnDataView(encoder, 4).setFloat32(0, num);
|
|
2232
|
+
const writeFloat32 = (encoder, num) => writeOnDataView(encoder, 4).setFloat32(0, num, false);
|
|
2222
2233
|
|
|
2223
2234
|
/**
|
|
2224
2235
|
* @param {Encoder} encoder
|
|
2225
2236
|
* @param {number} num
|
|
2226
2237
|
*/
|
|
2227
|
-
const writeFloat64 = (encoder, num) => writeOnDataView(encoder, 8).setFloat64(0, num);
|
|
2238
|
+
const writeFloat64 = (encoder, num) => writeOnDataView(encoder, 8).setFloat64(0, num, false);
|
|
2228
2239
|
|
|
2229
2240
|
/**
|
|
2230
2241
|
* @param {Encoder} encoder
|
|
2231
2242
|
* @param {bigint} num
|
|
2232
2243
|
*/
|
|
2233
|
-
const writeBigInt64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigInt64(0, num);
|
|
2244
|
+
const writeBigInt64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigInt64(0, num, false);
|
|
2234
2245
|
|
|
2235
2246
|
const floatTestBed = new DataView(new ArrayBuffer(4));
|
|
2236
2247
|
/**
|
|
@@ -2468,6 +2479,7 @@
|
|
|
2468
2479
|
* @param {UintOptRleEncoder} encoder
|
|
2469
2480
|
*/
|
|
2470
2481
|
const flushUintOptRleEncoder = encoder => {
|
|
2482
|
+
/* istanbul ignore else */
|
|
2471
2483
|
if (encoder.count > 0) {
|
|
2472
2484
|
// flush counter, unless this is the first value (count = 0)
|
|
2473
2485
|
// case 1: just a single value. set sign to positive
|
|
@@ -2808,7 +2820,7 @@
|
|
|
2808
2820
|
};
|
|
2809
2821
|
|
|
2810
2822
|
/**
|
|
2811
|
-
* Look ahead without incrementing position
|
|
2823
|
+
* Look ahead without incrementing the position
|
|
2812
2824
|
* to the next byte and read it as unsigned integer.
|
|
2813
2825
|
*
|
|
2814
2826
|
* @function
|
|
@@ -2818,7 +2830,7 @@
|
|
|
2818
2830
|
const peekUint8 = decoder => decoder.arr[decoder.pos];
|
|
2819
2831
|
|
|
2820
2832
|
/**
|
|
2821
|
-
* Look ahead without incrementing position
|
|
2833
|
+
* Look ahead without incrementing the position
|
|
2822
2834
|
* to the next byte and read it as unsigned integer.
|
|
2823
2835
|
*
|
|
2824
2836
|
* @function
|
|
@@ -2830,7 +2842,7 @@
|
|
|
2830
2842
|
(decoder.arr[decoder.pos + 1] << 8);
|
|
2831
2843
|
|
|
2832
2844
|
/**
|
|
2833
|
-
* Look ahead without incrementing position
|
|
2845
|
+
* Look ahead without incrementing the position
|
|
2834
2846
|
* to the next byte and read it as unsigned integer.
|
|
2835
2847
|
*
|
|
2836
2848
|
* @function
|
|
@@ -2876,7 +2888,7 @@
|
|
|
2876
2888
|
* 1/8th of the storage is used as encoding overhead.
|
|
2877
2889
|
* * numbers < 2^7 is stored in one bytlength
|
|
2878
2890
|
* * numbers < 2^14 is stored in two bylength
|
|
2879
|
-
* @todo This should probably create the inverse ~num if
|
|
2891
|
+
* @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.
|
|
2880
2892
|
*
|
|
2881
2893
|
* @function
|
|
2882
2894
|
* @param {Decoder} decoder
|
|
@@ -2999,17 +3011,17 @@
|
|
|
2999
3011
|
/**
|
|
3000
3012
|
* @param {Decoder} decoder
|
|
3001
3013
|
*/
|
|
3002
|
-
const readFloat32 = decoder => readFromDataView(decoder, 4).getFloat32(0);
|
|
3014
|
+
const readFloat32 = decoder => readFromDataView(decoder, 4).getFloat32(0, false);
|
|
3003
3015
|
|
|
3004
3016
|
/**
|
|
3005
3017
|
* @param {Decoder} decoder
|
|
3006
3018
|
*/
|
|
3007
|
-
const readFloat64 = decoder => readFromDataView(decoder, 8).getFloat64(0);
|
|
3019
|
+
const readFloat64 = decoder => readFromDataView(decoder, 8).getFloat64(0, false);
|
|
3008
3020
|
|
|
3009
3021
|
/**
|
|
3010
3022
|
* @param {Decoder} decoder
|
|
3011
3023
|
*/
|
|
3012
|
-
const readBigInt64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigInt64(0);
|
|
3024
|
+
const readBigInt64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigInt64(0, false);
|
|
3013
3025
|
|
|
3014
3026
|
/**
|
|
3015
3027
|
* @type {Array<function(Decoder):any>}
|
|
@@ -3373,7 +3385,7 @@
|
|
|
3373
3385
|
* @param {number} seed A positive 32bit integer. Do not use negative numbers.
|
|
3374
3386
|
* @return {PRNG}
|
|
3375
3387
|
*/
|
|
3376
|
-
const create$
|
|
3388
|
+
const create$3 = seed => new DefaultPRNG(seed);
|
|
3377
3389
|
|
|
3378
3390
|
/**
|
|
3379
3391
|
* Generates a single random bool.
|
|
@@ -3421,7 +3433,7 @@
|
|
|
3421
3433
|
* @param {Number} max The upper bound of the allowed return values (inclusive).
|
|
3422
3434
|
* @return {Number} A random integer on [min, max]
|
|
3423
3435
|
*/
|
|
3424
|
-
const uint32
|
|
3436
|
+
const uint32 = (gen, min, max) => int32(gen, min, max) >>> 0;
|
|
3425
3437
|
|
|
3426
3438
|
/**
|
|
3427
3439
|
* @deprecated
|
|
@@ -3544,7 +3556,7 @@
|
|
|
3544
3556
|
* @param {Array<number>} arr
|
|
3545
3557
|
* @return {number}
|
|
3546
3558
|
*/
|
|
3547
|
-
const average = arr => arr.reduce(add, 0) / arr.length;
|
|
3559
|
+
const average = arr => arr.reduce(add$1, 0) / arr.length;
|
|
3548
3560
|
|
|
3549
3561
|
/**
|
|
3550
3562
|
* Utility helpers to work with promises.
|
|
@@ -3563,7 +3575,7 @@
|
|
|
3563
3575
|
* @param {function(PromiseResolve<T>,function(Error):void):any} f
|
|
3564
3576
|
* @return {Promise<T>}
|
|
3565
3577
|
*/
|
|
3566
|
-
const create$
|
|
3578
|
+
const create$2 = f => /** @type {Promise<T>} */ (new Promise(f));
|
|
3567
3579
|
|
|
3568
3580
|
/**
|
|
3569
3581
|
* @param {function(function():void,function(Error):void):void} f
|
|
@@ -3600,7 +3612,7 @@
|
|
|
3600
3612
|
* @param {number} [intervalResolution]
|
|
3601
3613
|
* @return {Promise<void>}
|
|
3602
3614
|
*/
|
|
3603
|
-
const until = (timeout, check, intervalResolution = 10) => create$
|
|
3615
|
+
const until = (timeout, check, intervalResolution = 10) => create$2((resolve, reject) => {
|
|
3604
3616
|
const startTime = getUnixTime();
|
|
3605
3617
|
const hasTimeout = timeout > 0;
|
|
3606
3618
|
const untilInterval = () => {
|
|
@@ -3622,7 +3634,7 @@
|
|
|
3622
3634
|
* @param {number} timeout
|
|
3623
3635
|
* @return {Promise<undefined>}
|
|
3624
3636
|
*/
|
|
3625
|
-
const wait = timeout => create$
|
|
3637
|
+
const wait = timeout => create$2((resolve, reject) => setTimeout(resolve, timeout));
|
|
3626
3638
|
|
|
3627
3639
|
/**
|
|
3628
3640
|
* Checks if an object is a promise using ducktyping.
|
|
@@ -3716,7 +3728,7 @@
|
|
|
3716
3728
|
/* istanbul ignore else */
|
|
3717
3729
|
if (this._seed === null) {
|
|
3718
3730
|
/* istanbul ignore next */
|
|
3719
|
-
this._seed = envSeed === null ? uint32() : envSeed;
|
|
3731
|
+
this._seed = envSeed === null ? uint32$1() : envSeed;
|
|
3720
3732
|
}
|
|
3721
3733
|
return this._seed
|
|
3722
3734
|
}
|
|
@@ -3729,13 +3741,13 @@
|
|
|
3729
3741
|
get prng () {
|
|
3730
3742
|
/* istanbul ignore else */
|
|
3731
3743
|
if (this._prng === null) {
|
|
3732
|
-
this._prng = create$
|
|
3744
|
+
this._prng = create$3(this.seed);
|
|
3733
3745
|
}
|
|
3734
3746
|
return this._prng
|
|
3735
3747
|
}
|
|
3736
3748
|
}
|
|
3737
3749
|
|
|
3738
|
-
const
|
|
3750
|
+
const repetitionTime = Number(getParam('--repetition-time', '50'));
|
|
3739
3751
|
/* istanbul ignore next */
|
|
3740
3752
|
const testFilter = hasParam('--filter') ? getParam('--filter', '') : null;
|
|
3741
3753
|
|
|
@@ -3765,7 +3777,7 @@
|
|
|
3765
3777
|
if (testFilter === null) {
|
|
3766
3778
|
groupCollapsed(...groupArgs);
|
|
3767
3779
|
} else {
|
|
3768
|
-
group(...groupArgs);
|
|
3780
|
+
group$1(...groupArgs);
|
|
3769
3781
|
}
|
|
3770
3782
|
const times = [];
|
|
3771
3783
|
const start = performance.now();
|
|
@@ -3784,12 +3796,12 @@
|
|
|
3784
3796
|
const currTime = performance.now();
|
|
3785
3797
|
times.push(currTime - lastTime);
|
|
3786
3798
|
lastTime = currTime;
|
|
3787
|
-
if (repeat && err === null && (lastTime - start) <
|
|
3799
|
+
if (repeat && err === null && (lastTime - start) < repetitionTime) {
|
|
3788
3800
|
tc.resetSeed();
|
|
3789
3801
|
} else {
|
|
3790
3802
|
break
|
|
3791
3803
|
}
|
|
3792
|
-
} while (err === null && (lastTime - start) <
|
|
3804
|
+
} while (err === null && (lastTime - start) < repetitionTime)
|
|
3793
3805
|
performance.mark(`${name}-end`);
|
|
3794
3806
|
/* istanbul ignore if */
|
|
3795
3807
|
if (err !== null && err.constructor !== SkipError) {
|
|
@@ -3805,7 +3817,7 @@
|
|
|
3805
3817
|
? ` - ${window.location.href}?filter=\\[${i + 1}/${tc._seed === null ? '' : `&seed=${tc._seed}`}`
|
|
3806
3818
|
: `\nrepeat: npm run test -- --filter "\\[${i + 1}/" ${tc._seed === null ? '' : `--seed ${tc._seed}`}`;
|
|
3807
3819
|
const timeInfo = (repeat && err === null)
|
|
3808
|
-
? ` - ${times.length}
|
|
3820
|
+
? ` - ${times.length} repetitions in ${humanizeDuration(duration)} (best: ${humanizeDuration(times[0])}, worst: ${humanizeDuration(last(times))}, median: ${humanizeDuration(median(times))}, average: ${humanizeDuration(average(times))})`
|
|
3809
3821
|
: ` in ${humanizeDuration(duration)}`;
|
|
3810
3822
|
if (err !== null) {
|
|
3811
3823
|
/* istanbul ignore else */
|
|
@@ -3847,7 +3859,7 @@
|
|
|
3847
3859
|
*/
|
|
3848
3860
|
const info = info => describe('', info);
|
|
3849
3861
|
|
|
3850
|
-
const printCanvas
|
|
3862
|
+
const printCanvas = printCanvas$1;
|
|
3851
3863
|
|
|
3852
3864
|
/**
|
|
3853
3865
|
* Group outputs in a collapsible category.
|
|
@@ -3867,8 +3879,8 @@
|
|
|
3867
3879
|
* @param {string} description
|
|
3868
3880
|
* @param {function(void):void} f
|
|
3869
3881
|
*/
|
|
3870
|
-
const group
|
|
3871
|
-
group(BLUE, description);
|
|
3882
|
+
const group = (description, f) => {
|
|
3883
|
+
group$1(BLUE, description);
|
|
3872
3884
|
try {
|
|
3873
3885
|
f();
|
|
3874
3886
|
} finally {
|
|
@@ -3895,7 +3907,7 @@
|
|
|
3895
3907
|
* @param {function(void):Promise<any>} f
|
|
3896
3908
|
*/
|
|
3897
3909
|
const groupAsync = async (description, f) => {
|
|
3898
|
-
group(BLUE, description);
|
|
3910
|
+
group$1(BLUE, description);
|
|
3899
3911
|
try {
|
|
3900
3912
|
await f();
|
|
3901
3913
|
} finally {
|
|
@@ -4003,7 +4015,7 @@
|
|
|
4003
4015
|
* @param {string} [m]
|
|
4004
4016
|
* @throws {TestError} Throws if test fails
|
|
4005
4017
|
*/
|
|
4006
|
-
const compareObjects = (a, b, m = 'Objects match') => { equalFlat
|
|
4018
|
+
const compareObjects = (a, b, m = 'Objects match') => { equalFlat(a, b) || fail(m); };
|
|
4007
4019
|
|
|
4008
4020
|
/**
|
|
4009
4021
|
* @param {any} constructor
|
|
@@ -4087,10 +4099,10 @@
|
|
|
4087
4099
|
break
|
|
4088
4100
|
}
|
|
4089
4101
|
case Object:
|
|
4090
|
-
if (length(a) !== length(b)) {
|
|
4102
|
+
if (length$1(a) !== length$1(b)) {
|
|
4091
4103
|
_failMessage(message, 'Objects have a different number of attributes', path);
|
|
4092
4104
|
}
|
|
4093
|
-
forEach
|
|
4105
|
+
forEach(a, (value, key) => {
|
|
4094
4106
|
if (!hasProperty(b, key)) {
|
|
4095
4107
|
_failMessage(message, `Property ${path} does not exist on second argument`, path);
|
|
4096
4108
|
}
|
|
@@ -4153,7 +4165,7 @@
|
|
|
4153
4165
|
* @param {Object<string, Object<string, function(TestCase):void|Promise<any>>>} tests
|
|
4154
4166
|
*/
|
|
4155
4167
|
const runTests = async tests => {
|
|
4156
|
-
const numberOfTests = map$
|
|
4168
|
+
const numberOfTests = map$1(tests, mod => map$1(mod, f => /* istanbul ignore next */ f ? 1 : 0).reduce(add$1, 0)).reduce(add$1, 0);
|
|
4157
4169
|
let successfulTests = 0;
|
|
4158
4170
|
let testnumber = 0;
|
|
4159
4171
|
const start = performance.now();
|
|
@@ -4342,8 +4354,8 @@
|
|
|
4342
4354
|
gen => false, // TYPE 120
|
|
4343
4355
|
gen => utf16String(gen), // TYPE 119
|
|
4344
4356
|
(gen, depth, toJsonCompatible) => ({ val: genAny(gen, depth + 1, toJsonCompatible) }), // TYPE 118
|
|
4345
|
-
(gen, depth, toJsonCompatible) => Array.from({ length: uint32
|
|
4346
|
-
gen => uint8Array(gen, uint32
|
|
4357
|
+
(gen, depth, toJsonCompatible) => Array.from({ length: uint32(gen, 0, 20 - depth) }).map(() => genAny(gen, depth + 1, toJsonCompatible)), // TYPE 117
|
|
4358
|
+
gen => uint8Array(gen, uint32(gen, 0, 50)) // TYPE 116
|
|
4347
4359
|
];
|
|
4348
4360
|
|
|
4349
4361
|
const genAnyLookupTableJsonCompatible = genAnyLookupTable.slice(1);
|
|
@@ -4412,7 +4424,7 @@
|
|
|
4412
4424
|
const reader = createDecoder(toUint8Array(encoder));
|
|
4413
4425
|
const result = read(reader);
|
|
4414
4426
|
const utf8ByteLength$1 = utf8ByteLength(val + '');
|
|
4415
|
-
const binaryByteLength = length
|
|
4427
|
+
const binaryByteLength = length(encoder);
|
|
4416
4428
|
if (doLog) {
|
|
4417
4429
|
describe(testname, ` utf8 encode: ${utf8ByteLength$1} bytes / binary encode: ${binaryByteLength} bytes`);
|
|
4418
4430
|
}
|
|
@@ -4578,7 +4590,7 @@
|
|
|
4578
4590
|
* @param {t.TestCase} tc
|
|
4579
4591
|
*/
|
|
4580
4592
|
const testRepeatVarIntEncoding = tc => {
|
|
4581
|
-
const n = uint32
|
|
4593
|
+
const n = uint32(tc.prng, 0, BITS32);
|
|
4582
4594
|
test(`varInt of ${n}`, writeVarInt, readVarInt, n, false);
|
|
4583
4595
|
};
|
|
4584
4596
|
|
|
@@ -4602,7 +4614,7 @@
|
|
|
4602
4614
|
* @param {t.TestCase} tc
|
|
4603
4615
|
*/
|
|
4604
4616
|
const testRepeatPeekVarIntEncoding = tc => {
|
|
4605
|
-
const n = uint32
|
|
4617
|
+
const n = uint32(tc.prng, 0, BITS32);
|
|
4606
4618
|
test(`varInt of ${n}`, writeVarInt, peekVarInt, n, false);
|
|
4607
4619
|
};
|
|
4608
4620
|
|
|
@@ -4693,12 +4705,12 @@
|
|
|
4693
4705
|
*/
|
|
4694
4706
|
const encodingPairs = [
|
|
4695
4707
|
{ name: 'uint8Array', read: decoder => readUint8Array(decoder, defLen), write: writeUint8Array, gen: gen => uint8Array(gen, defLen), compare: compare },
|
|
4696
|
-
{ name: 'varUint8Array', read: readVarUint8Array, write: writeVarUint8Array, gen: gen => uint8Array(gen, uint32
|
|
4697
|
-
{ name: 'uint8', read: readUint8, write: writeUint8, gen: gen => uint32
|
|
4698
|
-
{ name: 'uint16', read: readUint16, write: writeUint16, gen: gen => uint32
|
|
4699
|
-
{ name: 'uint32', read: readUint32, write: writeUint32, gen: gen => uint32
|
|
4700
|
-
{ name: 'uint32bigEndian', read: readUint32BigEndian, write: writeUint32BigEndian, gen: gen => uint32
|
|
4701
|
-
{ name: 'varString', read: readVarString, write: writeVarString, gen: gen => utf16String(gen, uint32
|
|
4708
|
+
{ name: 'varUint8Array', read: readVarUint8Array, write: writeVarUint8Array, gen: gen => uint8Array(gen, uint32(gen, 0, defLen)), compare: compare },
|
|
4709
|
+
{ name: 'uint8', read: readUint8, write: writeUint8, gen: gen => uint32(gen, 0, BITS8), compare: strictComparison },
|
|
4710
|
+
{ name: 'uint16', read: readUint16, write: writeUint16, gen: gen => uint32(gen, 0, BITS16), compare: strictComparison },
|
|
4711
|
+
{ name: 'uint32', read: readUint32, write: writeUint32, gen: gen => uint32(gen, 0, BITS32), compare: strictComparison },
|
|
4712
|
+
{ name: 'uint32bigEndian', read: readUint32BigEndian, write: writeUint32BigEndian, gen: gen => uint32(gen, 0, BITS32), compare: strictComparison },
|
|
4713
|
+
{ name: 'varString', read: readVarString, write: writeVarString, gen: gen => utf16String(gen, uint32(gen, 0, defLen)), compare: strictComparison },
|
|
4702
4714
|
{ name: 'varUint', read: readVarUint, write: writeVarUint, gen: gen => uint53(gen, 0, BITS32), compare: strictComparison },
|
|
4703
4715
|
{ name: 'varInt', read: readVarInt, write: writeVarInt, gen: gen => int53(gen, LOWEST_INT32, HIGHEST_INT32), compare: strictComparison },
|
|
4704
4716
|
{ name: 'Any', read: readAny, write: writeAny, gen: genAny, compare: compare }
|
|
@@ -4727,7 +4739,7 @@
|
|
|
4727
4739
|
writeUint8Array(encoder, tailData);
|
|
4728
4740
|
const buf = toUint8Array(encoder);
|
|
4729
4741
|
const decoder = createDecoder(buf);
|
|
4730
|
-
assert(length
|
|
4742
|
+
assert(length(encoder) === buf.byteLength);
|
|
4731
4743
|
for (let i = 0; i < ops.length; i++) {
|
|
4732
4744
|
const o = ops[i];
|
|
4733
4745
|
const val = o.read(decoder);
|
|
@@ -4765,7 +4777,7 @@
|
|
|
4765
4777
|
encoder.cpos = initialLen - 2;
|
|
4766
4778
|
writeUint32(encoder, BITS32);
|
|
4767
4779
|
const buf = toUint8Array(encoder);
|
|
4768
|
-
assert(length
|
|
4780
|
+
assert(length(encoder) === initialLen + 2);
|
|
4769
4781
|
const decoder = createDecoder(buf);
|
|
4770
4782
|
const space = createUint8ArrayFromArrayBuffer(readUint8Array(decoder, initialLen - 2));
|
|
4771
4783
|
for (let i = 0; i < initialLen - 2; i++) {
|
|
@@ -5090,7 +5102,7 @@
|
|
|
5090
5102
|
compare([1, 2], [1, 2], 'simple compare (array)');
|
|
5091
5103
|
compare({ a: [1, 2] }, { a: [1, 2] }, 'simple compare nested');
|
|
5092
5104
|
compare(new Set(['3', 1234]), new Set(['3', 1234]), 'compare Sets');
|
|
5093
|
-
const map1 = create();
|
|
5105
|
+
const map1 = create$7();
|
|
5094
5106
|
map1.set(1, 2);
|
|
5095
5107
|
map1.set('x', {});
|
|
5096
5108
|
map1.set(98, 'tst');
|
|
@@ -5194,17 +5206,17 @@
|
|
|
5194
5206
|
};
|
|
5195
5207
|
|
|
5196
5208
|
const testAsync = async () => {
|
|
5197
|
-
await measureTimeAsync('time', () => create$
|
|
5209
|
+
await measureTimeAsync('time', () => create$2(r => setTimeout(r)));
|
|
5198
5210
|
await groupAsync('some description', () => wait(1));
|
|
5199
5211
|
};
|
|
5200
5212
|
|
|
5201
|
-
const
|
|
5213
|
+
const testRepeatRepetition = () => {
|
|
5202
5214
|
const arr = [];
|
|
5203
5215
|
const n = 100;
|
|
5204
5216
|
for (let i = 1; i <= n; i++) {
|
|
5205
5217
|
arr.push(i);
|
|
5206
5218
|
}
|
|
5207
|
-
assert(arr.reduce(add, 0) === (n + 1) * n / 2);
|
|
5219
|
+
assert(arr.reduce(add$1, 0) === (n + 1) * n / 2);
|
|
5208
5220
|
};
|
|
5209
5221
|
|
|
5210
5222
|
var testing = /*#__PURE__*/Object.freeze({
|
|
@@ -5213,7 +5225,7 @@
|
|
|
5213
5225
|
testFailing: testFailing,
|
|
5214
5226
|
testSkipping: testSkipping,
|
|
5215
5227
|
testAsync: testAsync,
|
|
5216
|
-
|
|
5228
|
+
testRepeatRepetition: testRepeatRepetition
|
|
5217
5229
|
});
|
|
5218
5230
|
|
|
5219
5231
|
/**
|
|
@@ -5227,7 +5239,7 @@
|
|
|
5227
5239
|
* @return {Error}
|
|
5228
5240
|
*/
|
|
5229
5241
|
/* istanbul ignore next */
|
|
5230
|
-
const create$
|
|
5242
|
+
const create$1 = s => new Error(s);
|
|
5231
5243
|
|
|
5232
5244
|
/* eslint-env browser */
|
|
5233
5245
|
|
|
@@ -5238,7 +5250,7 @@
|
|
|
5238
5250
|
* @return {Promise<any>}
|
|
5239
5251
|
*/
|
|
5240
5252
|
/* istanbul ignore next */
|
|
5241
|
-
const rtop = request => create$
|
|
5253
|
+
const rtop = request => create$2((resolve, reject) => {
|
|
5242
5254
|
/* istanbul ignore next */
|
|
5243
5255
|
// @ts-ignore
|
|
5244
5256
|
request.onerror = event => reject(new Error(event.target.error));
|
|
@@ -5255,7 +5267,7 @@
|
|
|
5255
5267
|
* @return {Promise<IDBDatabase>}
|
|
5256
5268
|
*/
|
|
5257
5269
|
/* istanbul ignore next */
|
|
5258
|
-
const openDB = (name, initDB) => create$
|
|
5270
|
+
const openDB = (name, initDB) => create$2((resolve, reject) => {
|
|
5259
5271
|
const request = indexedDB.open(name);
|
|
5260
5272
|
/**
|
|
5261
5273
|
* @param {any} event
|
|
@@ -5265,7 +5277,7 @@
|
|
|
5265
5277
|
/**
|
|
5266
5278
|
* @param {any} event
|
|
5267
5279
|
*/
|
|
5268
|
-
request.onerror = event => reject(create$
|
|
5280
|
+
request.onerror = event => reject(create$1(event.target.error));
|
|
5269
5281
|
/* istanbul ignore next */
|
|
5270
5282
|
request.onblocked = () => location.reload();
|
|
5271
5283
|
/**
|
|
@@ -5335,7 +5347,7 @@
|
|
|
5335
5347
|
* @return {Promise<any>}
|
|
5336
5348
|
*/
|
|
5337
5349
|
/* istanbul ignore next */
|
|
5338
|
-
const add
|
|
5350
|
+
const add = (store, item, key) =>
|
|
5339
5351
|
rtop(store.add(item, key));
|
|
5340
5352
|
|
|
5341
5353
|
/**
|
|
@@ -5388,7 +5400,7 @@
|
|
|
5388
5400
|
* @return {Promise<void>}
|
|
5389
5401
|
*/
|
|
5390
5402
|
/* istanbul ignore next */
|
|
5391
|
-
const iterateOnRequest = (request, f) => create$
|
|
5403
|
+
const iterateOnRequest = (request, f) => create$2((resolve, reject) => {
|
|
5392
5404
|
/* istanbul ignore next */
|
|
5393
5405
|
request.onerror = reject;
|
|
5394
5406
|
/**
|
|
@@ -5433,7 +5445,7 @@
|
|
|
5433
5445
|
* @returns {IDBObjectStore}
|
|
5434
5446
|
*/
|
|
5435
5447
|
/* istanbul ignore next */
|
|
5436
|
-
const getStore = (t, store) => t.objectStore(store);
|
|
5448
|
+
const getStore$1 = (t, store) => t.objectStore(store);
|
|
5437
5449
|
|
|
5438
5450
|
/**
|
|
5439
5451
|
* @param {any} lower
|
|
@@ -5462,7 +5474,7 @@
|
|
|
5462
5474
|
* @param {IDBTransaction} t
|
|
5463
5475
|
* @return {IDBObjectStore}
|
|
5464
5476
|
*/
|
|
5465
|
-
const getStore
|
|
5477
|
+
const getStore = t => getStore$1(t, 'test');
|
|
5466
5478
|
|
|
5467
5479
|
/* istanbul ignore next */
|
|
5468
5480
|
const testRetrieveElements = async () => {
|
|
@@ -5471,7 +5483,7 @@
|
|
|
5471
5483
|
await deleteDB(testDBName);
|
|
5472
5484
|
const db = await openDB(testDBName, initTestDB);
|
|
5473
5485
|
const transaction = createTransaction(db);
|
|
5474
|
-
const store = getStore
|
|
5486
|
+
const store = getStore(transaction);
|
|
5475
5487
|
await put(store, 0, ['t', 1]);
|
|
5476
5488
|
await put(store, 1, ['t', 2]);
|
|
5477
5489
|
const expectedKeys = [['t', 1], ['t', 2]];
|
|
@@ -5526,7 +5538,7 @@
|
|
|
5526
5538
|
const getVDel = await get(store, ['t', 0]);
|
|
5527
5539
|
assert(getVDel === undefined);
|
|
5528
5540
|
describe('idb.add');
|
|
5529
|
-
await add
|
|
5541
|
+
await add(store, 99, 42);
|
|
5530
5542
|
const idbVAdd = await get(store, 42);
|
|
5531
5543
|
assert(idbVAdd === 99);
|
|
5532
5544
|
describe('idb.addAutoKey');
|
|
@@ -5623,7 +5635,7 @@
|
|
|
5623
5635
|
* @param {prng.PRNG} gen
|
|
5624
5636
|
*/
|
|
5625
5637
|
const runGenTest = (tc, gen) => {
|
|
5626
|
-
group
|
|
5638
|
+
group('next - average distribution', () => {
|
|
5627
5639
|
let sum = 0;
|
|
5628
5640
|
for (let i = 0; i < genTestData; i++) {
|
|
5629
5641
|
const next = gen.next();
|
|
@@ -5637,7 +5649,7 @@
|
|
|
5637
5649
|
assert(avg <= 0.55);
|
|
5638
5650
|
});
|
|
5639
5651
|
|
|
5640
|
-
group
|
|
5652
|
+
group('bool - bool distribution is fair', () => {
|
|
5641
5653
|
let head = 0;
|
|
5642
5654
|
let tail = 0;
|
|
5643
5655
|
let b;
|
|
@@ -5655,12 +5667,12 @@
|
|
|
5655
5667
|
assert(tail >= floor(genTestData * 0.45), 'Generated enough tails.');
|
|
5656
5668
|
assert(head >= floor(genTestData * 0.45), 'Generated enough heads.');
|
|
5657
5669
|
});
|
|
5658
|
-
group
|
|
5670
|
+
group('int31 - integers average correctly', () => {
|
|
5659
5671
|
let count = 0;
|
|
5660
5672
|
let i;
|
|
5661
5673
|
|
|
5662
5674
|
for (i = 0; i < genTestData; i++) {
|
|
5663
|
-
count += uint32
|
|
5675
|
+
count += uint32(gen, 0, 100);
|
|
5664
5676
|
}
|
|
5665
5677
|
const average = count / genTestData;
|
|
5666
5678
|
const expectedAverage = 100 / 2;
|
|
@@ -5668,7 +5680,7 @@
|
|
|
5668
5680
|
assert(abs(average - expectedAverage) <= 2, 'Expected average is at most 1 off.');
|
|
5669
5681
|
});
|
|
5670
5682
|
|
|
5671
|
-
group
|
|
5683
|
+
group('int32 - generates integer with 32 bits', () => {
|
|
5672
5684
|
let largest = 0;
|
|
5673
5685
|
let smallest = 0;
|
|
5674
5686
|
let i;
|
|
@@ -5689,12 +5701,12 @@
|
|
|
5689
5701
|
assert((smallest & BIT32) !== 0, 'Largest number is 32 bits long'); // largest.. assuming we convert int to uint
|
|
5690
5702
|
});
|
|
5691
5703
|
|
|
5692
|
-
group
|
|
5704
|
+
group('uint32 - generates unsigned integer with 32 bits', () => {
|
|
5693
5705
|
let num = 0;
|
|
5694
5706
|
let i;
|
|
5695
5707
|
let newNum;
|
|
5696
5708
|
for (i = 0; i < genTestData; i++) {
|
|
5697
|
-
newNum = uint32
|
|
5709
|
+
newNum = uint32(gen, 0, BITS32);
|
|
5698
5710
|
if (newNum > num) {
|
|
5699
5711
|
num = newNum;
|
|
5700
5712
|
}
|
|
@@ -5703,7 +5715,7 @@
|
|
|
5703
5715
|
assert((num & BIT32) !== 0, 'Largest number is 32 bits long.');
|
|
5704
5716
|
});
|
|
5705
5717
|
|
|
5706
|
-
group
|
|
5718
|
+
group('int53 - generates integer exceeding 32 bits', () => {
|
|
5707
5719
|
let largest = 0;
|
|
5708
5720
|
let smallest = 0;
|
|
5709
5721
|
let i;
|
|
@@ -5725,7 +5737,7 @@
|
|
|
5725
5737
|
assert(smallest < BITS32, 'Smallest Number is smaller than BITS32 (negative)');
|
|
5726
5738
|
});
|
|
5727
5739
|
|
|
5728
|
-
group
|
|
5740
|
+
group('uint53 - generates integer exceeding 32 bits', () => {
|
|
5729
5741
|
let largest = 0;
|
|
5730
5742
|
let smallest = 10000;
|
|
5731
5743
|
let i;
|
|
@@ -5747,12 +5759,12 @@
|
|
|
5747
5759
|
assert(largest > (BITS32 >>> 0), 'Largest number exceeds BITS32');
|
|
5748
5760
|
});
|
|
5749
5761
|
|
|
5750
|
-
group
|
|
5762
|
+
group('int31 - generates integer with 31 bits', () => {
|
|
5751
5763
|
let num = 0;
|
|
5752
5764
|
let i;
|
|
5753
5765
|
let newNum;
|
|
5754
5766
|
for (i = 0; i < genTestData; i++) {
|
|
5755
|
-
newNum = uint32
|
|
5767
|
+
newNum = uint32(gen, 0, BITS31);
|
|
5756
5768
|
if (newNum > num) {
|
|
5757
5769
|
num = newNum;
|
|
5758
5770
|
}
|
|
@@ -5761,7 +5773,7 @@
|
|
|
5761
5773
|
assert((num & BIT31) !== 0, 'Largest number is 31 bits long.');
|
|
5762
5774
|
});
|
|
5763
5775
|
|
|
5764
|
-
group
|
|
5776
|
+
group('real - has 53 bit resolution', () => {
|
|
5765
5777
|
let num = 0;
|
|
5766
5778
|
let i;
|
|
5767
5779
|
let newNum;
|
|
@@ -5775,7 +5787,7 @@
|
|
|
5775
5787
|
assert((MAX_SAFE_INTEGER - num) / MAX_SAFE_INTEGER < 0.01, 'Largest number is close to MAX_SAFE_INTEGER (at most 1% off).');
|
|
5776
5788
|
});
|
|
5777
5789
|
|
|
5778
|
-
group
|
|
5790
|
+
group('char - generates all ascii characters', () => {
|
|
5779
5791
|
const charSet = new Set();
|
|
5780
5792
|
const chars = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^_`abcdefghijklmnopqrstuvwxyz{|}~"';
|
|
5781
5793
|
for (let i = chars.length - 1; i >= 0; i--) {
|
|
@@ -5829,7 +5841,7 @@
|
|
|
5829
5841
|
const y = int32(gen, 0, DIAMETER);
|
|
5830
5842
|
ctx.fillRect(x, y, 1, 2);
|
|
5831
5843
|
}
|
|
5832
|
-
printCanvas
|
|
5844
|
+
printCanvas(canvas$1, DIAMETER);
|
|
5833
5845
|
};
|
|
5834
5846
|
|
|
5835
5847
|
/* istanbul ignore next */
|
|
@@ -5838,9 +5850,9 @@
|
|
|
5838
5850
|
*/
|
|
5839
5851
|
const testNumberDistributions = tc => {
|
|
5840
5852
|
skip(!isBrowser);
|
|
5841
|
-
group
|
|
5842
|
-
group
|
|
5843
|
-
group
|
|
5853
|
+
group('Xoroshiro128plus', () => printDistribution(new Xoroshiro128plus(tc.seed), tc));
|
|
5854
|
+
group('Xorshift32', () => printDistribution(new Xorshift32(tc.seed), tc));
|
|
5855
|
+
group('MT19937', () => printDistribution(new Mt19937(tc.seed), tc));
|
|
5844
5856
|
};
|
|
5845
5857
|
|
|
5846
5858
|
var prng = /*#__PURE__*/Object.freeze({
|
|
@@ -5855,7 +5867,7 @@
|
|
|
5855
5867
|
* @param {t.TestCase} tc
|
|
5856
5868
|
*/
|
|
5857
5869
|
const testMedian = tc => {
|
|
5858
|
-
assert(isNaN(median([])), 'median([]) = NaN');
|
|
5870
|
+
assert(isNaN$1(median([])), 'median([]) = NaN');
|
|
5859
5871
|
assert(median([1]) === 1, 'median([x]) = x');
|
|
5860
5872
|
assert(median([1, 2, 3]) === 2, 'median([a,b,c]) = b');
|
|
5861
5873
|
assert(median([1, 2, 3, 4]) === (2 + 3) / 2, 'median([a,b,c,d]) = (b+c)/2');
|
|
@@ -5874,7 +5886,7 @@
|
|
|
5874
5886
|
const testBitx = tc => {
|
|
5875
5887
|
for (let i = 1; i <= 32; i++) {
|
|
5876
5888
|
// @ts-ignore
|
|
5877
|
-
assert(binary[`BIT${i}`] === (1 << (i - 1)), `BIT${i}=${1 << (i - 1)}`);
|
|
5889
|
+
assert(binary$1[`BIT${i}`] === (1 << (i - 1)), `BIT${i}=${1 << (i - 1)}`);
|
|
5878
5890
|
}
|
|
5879
5891
|
};
|
|
5880
5892
|
|
|
@@ -5886,13 +5898,13 @@
|
|
|
5886
5898
|
for (let i = 1; i < 32; i++) {
|
|
5887
5899
|
const expected = ((1 << i) - 1) >>> 0;
|
|
5888
5900
|
// @ts-ignore
|
|
5889
|
-
const have = binary[`BITS${i}`];
|
|
5901
|
+
const have = binary$1[`BITS${i}`];
|
|
5890
5902
|
assert(have === expected, `BITS${i}=${have}=${expected}`);
|
|
5891
5903
|
}
|
|
5892
5904
|
assert(BITS32 === 0xFFFFFFFF);
|
|
5893
5905
|
};
|
|
5894
5906
|
|
|
5895
|
-
var binary
|
|
5907
|
+
var binary = /*#__PURE__*/Object.freeze({
|
|
5896
5908
|
__proto__: null,
|
|
5897
5909
|
testBitx: testBitx,
|
|
5898
5910
|
testBitsx: testBitsx
|
|
@@ -5909,7 +5921,7 @@
|
|
|
5909
5921
|
let lenSum = 0;
|
|
5910
5922
|
let ones = 0;
|
|
5911
5923
|
for (let i = 0; i < iterations; i++) {
|
|
5912
|
-
newNum = uint32();
|
|
5924
|
+
newNum = uint32$1();
|
|
5913
5925
|
lenSum += newNum.toString().length;
|
|
5914
5926
|
ones += newNum.toString(2).split('').filter(x => x === '1').length;
|
|
5915
5927
|
if (newNum > largest) {
|
|
@@ -5981,7 +5993,7 @@
|
|
|
5981
5993
|
* @param {Promise<T>} p
|
|
5982
5994
|
* @return {Promise<T>}
|
|
5983
5995
|
*/
|
|
5984
|
-
const failsP = p => create$
|
|
5996
|
+
const failsP = p => create$2((resolve, reject) => p.then(() => reject(create$1('Promise should fail')), resolve));
|
|
5985
5997
|
|
|
5986
5998
|
/**
|
|
5987
5999
|
* @param {t.TestCase} tc
|
|
@@ -6007,7 +6019,7 @@
|
|
|
6007
6019
|
*/
|
|
6008
6020
|
const testispromise = tc => {
|
|
6009
6021
|
assert(isPromise(new Promise(() => {})));
|
|
6010
|
-
assert(isPromise(create$
|
|
6022
|
+
assert(isPromise(create$2(() => {})));
|
|
6011
6023
|
const rej = reject();
|
|
6012
6024
|
assert(isPromise(rej));
|
|
6013
6025
|
rej.catch(() => {});
|
|
@@ -6052,7 +6064,7 @@
|
|
|
6052
6064
|
*
|
|
6053
6065
|
* @return {Queue}
|
|
6054
6066
|
*/
|
|
6055
|
-
const create
|
|
6067
|
+
const create = () => new Queue();
|
|
6056
6068
|
|
|
6057
6069
|
/**
|
|
6058
6070
|
* @param {Queue} queue
|
|
@@ -6063,7 +6075,7 @@
|
|
|
6063
6075
|
* @param {Queue} queue
|
|
6064
6076
|
* @param {QueueNode} n
|
|
6065
6077
|
*/
|
|
6066
|
-
const enqueue
|
|
6078
|
+
const enqueue = (queue, n) => {
|
|
6067
6079
|
if (queue.end !== null) {
|
|
6068
6080
|
queue.end.next = n;
|
|
6069
6081
|
queue.end = n;
|
|
@@ -6105,11 +6117,11 @@
|
|
|
6105
6117
|
/**
|
|
6106
6118
|
* @type {queue.Queue}
|
|
6107
6119
|
*/
|
|
6108
|
-
const q = create
|
|
6120
|
+
const q = create();
|
|
6109
6121
|
assert(isEmpty(q));
|
|
6110
6122
|
assert(dequeue(q) === null);
|
|
6111
6123
|
for (let i = 0; i < N; i++) {
|
|
6112
|
-
enqueue
|
|
6124
|
+
enqueue(q, new QueueItem(i));
|
|
6113
6125
|
assert(!isEmpty(q));
|
|
6114
6126
|
}
|
|
6115
6127
|
for (let i = 0; i < N; i++) {
|
|
@@ -6119,7 +6131,7 @@
|
|
|
6119
6131
|
assert(dequeue(q) === null);
|
|
6120
6132
|
};
|
|
6121
6133
|
|
|
6122
|
-
var queue
|
|
6134
|
+
var queue = /*#__PURE__*/Object.freeze({
|
|
6123
6135
|
__proto__: null,
|
|
6124
6136
|
testEnqueueDequeue: testEnqueueDequeue
|
|
6125
6137
|
});
|
|
@@ -6128,10 +6140,10 @@
|
|
|
6128
6140
|
* @param {t.TestCase} tc
|
|
6129
6141
|
*/
|
|
6130
6142
|
const testMap = tc => {
|
|
6131
|
-
const m = create();
|
|
6143
|
+
const m = create$7();
|
|
6132
6144
|
m.set(1, 2);
|
|
6133
6145
|
m.set(2, 3);
|
|
6134
|
-
assert(map(m, (value, key) => value * 2 + key).reduce(add) === 13);
|
|
6146
|
+
assert(map$3(m, (value, key) => value * 2 + key).reduce(add$1) === 13);
|
|
6135
6147
|
let numberOfWrites = 0;
|
|
6136
6148
|
const createT = () => {
|
|
6137
6149
|
numberOfWrites++;
|
|
@@ -6144,7 +6156,7 @@
|
|
|
6144
6156
|
assert(numberOfWrites === 1);
|
|
6145
6157
|
};
|
|
6146
6158
|
|
|
6147
|
-
var map
|
|
6159
|
+
var map = /*#__PURE__*/Object.freeze({
|
|
6148
6160
|
__proto__: null,
|
|
6149
6161
|
testMap: testMap
|
|
6150
6162
|
});
|
|
@@ -6156,16 +6168,16 @@
|
|
|
6156
6168
|
let currI = 0;
|
|
6157
6169
|
for (let i = 0; i < 10; i++) {
|
|
6158
6170
|
const bi = i;
|
|
6159
|
-
enqueue(() => {
|
|
6171
|
+
enqueue$1(() => {
|
|
6160
6172
|
assert(currI++ === bi);
|
|
6161
6173
|
});
|
|
6162
6174
|
}
|
|
6163
|
-
enqueue(() => {
|
|
6175
|
+
enqueue$1(() => {
|
|
6164
6176
|
assert(currI === 10);
|
|
6165
6177
|
});
|
|
6166
6178
|
assert(currI === 0);
|
|
6167
6179
|
return all([
|
|
6168
|
-
createEmpty(resolve => enqueue(resolve)),
|
|
6180
|
+
createEmpty(resolve => enqueue$1(resolve)),
|
|
6169
6181
|
until(0, () => currI === 10)
|
|
6170
6182
|
])
|
|
6171
6183
|
};
|
|
@@ -6179,7 +6191,7 @@
|
|
|
6179
6191
|
set = true;
|
|
6180
6192
|
});
|
|
6181
6193
|
timeout$1.destroy();
|
|
6182
|
-
await create$
|
|
6194
|
+
await create$2(resolve => {
|
|
6183
6195
|
timeout(10, resolve);
|
|
6184
6196
|
});
|
|
6185
6197
|
assert(set === false);
|
|
@@ -6217,7 +6229,7 @@
|
|
|
6217
6229
|
* @param {t.TestCase} tc
|
|
6218
6230
|
*/
|
|
6219
6231
|
const testIdleCallback = async tc => {
|
|
6220
|
-
await create$
|
|
6232
|
+
await create$2(resolve => {
|
|
6221
6233
|
idleCallback(resolve);
|
|
6222
6234
|
});
|
|
6223
6235
|
};
|
|
@@ -6272,18 +6284,18 @@
|
|
|
6272
6284
|
* @param {t.TestCase} tc
|
|
6273
6285
|
*/
|
|
6274
6286
|
const testPair = tc => {
|
|
6275
|
-
const ps = [create$
|
|
6287
|
+
const ps = [create$5(1, 2), create$5(3, 4), createReversed(6, 5)];
|
|
6276
6288
|
describe('Counting elements in pair list');
|
|
6277
6289
|
let countLeft = 0;
|
|
6278
6290
|
let countRight = 0;
|
|
6279
|
-
forEach(ps, (left, right) => {
|
|
6291
|
+
forEach$1(ps, (left, right) => {
|
|
6280
6292
|
countLeft += left;
|
|
6281
6293
|
countRight += right;
|
|
6282
6294
|
});
|
|
6283
6295
|
assert(countLeft === 9);
|
|
6284
6296
|
assert(countRight === 12);
|
|
6285
|
-
assert(countLeft === map$
|
|
6286
|
-
assert(countRight === map$
|
|
6297
|
+
assert(countLeft === map$2(ps, left => left).reduce(add$1));
|
|
6298
|
+
assert(countRight === map$2(ps, (left, right) => right).reduce(add$1));
|
|
6287
6299
|
};
|
|
6288
6300
|
|
|
6289
6301
|
var pair = /*#__PURE__*/Object.freeze({
|
|
@@ -6295,17 +6307,17 @@
|
|
|
6295
6307
|
* @param {t.TestCase} tc
|
|
6296
6308
|
*/
|
|
6297
6309
|
const testObject = tc => {
|
|
6298
|
-
assert(create$
|
|
6310
|
+
assert(create$4().constructor === undefined, 'object.create creates an empty object without constructor');
|
|
6299
6311
|
describe('object.equalFlat');
|
|
6300
|
-
assert(equalFlat
|
|
6301
|
-
assert(equalFlat
|
|
6302
|
-
assert(equalFlat
|
|
6303
|
-
assert(!equalFlat
|
|
6304
|
-
assert(equalFlat
|
|
6305
|
-
assert(!equalFlat
|
|
6312
|
+
assert(equalFlat({}, {}), 'comparing equal objects');
|
|
6313
|
+
assert(equalFlat({ x: 1 }, { x: 1 }), 'comparing equal objects');
|
|
6314
|
+
assert(equalFlat({ x: 'dtrn' }, { x: 'dtrn' }), 'comparing equal objects');
|
|
6315
|
+
assert(!equalFlat({ x: {} }, { x: {} }), 'flatEqual does not dive deep');
|
|
6316
|
+
assert(equalFlat({ x: undefined }, { x: undefined }), 'flatEqual handles undefined');
|
|
6317
|
+
assert(!equalFlat({ x: undefined }, { y: {} }), 'flatEqual handles undefined');
|
|
6306
6318
|
describe('object.every');
|
|
6307
|
-
assert(every
|
|
6308
|
-
assert(!every
|
|
6319
|
+
assert(every({ a: 1, b: 3 }, (v, k) => (v % 2) === 1 && k !== 'c'));
|
|
6320
|
+
assert(!every({ a: 1, b: 3, c: 5 }, (v, k) => (v % 2) === 1 && k !== 'c'));
|
|
6309
6321
|
describe('object.some');
|
|
6310
6322
|
assert(some({ a: 1, b: 3 }, (v, k) => v === 3 && k === 'b'));
|
|
6311
6323
|
assert(!some({ a: 1, b: 5 }, (v, k) => v === 3));
|
|
@@ -6313,13 +6325,13 @@
|
|
|
6313
6325
|
assert(!some({ a: 1, b: 5 }, (v, k) => false));
|
|
6314
6326
|
describe('object.forEach');
|
|
6315
6327
|
let forEachSum = 0;
|
|
6316
|
-
forEach
|
|
6328
|
+
forEach({ x: 1, y: 3 }, (v, k) => { forEachSum += v; });
|
|
6317
6329
|
assert(forEachSum === 4);
|
|
6318
6330
|
describe('object.map');
|
|
6319
|
-
assert(map$
|
|
6331
|
+
assert(map$1({ x: 1, z: 5 }, (v, k) => v).reduce(add$1) === 6);
|
|
6320
6332
|
describe('object.length');
|
|
6321
|
-
assert(length({}) === 0);
|
|
6322
|
-
assert(length({ x: 1 }) === 1);
|
|
6333
|
+
assert(length$1({}) === 0);
|
|
6334
|
+
assert(length$1({ x: 1 }) === 1);
|
|
6323
6335
|
};
|
|
6324
6336
|
|
|
6325
6337
|
var object = /*#__PURE__*/Object.freeze({
|
|
@@ -6336,7 +6348,7 @@
|
|
|
6336
6348
|
assert(abs(Number.MIN_SAFE_INTEGER) === Number.MAX_SAFE_INTEGER);
|
|
6337
6349
|
assert(abs(Number.MAX_SAFE_INTEGER) === Number.MAX_SAFE_INTEGER);
|
|
6338
6350
|
describe('math.add');
|
|
6339
|
-
assert([1, 2, 3, 4, 5].reduce(add) === 15);
|
|
6351
|
+
assert([1, 2, 3, 4, 5].reduce(add$1) === 15);
|
|
6340
6352
|
describe('math.ceil');
|
|
6341
6353
|
assert(ceil(1.5) === 2);
|
|
6342
6354
|
assert(ceil(-1.5) === -1);
|
|
@@ -6344,9 +6356,9 @@
|
|
|
6344
6356
|
assert(floor(1.5) === 1);
|
|
6345
6357
|
assert(floor(-1.5) === -2);
|
|
6346
6358
|
describe('math.isNaN');
|
|
6347
|
-
assert(isNaN(NaN));
|
|
6359
|
+
assert(isNaN$1(NaN));
|
|
6348
6360
|
// @ts-ignore
|
|
6349
|
-
assert(!isNaN(null));
|
|
6361
|
+
assert(!isNaN$1(null));
|
|
6350
6362
|
describe('math.max');
|
|
6351
6363
|
assert([1, 3, 65, 1, 314, 25, 3475, 2, 1].reduce(max) === 3475);
|
|
6352
6364
|
describe('math.min');
|
|
@@ -6366,11 +6378,11 @@
|
|
|
6366
6378
|
*/
|
|
6367
6379
|
const testNumber = tc => {
|
|
6368
6380
|
describe('isNaN');
|
|
6369
|
-
assert(isNaN
|
|
6370
|
-
assert(!isNaN
|
|
6381
|
+
assert(isNaN(NaN));
|
|
6382
|
+
assert(!isNaN(1 / 0));
|
|
6371
6383
|
// @ts-ignore
|
|
6372
|
-
assert(isNaN
|
|
6373
|
-
assert(!isNaN
|
|
6384
|
+
assert(isNaN('a' / 0));
|
|
6385
|
+
assert(!isNaN(0));
|
|
6374
6386
|
describe('isInteger');
|
|
6375
6387
|
assert(!isInteger(1 / 0));
|
|
6376
6388
|
assert(!isInteger(NaN));
|
|
@@ -6708,7 +6720,7 @@
|
|
|
6708
6720
|
* @return {string}
|
|
6709
6721
|
*/
|
|
6710
6722
|
const encodeQueryParams = params =>
|
|
6711
|
-
map$
|
|
6723
|
+
map$1(params, (val, key) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`).join('&');
|
|
6712
6724
|
|
|
6713
6725
|
/**
|
|
6714
6726
|
* @param {Object<string,any>} params
|
|
@@ -6851,6 +6863,27 @@
|
|
|
6851
6863
|
testDeepEquality: testDeepEquality
|
|
6852
6864
|
});
|
|
6853
6865
|
|
|
6866
|
+
/**
|
|
6867
|
+
* @param {t.TestCase} tc
|
|
6868
|
+
*/
|
|
6869
|
+
const testStorageModule = tc => {
|
|
6870
|
+
const s = varStorage;
|
|
6871
|
+
/**
|
|
6872
|
+
* @type {any}
|
|
6873
|
+
*/
|
|
6874
|
+
let lastEvent = null;
|
|
6875
|
+
onChange(event => {
|
|
6876
|
+
lastEvent = event;
|
|
6877
|
+
});
|
|
6878
|
+
s.setItem('key', 'value');
|
|
6879
|
+
assert(lastEvent === null);
|
|
6880
|
+
};
|
|
6881
|
+
|
|
6882
|
+
var storage = /*#__PURE__*/Object.freeze({
|
|
6883
|
+
__proto__: null,
|
|
6884
|
+
testStorageModule: testStorageModule
|
|
6885
|
+
});
|
|
6886
|
+
|
|
6854
6887
|
/* istanbul ignore if */
|
|
6855
6888
|
if (isBrowser) {
|
|
6856
6889
|
createVConsole(document.body);
|
|
@@ -6866,11 +6899,11 @@
|
|
|
6866
6899
|
indexeddb,
|
|
6867
6900
|
prng,
|
|
6868
6901
|
statistics,
|
|
6869
|
-
binary
|
|
6902
|
+
binary,
|
|
6870
6903
|
random,
|
|
6871
6904
|
promise,
|
|
6872
|
-
queue
|
|
6873
|
-
map
|
|
6905
|
+
queue,
|
|
6906
|
+
map,
|
|
6874
6907
|
eventloop,
|
|
6875
6908
|
time,
|
|
6876
6909
|
pair,
|
|
@@ -6881,7 +6914,8 @@
|
|
|
6881
6914
|
sort,
|
|
6882
6915
|
url,
|
|
6883
6916
|
metric,
|
|
6884
|
-
func
|
|
6917
|
+
func,
|
|
6918
|
+
storage
|
|
6885
6919
|
}).then(success => {
|
|
6886
6920
|
/* istanbul ignore next */
|
|
6887
6921
|
if (isNode) {
|