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.cjs
CHANGED
|
@@ -16,7 +16,7 @@ var isomorphic_js = require('isomorphic.js');
|
|
|
16
16
|
*
|
|
17
17
|
* @function
|
|
18
18
|
*/
|
|
19
|
-
const create = () => new Map();
|
|
19
|
+
const create$7 = () => new Map();
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Copy a Map object into a fresh Map object.
|
|
@@ -27,7 +27,7 @@ const create = () => new Map();
|
|
|
27
27
|
* @return {Map<X,Y>}
|
|
28
28
|
*/
|
|
29
29
|
const copy = m => {
|
|
30
|
-
const r = create();
|
|
30
|
+
const r = create$7();
|
|
31
31
|
m.forEach((v, k) => { r.set(k, v); });
|
|
32
32
|
return r
|
|
33
33
|
};
|
|
@@ -66,7 +66,7 @@ const setIfUndefined = (map, key, createT) => {
|
|
|
66
66
|
* @param {function(V,K):R} f
|
|
67
67
|
* @return {Array<R>}
|
|
68
68
|
*/
|
|
69
|
-
const map = (m, f) => {
|
|
69
|
+
const map$3 = (m, f) => {
|
|
70
70
|
const res = [];
|
|
71
71
|
for (const [key, value] of m) {
|
|
72
72
|
res.push(f(value, key));
|
|
@@ -203,7 +203,7 @@ const decodeUtf8 = utf8TextDecoder ? _decodeUtf8Native : _decodeUtf8Polyfill;
|
|
|
203
203
|
/* istanbul ignore next */
|
|
204
204
|
const undefinedToNull = v => v === undefined ? null : v;
|
|
205
205
|
|
|
206
|
-
/* global localStorage */
|
|
206
|
+
/* global localStorage, addEventListener */
|
|
207
207
|
|
|
208
208
|
/**
|
|
209
209
|
* Isomorphic variable storage.
|
|
@@ -221,10 +221,10 @@ class VarStoragePolyfill {
|
|
|
221
221
|
|
|
222
222
|
/**
|
|
223
223
|
* @param {string} key
|
|
224
|
-
* @param {any}
|
|
224
|
+
* @param {any} newValue
|
|
225
225
|
*/
|
|
226
|
-
setItem (key,
|
|
227
|
-
this.map.set(key,
|
|
226
|
+
setItem (key, newValue) {
|
|
227
|
+
this.map.set(key, newValue);
|
|
228
228
|
}
|
|
229
229
|
|
|
230
230
|
/**
|
|
@@ -240,12 +240,14 @@ class VarStoragePolyfill {
|
|
|
240
240
|
* @type {any}
|
|
241
241
|
*/
|
|
242
242
|
let _localStorage = new VarStoragePolyfill();
|
|
243
|
+
let usePolyfill = true;
|
|
243
244
|
|
|
244
245
|
try {
|
|
245
246
|
// if the same-origin rule is violated, accessing localStorage might thrown an error
|
|
246
247
|
/* istanbul ignore next */
|
|
247
248
|
if (typeof localStorage !== 'undefined') {
|
|
248
249
|
_localStorage = localStorage;
|
|
250
|
+
usePolyfill = false;
|
|
249
251
|
}
|
|
250
252
|
} catch (e) { }
|
|
251
253
|
|
|
@@ -255,6 +257,15 @@ try {
|
|
|
255
257
|
*/
|
|
256
258
|
const varStorage = _localStorage;
|
|
257
259
|
|
|
260
|
+
/* istanbul ignore next */
|
|
261
|
+
/**
|
|
262
|
+
* A polyfill for `addEventListener('storage', event => {..})` that does nothing if the polyfill is being used.
|
|
263
|
+
*
|
|
264
|
+
* @param {function({ key: string, newValue: string, oldValue: string }): void} eventHandler
|
|
265
|
+
* @function
|
|
266
|
+
*/
|
|
267
|
+
const onChange = eventHandler => usePolyfill || addEventListener('storage', /** @type {any} */ (eventHandler));
|
|
268
|
+
|
|
258
269
|
/**
|
|
259
270
|
* Isomorphic module to work access the environment (query params, env variables).
|
|
260
271
|
*
|
|
@@ -278,7 +289,7 @@ let params;
|
|
|
278
289
|
const computeParams = () => {
|
|
279
290
|
if (params === undefined) {
|
|
280
291
|
if (isNode) {
|
|
281
|
-
params = create();
|
|
292
|
+
params = create$7();
|
|
282
293
|
const pargs = process.argv;
|
|
283
294
|
let currParamName = null;
|
|
284
295
|
/* istanbul ignore next */
|
|
@@ -301,7 +312,7 @@ const computeParams = () => {
|
|
|
301
312
|
}
|
|
302
313
|
// in ReactNative for example this would not be true (unless connected to the Remote Debugger)
|
|
303
314
|
} else if (typeof location === 'object') {
|
|
304
|
-
params = create()
|
|
315
|
+
params = create$7()
|
|
305
316
|
// eslint-disable-next-line no-undef
|
|
306
317
|
;(location.search || '?').slice(1).split('&').forEach(kv => {
|
|
307
318
|
if (kv.length !== 0) {
|
|
@@ -311,7 +322,7 @@ const computeParams = () => {
|
|
|
311
322
|
}
|
|
312
323
|
});
|
|
313
324
|
} else {
|
|
314
|
-
params = create();
|
|
325
|
+
params = create$7();
|
|
315
326
|
}
|
|
316
327
|
}
|
|
317
328
|
return params
|
|
@@ -361,7 +372,7 @@ const production = hasConf('production');
|
|
|
361
372
|
*
|
|
362
373
|
* @return {Symbol}
|
|
363
374
|
*/
|
|
364
|
-
const create$
|
|
375
|
+
const create$6 = Symbol;
|
|
365
376
|
|
|
366
377
|
/**
|
|
367
378
|
* Working with value pairs.
|
|
@@ -389,7 +400,7 @@ class Pair {
|
|
|
389
400
|
* @param {R} right
|
|
390
401
|
* @return {Pair<L,R>}
|
|
391
402
|
*/
|
|
392
|
-
const create$
|
|
403
|
+
const create$5 = (left, right) => new Pair(left, right);
|
|
393
404
|
|
|
394
405
|
/**
|
|
395
406
|
* @template L,R
|
|
@@ -404,7 +415,7 @@ const createReversed = (right, left) => new Pair(left, right);
|
|
|
404
415
|
* @param {Array<Pair<L,R>>} arr
|
|
405
416
|
* @param {function(L, R):any} f
|
|
406
417
|
*/
|
|
407
|
-
const forEach = (arr, f) => arr.forEach(p => f(p.left, p.right));
|
|
418
|
+
const forEach$1 = (arr, f) => arr.forEach(p => f(p.left, p.right));
|
|
408
419
|
|
|
409
420
|
/**
|
|
410
421
|
* @template L,R,X
|
|
@@ -412,7 +423,7 @@ const forEach = (arr, f) => arr.forEach(p => f(p.left, p.right));
|
|
|
412
423
|
* @param {function(L, R):X} f
|
|
413
424
|
* @return {Array<X>}
|
|
414
425
|
*/
|
|
415
|
-
const map$
|
|
426
|
+
const map$2 = (arr, f) => arr.map(p => f(p.left, p.right));
|
|
416
427
|
|
|
417
428
|
/* eslint-env browser */
|
|
418
429
|
|
|
@@ -452,7 +463,7 @@ const createTextNode = text => doc.createTextNode(text);
|
|
|
452
463
|
*/
|
|
453
464
|
/* istanbul ignore next */
|
|
454
465
|
const setAttributes = (el, attrs) => {
|
|
455
|
-
forEach(attrs, (key, value) => {
|
|
466
|
+
forEach$1(attrs, (key, value) => {
|
|
456
467
|
if (value === false) {
|
|
457
468
|
el.removeAttribute(key);
|
|
458
469
|
} else if (value === true) {
|
|
@@ -531,7 +542,7 @@ const text = createTextNode;
|
|
|
531
542
|
* @return {string}
|
|
532
543
|
*/
|
|
533
544
|
/* istanbul ignore next */
|
|
534
|
-
const mapToStyleString = m => map(m, (value, key) => `${key}:${value};`).join('');
|
|
545
|
+
const mapToStyleString = m => map$3(m, (value, key) => `${key}:${value};`).join('');
|
|
535
546
|
|
|
536
547
|
/**
|
|
537
548
|
* @param {Node} parent
|
|
@@ -566,21 +577,21 @@ const stringify = JSON.stringify;
|
|
|
566
577
|
/**
|
|
567
578
|
* @type {Array<function>}
|
|
568
579
|
*/
|
|
569
|
-
let queue = [];
|
|
580
|
+
let queue$1 = [];
|
|
570
581
|
|
|
571
582
|
const _runQueue = () => {
|
|
572
|
-
for (let i = 0; i < queue.length; i++) {
|
|
573
|
-
queue[i]();
|
|
583
|
+
for (let i = 0; i < queue$1.length; i++) {
|
|
584
|
+
queue$1[i]();
|
|
574
585
|
}
|
|
575
|
-
queue = [];
|
|
586
|
+
queue$1 = [];
|
|
576
587
|
};
|
|
577
588
|
|
|
578
589
|
/**
|
|
579
590
|
* @param {function():void} f
|
|
580
591
|
*/
|
|
581
|
-
const enqueue = f => {
|
|
582
|
-
queue.push(f);
|
|
583
|
-
if (queue.length === 1) {
|
|
592
|
+
const enqueue$1 = f => {
|
|
593
|
+
queue$1.push(f);
|
|
594
|
+
if (queue$1.length === 1) {
|
|
584
595
|
setTimeout(_runQueue, 0);
|
|
585
596
|
}
|
|
586
597
|
};
|
|
@@ -667,7 +678,7 @@ const log10 = Math.log10;
|
|
|
667
678
|
* @param {number} b
|
|
668
679
|
* @return {number} The sum of a and b
|
|
669
680
|
*/
|
|
670
|
-
const add = (a, b) => a + b;
|
|
681
|
+
const add$1 = (a, b) => a + b;
|
|
671
682
|
|
|
672
683
|
/**
|
|
673
684
|
* @function
|
|
@@ -685,7 +696,7 @@ const min = (a, b) => a < b ? a : b;
|
|
|
685
696
|
*/
|
|
686
697
|
const max = (a, b) => a > b ? a : b;
|
|
687
698
|
|
|
688
|
-
const isNaN = Number.isNaN;
|
|
699
|
+
const isNaN$1 = Number.isNaN;
|
|
689
700
|
/**
|
|
690
701
|
* Base 10 exponential function. Returns the value of 10 raised to the power of pow.
|
|
691
702
|
*
|
|
@@ -818,7 +829,7 @@ const appendTo = (dest, src) => {
|
|
|
818
829
|
* @param {function(ITEM, number, Array<ITEM>):boolean} f
|
|
819
830
|
* @return {boolean}
|
|
820
831
|
*/
|
|
821
|
-
const every = (arr, f) => arr.every(f);
|
|
832
|
+
const every$1 = (arr, f) => arr.every(f);
|
|
822
833
|
|
|
823
834
|
/**
|
|
824
835
|
* @template ELEM
|
|
@@ -827,7 +838,7 @@ const every = (arr, f) => arr.every(f);
|
|
|
827
838
|
* @param {Array<ELEM>} b
|
|
828
839
|
* @return {boolean}
|
|
829
840
|
*/
|
|
830
|
-
const equalFlat = (a, b) => a.length === b.length && every(a, (item, index) => item === b[index]);
|
|
841
|
+
const equalFlat$1 = (a, b) => a.length === b.length && every$1(a, (item, index) => item === b[index]);
|
|
831
842
|
|
|
832
843
|
/**
|
|
833
844
|
* @template ELEM
|
|
@@ -845,7 +856,7 @@ const flatten = arr => arr.reduce((acc, val) => acc.concat(val), []);
|
|
|
845
856
|
/**
|
|
846
857
|
* @return {Object<string,any>} obj
|
|
847
858
|
*/
|
|
848
|
-
const create$
|
|
859
|
+
const create$4 = () => Object.create(null);
|
|
849
860
|
|
|
850
861
|
/**
|
|
851
862
|
* Object.assign
|
|
@@ -861,7 +872,7 @@ const keys = Object.keys;
|
|
|
861
872
|
* @param {Object<string,any>} obj
|
|
862
873
|
* @param {function(any,string):any} f
|
|
863
874
|
*/
|
|
864
|
-
const forEach
|
|
875
|
+
const forEach = (obj, f) => {
|
|
865
876
|
for (const key in obj) {
|
|
866
877
|
f(obj[key], key);
|
|
867
878
|
}
|
|
@@ -873,7 +884,7 @@ const forEach$1 = (obj, f) => {
|
|
|
873
884
|
* @param {function(any,string):R} f
|
|
874
885
|
* @return {Array<R>}
|
|
875
886
|
*/
|
|
876
|
-
const map$
|
|
887
|
+
const map$1 = (obj, f) => {
|
|
877
888
|
const results = [];
|
|
878
889
|
for (const key in obj) {
|
|
879
890
|
results.push(f(obj[key], key));
|
|
@@ -885,7 +896,7 @@ const map$2 = (obj, f) => {
|
|
|
885
896
|
* @param {Object<string,any>} obj
|
|
886
897
|
* @return {number}
|
|
887
898
|
*/
|
|
888
|
-
const length = obj => keys(obj).length;
|
|
899
|
+
const length$1 = obj => keys(obj).length;
|
|
889
900
|
|
|
890
901
|
/**
|
|
891
902
|
* @param {Object<string,any>} obj
|
|
@@ -906,7 +917,7 @@ const some = (obj, f) => {
|
|
|
906
917
|
* @param {function(any,string):boolean} f
|
|
907
918
|
* @return {boolean}
|
|
908
919
|
*/
|
|
909
|
-
const every
|
|
920
|
+
const every = (obj, f) => {
|
|
910
921
|
for (const key in obj) {
|
|
911
922
|
if (!f(obj[key], key)) {
|
|
912
923
|
return false
|
|
@@ -929,7 +940,7 @@ const hasProperty = (obj, key) => Object.prototype.hasOwnProperty.call(obj, key)
|
|
|
929
940
|
* @param {Object<string,any>} b
|
|
930
941
|
* @return {boolean}
|
|
931
942
|
*/
|
|
932
|
-
const equalFlat
|
|
943
|
+
const equalFlat = (a, b) => a === b || (length$1(a) === length$1(b) && every(a, (val, key) => (val !== undefined || hasProperty(b, key)) && b[key] === val));
|
|
933
944
|
|
|
934
945
|
/**
|
|
935
946
|
* Common functions and function call helpers.
|
|
@@ -953,7 +964,7 @@ const equalityStrict = (a, b) => a === b;
|
|
|
953
964
|
* @param {Array<T>|object} b
|
|
954
965
|
* @return {boolean}
|
|
955
966
|
*/
|
|
956
|
-
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
|
|
967
|
+
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))));
|
|
957
968
|
|
|
958
969
|
/**
|
|
959
970
|
* @param {any} a
|
|
@@ -1009,7 +1020,7 @@ const equalityDeep = (a, b) => {
|
|
|
1009
1020
|
break
|
|
1010
1021
|
}
|
|
1011
1022
|
case Object:
|
|
1012
|
-
if (length(a) !== length(b)) {
|
|
1023
|
+
if (length$1(a) !== length$1(b)) {
|
|
1013
1024
|
return false
|
|
1014
1025
|
}
|
|
1015
1026
|
for (const key in a) {
|
|
@@ -1040,29 +1051,29 @@ const equalityDeep = (a, b) => {
|
|
|
1040
1051
|
* @module logging
|
|
1041
1052
|
*/
|
|
1042
1053
|
|
|
1043
|
-
const BOLD = create$
|
|
1044
|
-
const UNBOLD = create$
|
|
1045
|
-
const BLUE = create$
|
|
1046
|
-
const GREY = create$
|
|
1047
|
-
const GREEN = create$
|
|
1048
|
-
const RED = create$
|
|
1049
|
-
const PURPLE = create$
|
|
1050
|
-
const ORANGE = create$
|
|
1051
|
-
const UNCOLOR = create$
|
|
1054
|
+
const BOLD = create$6();
|
|
1055
|
+
const UNBOLD = create$6();
|
|
1056
|
+
const BLUE = create$6();
|
|
1057
|
+
const GREY = create$6();
|
|
1058
|
+
const GREEN = create$6();
|
|
1059
|
+
const RED = create$6();
|
|
1060
|
+
const PURPLE = create$6();
|
|
1061
|
+
const ORANGE = create$6();
|
|
1062
|
+
const UNCOLOR = create$6();
|
|
1052
1063
|
|
|
1053
1064
|
/**
|
|
1054
1065
|
* @type {Object<Symbol,pair.Pair<string,string>>}
|
|
1055
1066
|
*/
|
|
1056
1067
|
const _browserStyleMap = {
|
|
1057
|
-
[BOLD]: create$
|
|
1058
|
-
[UNBOLD]: create$
|
|
1059
|
-
[BLUE]: create$
|
|
1060
|
-
[GREEN]: create$
|
|
1061
|
-
[GREY]: create$
|
|
1062
|
-
[RED]: create$
|
|
1063
|
-
[PURPLE]: create$
|
|
1064
|
-
[ORANGE]: create$
|
|
1065
|
-
[UNCOLOR]: create$
|
|
1068
|
+
[BOLD]: create$5('font-weight', 'bold'),
|
|
1069
|
+
[UNBOLD]: create$5('font-weight', 'normal'),
|
|
1070
|
+
[BLUE]: create$5('color', 'blue'),
|
|
1071
|
+
[GREEN]: create$5('color', 'green'),
|
|
1072
|
+
[GREY]: create$5('color', 'grey'),
|
|
1073
|
+
[RED]: create$5('color', 'red'),
|
|
1074
|
+
[PURPLE]: create$5('color', 'purple'),
|
|
1075
|
+
[ORANGE]: create$5('color', 'orange'), // not well supported in chrome when debugging node with inspector - TODO: deprecate
|
|
1076
|
+
[UNCOLOR]: create$5('color', 'black')
|
|
1066
1077
|
};
|
|
1067
1078
|
|
|
1068
1079
|
const _nodeStyleMap = {
|
|
@@ -1085,7 +1096,7 @@ const _nodeStyleMap = {
|
|
|
1085
1096
|
const computeBrowserLoggingArgs = args => {
|
|
1086
1097
|
const strBuilder = [];
|
|
1087
1098
|
const styles = [];
|
|
1088
|
-
const currentStyle = create();
|
|
1099
|
+
const currentStyle = create$7();
|
|
1089
1100
|
/**
|
|
1090
1101
|
* @type {Array<string|Object|number>}
|
|
1091
1102
|
*/
|
|
@@ -1214,7 +1225,7 @@ const printImgBase64 = (base64, height) => printImg(`data:image/gif;base64,${bas
|
|
|
1214
1225
|
/**
|
|
1215
1226
|
* @param {Array<string|Symbol|Object|number>} args
|
|
1216
1227
|
*/
|
|
1217
|
-
const group = (...args) => {
|
|
1228
|
+
const group$1 = (...args) => {
|
|
1218
1229
|
console.group(...computeLoggingArgs(args));
|
|
1219
1230
|
/* istanbul ignore next */
|
|
1220
1231
|
vconsoles.forEach(vc => vc.group(args));
|
|
@@ -1240,7 +1251,7 @@ const groupEnd = () => {
|
|
|
1240
1251
|
* @param {HTMLCanvasElement} canvas
|
|
1241
1252
|
* @param {number} height
|
|
1242
1253
|
*/
|
|
1243
|
-
const printCanvas = (canvas, height) => printImg(canvas.toDataURL(), height);
|
|
1254
|
+
const printCanvas$1 = (canvas, height) => printImg(canvas.toDataURL(), height);
|
|
1244
1255
|
|
|
1245
1256
|
const vconsoles = new Set();
|
|
1246
1257
|
|
|
@@ -1263,7 +1274,7 @@ const _computeLineSpans = args => {
|
|
|
1263
1274
|
} else {
|
|
1264
1275
|
if (arg.constructor === String || arg.constructor === Number) {
|
|
1265
1276
|
// @ts-ignore
|
|
1266
|
-
const span = element('span', [create$
|
|
1277
|
+
const span = element('span', [create$5('style', mapToStyleString(currentStyle))], [text(arg)]);
|
|
1267
1278
|
if (span.innerHTML === '') {
|
|
1268
1279
|
span.innerHTML = ' ';
|
|
1269
1280
|
}
|
|
@@ -1308,11 +1319,11 @@ class VConsole {
|
|
|
1308
1319
|
* @param {boolean} collapsed
|
|
1309
1320
|
*/
|
|
1310
1321
|
group (args, collapsed = false) {
|
|
1311
|
-
enqueue(() => {
|
|
1312
|
-
const triangleDown = element('span', [create$
|
|
1313
|
-
const triangleRight = element('span', [create$
|
|
1314
|
-
const content = element('div', [create$
|
|
1315
|
-
const nextContainer = element('div', [create$
|
|
1322
|
+
enqueue$1(() => {
|
|
1323
|
+
const triangleDown = element('span', [create$5('hidden', collapsed), create$5('style', 'color:grey;font-size:120%;')], [text('▼')]);
|
|
1324
|
+
const triangleRight = element('span', [create$5('hidden', !collapsed), create$5('style', 'color:grey;font-size:125%;')], [text('▶')]);
|
|
1325
|
+
const content = element('div', [create$5('style', `${lineStyle};padding-left:${this.depth * 10}px`)], [triangleDown, triangleRight, text(' ')].concat(_computeLineSpans(args)));
|
|
1326
|
+
const nextContainer = element('div', [create$5('hidden', collapsed)]);
|
|
1316
1327
|
const nextLine = element('div', [], [content, nextContainer]);
|
|
1317
1328
|
append(this.ccontainer, [nextLine]);
|
|
1318
1329
|
this.ccontainer = nextContainer;
|
|
@@ -1334,7 +1345,7 @@ class VConsole {
|
|
|
1334
1345
|
}
|
|
1335
1346
|
|
|
1336
1347
|
groupEnd () {
|
|
1337
|
-
enqueue(() => {
|
|
1348
|
+
enqueue$1(() => {
|
|
1338
1349
|
if (this.depth > 0) {
|
|
1339
1350
|
this.depth--;
|
|
1340
1351
|
// @ts-ignore
|
|
@@ -1347,8 +1358,8 @@ class VConsole {
|
|
|
1347
1358
|
* @param {Array<string|Symbol|Object|number>} args
|
|
1348
1359
|
*/
|
|
1349
1360
|
print (args) {
|
|
1350
|
-
enqueue(() => {
|
|
1351
|
-
append(this.ccontainer, [element('div', [create$
|
|
1361
|
+
enqueue$1(() => {
|
|
1362
|
+
append(this.ccontainer, [element('div', [create$5('style', `${lineStyle};padding-left:${this.depth * 10}px`)], _computeLineSpans(args))]);
|
|
1352
1363
|
});
|
|
1353
1364
|
}
|
|
1354
1365
|
|
|
@@ -1364,8 +1375,8 @@ class VConsole {
|
|
|
1364
1375
|
* @param {number} height
|
|
1365
1376
|
*/
|
|
1366
1377
|
printImg (url, height) {
|
|
1367
|
-
enqueue(() => {
|
|
1368
|
-
append(this.ccontainer, [element('img', [create$
|
|
1378
|
+
enqueue$1(() => {
|
|
1379
|
+
append(this.ccontainer, [element('img', [create$5('src', url), create$5('height', `${round(height * 1.5)}px`)])]);
|
|
1369
1380
|
});
|
|
1370
1381
|
}
|
|
1371
1382
|
|
|
@@ -1373,13 +1384,13 @@ class VConsole {
|
|
|
1373
1384
|
* @param {Node} node
|
|
1374
1385
|
*/
|
|
1375
1386
|
printDom (node) {
|
|
1376
|
-
enqueue(() => {
|
|
1387
|
+
enqueue$1(() => {
|
|
1377
1388
|
append(this.ccontainer, [node]);
|
|
1378
1389
|
});
|
|
1379
1390
|
}
|
|
1380
1391
|
|
|
1381
1392
|
destroy () {
|
|
1382
|
-
enqueue(() => {
|
|
1393
|
+
enqueue$1(() => {
|
|
1383
1394
|
vconsoles.delete(this);
|
|
1384
1395
|
});
|
|
1385
1396
|
}
|
|
@@ -1489,12 +1500,12 @@ const simpleDiffArray = (a, b, compare = equalityStrict) => {
|
|
|
1489
1500
|
};
|
|
1490
1501
|
|
|
1491
1502
|
/* istanbul ignore next */
|
|
1492
|
-
const uint32 = () => new Uint32Array(isomorphic_js.cryptoRandomBuffer(4))[0];
|
|
1503
|
+
const uint32$1 = () => new Uint32Array(isomorphic_js.cryptoRandomBuffer(4))[0];
|
|
1493
1504
|
|
|
1494
1505
|
// @ts-ignore
|
|
1495
1506
|
const uuidv4Template = [1e7] + -1e3 + -4e3 + -8e3 + -1e11;
|
|
1496
1507
|
const uuidv4 = () => uuidv4Template.replace(/[018]/g, /** @param {number} c */ c =>
|
|
1497
|
-
(c ^ uint32() & 15 >> c / 4).toString(16)
|
|
1508
|
+
(c ^ uint32$1() & 15 >> c / 4).toString(16)
|
|
1498
1509
|
);
|
|
1499
1510
|
|
|
1500
1511
|
/* eslint-env browser */
|
|
@@ -1588,7 +1599,7 @@ const BITS31 = 0x7FFFFFFF;
|
|
|
1588
1599
|
*/
|
|
1589
1600
|
const BITS32 = 0xFFFFFFFF;
|
|
1590
1601
|
|
|
1591
|
-
var binary = /*#__PURE__*/Object.freeze({
|
|
1602
|
+
var binary$1 = /*#__PURE__*/Object.freeze({
|
|
1592
1603
|
__proto__: null,
|
|
1593
1604
|
BIT1: BIT1,
|
|
1594
1605
|
BIT2: BIT2,
|
|
@@ -1821,7 +1832,7 @@ const HIGHEST_INT32 = BITS31;
|
|
|
1821
1832
|
|
|
1822
1833
|
/* istanbul ignore next */
|
|
1823
1834
|
const isInteger = Number.isInteger || (num => typeof num === 'number' && isFinite(num) && floor(num) === num);
|
|
1824
|
-
const isNaN
|
|
1835
|
+
const isNaN = Number.isNaN;
|
|
1825
1836
|
|
|
1826
1837
|
/**
|
|
1827
1838
|
* Efficient schema-less binary encoding with support for variable length encoding.
|
|
@@ -1878,7 +1889,7 @@ const createEncoder = () => new Encoder();
|
|
|
1878
1889
|
* @param {Encoder} encoder
|
|
1879
1890
|
* @return {number}
|
|
1880
1891
|
*/
|
|
1881
|
-
const length
|
|
1892
|
+
const length = encoder => {
|
|
1882
1893
|
let len = encoder.cpos;
|
|
1883
1894
|
for (let i = 0; i < encoder.bufs.length; i++) {
|
|
1884
1895
|
len += encoder.bufs[i].length;
|
|
@@ -1894,7 +1905,7 @@ const length$1 = encoder => {
|
|
|
1894
1905
|
* @return {Uint8Array} The created ArrayBuffer.
|
|
1895
1906
|
*/
|
|
1896
1907
|
const toUint8Array = encoder => {
|
|
1897
|
-
const uint8arr = new Uint8Array(length
|
|
1908
|
+
const uint8arr = new Uint8Array(length(encoder));
|
|
1898
1909
|
let curPos = 0;
|
|
1899
1910
|
for (let i = 0; i < encoder.bufs.length; i++) {
|
|
1900
1911
|
const d = encoder.bufs[i];
|
|
@@ -2193,19 +2204,19 @@ const writeOnDataView = (encoder, len) => {
|
|
|
2193
2204
|
* @param {Encoder} encoder
|
|
2194
2205
|
* @param {number} num
|
|
2195
2206
|
*/
|
|
2196
|
-
const writeFloat32 = (encoder, num) => writeOnDataView(encoder, 4).setFloat32(0, num);
|
|
2207
|
+
const writeFloat32 = (encoder, num) => writeOnDataView(encoder, 4).setFloat32(0, num, false);
|
|
2197
2208
|
|
|
2198
2209
|
/**
|
|
2199
2210
|
* @param {Encoder} encoder
|
|
2200
2211
|
* @param {number} num
|
|
2201
2212
|
*/
|
|
2202
|
-
const writeFloat64 = (encoder, num) => writeOnDataView(encoder, 8).setFloat64(0, num);
|
|
2213
|
+
const writeFloat64 = (encoder, num) => writeOnDataView(encoder, 8).setFloat64(0, num, false);
|
|
2203
2214
|
|
|
2204
2215
|
/**
|
|
2205
2216
|
* @param {Encoder} encoder
|
|
2206
2217
|
* @param {bigint} num
|
|
2207
2218
|
*/
|
|
2208
|
-
const writeBigInt64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigInt64(0, num);
|
|
2219
|
+
const writeBigInt64 = (encoder, num) => /** @type {any} */ (writeOnDataView(encoder, 8)).setBigInt64(0, num, false);
|
|
2209
2220
|
|
|
2210
2221
|
const floatTestBed = new DataView(new ArrayBuffer(4));
|
|
2211
2222
|
/**
|
|
@@ -2443,6 +2454,7 @@ class RleIntDiffEncoder extends Encoder {
|
|
|
2443
2454
|
* @param {UintOptRleEncoder} encoder
|
|
2444
2455
|
*/
|
|
2445
2456
|
const flushUintOptRleEncoder = encoder => {
|
|
2457
|
+
/* istanbul ignore else */
|
|
2446
2458
|
if (encoder.count > 0) {
|
|
2447
2459
|
// flush counter, unless this is the first value (count = 0)
|
|
2448
2460
|
// case 1: just a single value. set sign to positive
|
|
@@ -2783,7 +2795,7 @@ const readUint32BigEndian = decoder => {
|
|
|
2783
2795
|
};
|
|
2784
2796
|
|
|
2785
2797
|
/**
|
|
2786
|
-
* Look ahead without incrementing position
|
|
2798
|
+
* Look ahead without incrementing the position
|
|
2787
2799
|
* to the next byte and read it as unsigned integer.
|
|
2788
2800
|
*
|
|
2789
2801
|
* @function
|
|
@@ -2793,7 +2805,7 @@ const readUint32BigEndian = decoder => {
|
|
|
2793
2805
|
const peekUint8 = decoder => decoder.arr[decoder.pos];
|
|
2794
2806
|
|
|
2795
2807
|
/**
|
|
2796
|
-
* Look ahead without incrementing position
|
|
2808
|
+
* Look ahead without incrementing the position
|
|
2797
2809
|
* to the next byte and read it as unsigned integer.
|
|
2798
2810
|
*
|
|
2799
2811
|
* @function
|
|
@@ -2805,7 +2817,7 @@ const peekUint16 = decoder =>
|
|
|
2805
2817
|
(decoder.arr[decoder.pos + 1] << 8);
|
|
2806
2818
|
|
|
2807
2819
|
/**
|
|
2808
|
-
* Look ahead without incrementing position
|
|
2820
|
+
* Look ahead without incrementing the position
|
|
2809
2821
|
* to the next byte and read it as unsigned integer.
|
|
2810
2822
|
*
|
|
2811
2823
|
* @function
|
|
@@ -2851,7 +2863,7 @@ const readVarUint = decoder => {
|
|
|
2851
2863
|
* 1/8th of the storage is used as encoding overhead.
|
|
2852
2864
|
* * numbers < 2^7 is stored in one bytlength
|
|
2853
2865
|
* * numbers < 2^14 is stored in two bylength
|
|
2854
|
-
* @todo This should probably create the inverse ~num if
|
|
2866
|
+
* @todo This should probably create the inverse ~num if number is negative - but this would be a breaking change.
|
|
2855
2867
|
*
|
|
2856
2868
|
* @function
|
|
2857
2869
|
* @param {Decoder} decoder
|
|
@@ -2974,17 +2986,17 @@ const readFromDataView = (decoder, len) => {
|
|
|
2974
2986
|
/**
|
|
2975
2987
|
* @param {Decoder} decoder
|
|
2976
2988
|
*/
|
|
2977
|
-
const readFloat32 = decoder => readFromDataView(decoder, 4).getFloat32(0);
|
|
2989
|
+
const readFloat32 = decoder => readFromDataView(decoder, 4).getFloat32(0, false);
|
|
2978
2990
|
|
|
2979
2991
|
/**
|
|
2980
2992
|
* @param {Decoder} decoder
|
|
2981
2993
|
*/
|
|
2982
|
-
const readFloat64 = decoder => readFromDataView(decoder, 8).getFloat64(0);
|
|
2994
|
+
const readFloat64 = decoder => readFromDataView(decoder, 8).getFloat64(0, false);
|
|
2983
2995
|
|
|
2984
2996
|
/**
|
|
2985
2997
|
* @param {Decoder} decoder
|
|
2986
2998
|
*/
|
|
2987
|
-
const readBigInt64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigInt64(0);
|
|
2999
|
+
const readBigInt64 = decoder => /** @type {any} */ (readFromDataView(decoder, 8)).getBigInt64(0, false);
|
|
2988
3000
|
|
|
2989
3001
|
/**
|
|
2990
3002
|
* @type {Array<function(Decoder):any>}
|
|
@@ -3348,7 +3360,7 @@ const DefaultPRNG = Xoroshiro128plus;
|
|
|
3348
3360
|
* @param {number} seed A positive 32bit integer. Do not use negative numbers.
|
|
3349
3361
|
* @return {PRNG}
|
|
3350
3362
|
*/
|
|
3351
|
-
const create$
|
|
3363
|
+
const create$3 = seed => new DefaultPRNG(seed);
|
|
3352
3364
|
|
|
3353
3365
|
/**
|
|
3354
3366
|
* Generates a single random bool.
|
|
@@ -3396,7 +3408,7 @@ const int32 = (gen, min, max) => floor(gen.next() * (max + 1 - min) + min);
|
|
|
3396
3408
|
* @param {Number} max The upper bound of the allowed return values (inclusive).
|
|
3397
3409
|
* @return {Number} A random integer on [min, max]
|
|
3398
3410
|
*/
|
|
3399
|
-
const uint32
|
|
3411
|
+
const uint32 = (gen, min, max) => int32(gen, min, max) >>> 0;
|
|
3400
3412
|
|
|
3401
3413
|
/**
|
|
3402
3414
|
* @deprecated
|
|
@@ -3519,7 +3531,7 @@ const median = arr => arr.length === 0 ? NaN : (arr.length % 2 === 1 ? arr[(arr.
|
|
|
3519
3531
|
* @param {Array<number>} arr
|
|
3520
3532
|
* @return {number}
|
|
3521
3533
|
*/
|
|
3522
|
-
const average = arr => arr.reduce(add, 0) / arr.length;
|
|
3534
|
+
const average = arr => arr.reduce(add$1, 0) / arr.length;
|
|
3523
3535
|
|
|
3524
3536
|
/**
|
|
3525
3537
|
* Utility helpers to work with promises.
|
|
@@ -3538,7 +3550,7 @@ const average = arr => arr.reduce(add, 0) / arr.length;
|
|
|
3538
3550
|
* @param {function(PromiseResolve<T>,function(Error):void):any} f
|
|
3539
3551
|
* @return {Promise<T>}
|
|
3540
3552
|
*/
|
|
3541
|
-
const create$
|
|
3553
|
+
const create$2 = f => /** @type {Promise<T>} */ (new Promise(f));
|
|
3542
3554
|
|
|
3543
3555
|
/**
|
|
3544
3556
|
* @param {function(function():void,function(Error):void):void} f
|
|
@@ -3575,7 +3587,7 @@ const resolve = res => Promise.resolve(res);
|
|
|
3575
3587
|
* @param {number} [intervalResolution]
|
|
3576
3588
|
* @return {Promise<void>}
|
|
3577
3589
|
*/
|
|
3578
|
-
const until = (timeout, check, intervalResolution = 10) => create$
|
|
3590
|
+
const until = (timeout, check, intervalResolution = 10) => create$2((resolve, reject) => {
|
|
3579
3591
|
const startTime = getUnixTime();
|
|
3580
3592
|
const hasTimeout = timeout > 0;
|
|
3581
3593
|
const untilInterval = () => {
|
|
@@ -3597,7 +3609,7 @@ const until = (timeout, check, intervalResolution = 10) => create$5((resolve, re
|
|
|
3597
3609
|
* @param {number} timeout
|
|
3598
3610
|
* @return {Promise<undefined>}
|
|
3599
3611
|
*/
|
|
3600
|
-
const wait = timeout => create$
|
|
3612
|
+
const wait = timeout => create$2((resolve, reject) => setTimeout(resolve, timeout));
|
|
3601
3613
|
|
|
3602
3614
|
/**
|
|
3603
3615
|
* Checks if an object is a promise using ducktyping.
|
|
@@ -3691,7 +3703,7 @@ class TestCase {
|
|
|
3691
3703
|
/* istanbul ignore else */
|
|
3692
3704
|
if (this._seed === null) {
|
|
3693
3705
|
/* istanbul ignore next */
|
|
3694
|
-
this._seed = envSeed === null ? uint32() : envSeed;
|
|
3706
|
+
this._seed = envSeed === null ? uint32$1() : envSeed;
|
|
3695
3707
|
}
|
|
3696
3708
|
return this._seed
|
|
3697
3709
|
}
|
|
@@ -3704,13 +3716,13 @@ class TestCase {
|
|
|
3704
3716
|
get prng () {
|
|
3705
3717
|
/* istanbul ignore else */
|
|
3706
3718
|
if (this._prng === null) {
|
|
3707
|
-
this._prng = create$
|
|
3719
|
+
this._prng = create$3(this.seed);
|
|
3708
3720
|
}
|
|
3709
3721
|
return this._prng
|
|
3710
3722
|
}
|
|
3711
3723
|
}
|
|
3712
3724
|
|
|
3713
|
-
const
|
|
3725
|
+
const repetitionTime = Number(getParam('--repetition-time', '50'));
|
|
3714
3726
|
/* istanbul ignore next */
|
|
3715
3727
|
const testFilter = hasParam('--filter') ? getParam('--filter', '') : null;
|
|
3716
3728
|
|
|
@@ -3740,7 +3752,7 @@ const run = async (moduleName, name, f, i, numberOfTests) => {
|
|
|
3740
3752
|
if (testFilter === null) {
|
|
3741
3753
|
groupCollapsed(...groupArgs);
|
|
3742
3754
|
} else {
|
|
3743
|
-
group(...groupArgs);
|
|
3755
|
+
group$1(...groupArgs);
|
|
3744
3756
|
}
|
|
3745
3757
|
const times = [];
|
|
3746
3758
|
const start = isomorphic_js.performance.now();
|
|
@@ -3759,12 +3771,12 @@ const run = async (moduleName, name, f, i, numberOfTests) => {
|
|
|
3759
3771
|
const currTime = isomorphic_js.performance.now();
|
|
3760
3772
|
times.push(currTime - lastTime);
|
|
3761
3773
|
lastTime = currTime;
|
|
3762
|
-
if (repeat && err === null && (lastTime - start) <
|
|
3774
|
+
if (repeat && err === null && (lastTime - start) < repetitionTime) {
|
|
3763
3775
|
tc.resetSeed();
|
|
3764
3776
|
} else {
|
|
3765
3777
|
break
|
|
3766
3778
|
}
|
|
3767
|
-
} while (err === null && (lastTime - start) <
|
|
3779
|
+
} while (err === null && (lastTime - start) < repetitionTime)
|
|
3768
3780
|
isomorphic_js.performance.mark(`${name}-end`);
|
|
3769
3781
|
/* istanbul ignore if */
|
|
3770
3782
|
if (err !== null && err.constructor !== SkipError) {
|
|
@@ -3780,7 +3792,7 @@ const run = async (moduleName, name, f, i, numberOfTests) => {
|
|
|
3780
3792
|
? ` - ${window.location.href}?filter=\\[${i + 1}/${tc._seed === null ? '' : `&seed=${tc._seed}`}`
|
|
3781
3793
|
: `\nrepeat: npm run test -- --filter "\\[${i + 1}/" ${tc._seed === null ? '' : `--seed ${tc._seed}`}`;
|
|
3782
3794
|
const timeInfo = (repeat && err === null)
|
|
3783
|
-
? ` - ${times.length}
|
|
3795
|
+
? ` - ${times.length} repetitions in ${humanizeDuration(duration)} (best: ${humanizeDuration(times[0])}, worst: ${humanizeDuration(last(times))}, median: ${humanizeDuration(median(times))}, average: ${humanizeDuration(average(times))})`
|
|
3784
3796
|
: ` in ${humanizeDuration(duration)}`;
|
|
3785
3797
|
if (err !== null) {
|
|
3786
3798
|
/* istanbul ignore else */
|
|
@@ -3822,7 +3834,7 @@ const describe = (description, info = '') => print(BLUE, description, ' ', GREY,
|
|
|
3822
3834
|
*/
|
|
3823
3835
|
const info = info => describe('', info);
|
|
3824
3836
|
|
|
3825
|
-
const printCanvas
|
|
3837
|
+
const printCanvas = printCanvas$1;
|
|
3826
3838
|
|
|
3827
3839
|
/**
|
|
3828
3840
|
* Group outputs in a collapsible category.
|
|
@@ -3842,8 +3854,8 @@ const printCanvas$1 = printCanvas;
|
|
|
3842
3854
|
* @param {string} description
|
|
3843
3855
|
* @param {function(void):void} f
|
|
3844
3856
|
*/
|
|
3845
|
-
const group
|
|
3846
|
-
group(BLUE, description);
|
|
3857
|
+
const group = (description, f) => {
|
|
3858
|
+
group$1(BLUE, description);
|
|
3847
3859
|
try {
|
|
3848
3860
|
f();
|
|
3849
3861
|
} finally {
|
|
@@ -3870,7 +3882,7 @@ const group$1 = (description, f) => {
|
|
|
3870
3882
|
* @param {function(void):Promise<any>} f
|
|
3871
3883
|
*/
|
|
3872
3884
|
const groupAsync = async (description, f) => {
|
|
3873
|
-
group(BLUE, description);
|
|
3885
|
+
group$1(BLUE, description);
|
|
3874
3886
|
try {
|
|
3875
3887
|
await f();
|
|
3876
3888
|
} finally {
|
|
@@ -3978,7 +3990,7 @@ const compareStrings = (a, b, m = 'Strings match') => {
|
|
|
3978
3990
|
* @param {string} [m]
|
|
3979
3991
|
* @throws {TestError} Throws if test fails
|
|
3980
3992
|
*/
|
|
3981
|
-
const compareObjects = (a, b, m = 'Objects match') => { equalFlat
|
|
3993
|
+
const compareObjects = (a, b, m = 'Objects match') => { equalFlat(a, b) || fail(m); };
|
|
3982
3994
|
|
|
3983
3995
|
/**
|
|
3984
3996
|
* @param {any} constructor
|
|
@@ -4062,10 +4074,10 @@ const _compare = (a, b, path, message, customCompare) => {
|
|
|
4062
4074
|
break
|
|
4063
4075
|
}
|
|
4064
4076
|
case Object:
|
|
4065
|
-
if (length(a) !== length(b)) {
|
|
4077
|
+
if (length$1(a) !== length$1(b)) {
|
|
4066
4078
|
_failMessage(message, 'Objects have a different number of attributes', path);
|
|
4067
4079
|
}
|
|
4068
|
-
forEach
|
|
4080
|
+
forEach(a, (value, key) => {
|
|
4069
4081
|
if (!hasProperty(b, key)) {
|
|
4070
4082
|
_failMessage(message, `Property ${path} does not exist on second argument`, path);
|
|
4071
4083
|
}
|
|
@@ -4128,7 +4140,7 @@ const fails = f => {
|
|
|
4128
4140
|
* @param {Object<string, Object<string, function(TestCase):void|Promise<any>>>} tests
|
|
4129
4141
|
*/
|
|
4130
4142
|
const runTests = async tests => {
|
|
4131
|
-
const numberOfTests = map$
|
|
4143
|
+
const numberOfTests = map$1(tests, mod => map$1(mod, f => /* istanbul ignore next */ f ? 1 : 0).reduce(add$1, 0)).reduce(add$1, 0);
|
|
4132
4144
|
let successfulTests = 0;
|
|
4133
4145
|
let testnumber = 0;
|
|
4134
4146
|
const start = isomorphic_js.performance.now();
|
|
@@ -4317,8 +4329,8 @@ let genAnyLookupTable = [
|
|
|
4317
4329
|
gen => false, // TYPE 120
|
|
4318
4330
|
gen => utf16String(gen), // TYPE 119
|
|
4319
4331
|
(gen, depth, toJsonCompatible) => ({ val: genAny(gen, depth + 1, toJsonCompatible) }), // TYPE 118
|
|
4320
|
-
(gen, depth, toJsonCompatible) => Array.from({ length: uint32
|
|
4321
|
-
gen => uint8Array(gen, uint32
|
|
4332
|
+
(gen, depth, toJsonCompatible) => Array.from({ length: uint32(gen, 0, 20 - depth) }).map(() => genAny(gen, depth + 1, toJsonCompatible)), // TYPE 117
|
|
4333
|
+
gen => uint8Array(gen, uint32(gen, 0, 50)) // TYPE 116
|
|
4322
4334
|
];
|
|
4323
4335
|
|
|
4324
4336
|
const genAnyLookupTableJsonCompatible = genAnyLookupTable.slice(1);
|
|
@@ -4387,7 +4399,7 @@ function test (testname, write, read, val, doLog = true) {
|
|
|
4387
4399
|
const reader = createDecoder(toUint8Array(encoder));
|
|
4388
4400
|
const result = read(reader);
|
|
4389
4401
|
const utf8ByteLength$1 = utf8ByteLength(val + '');
|
|
4390
|
-
const binaryByteLength = length
|
|
4402
|
+
const binaryByteLength = length(encoder);
|
|
4391
4403
|
if (doLog) {
|
|
4392
4404
|
describe(testname, ` utf8 encode: ${utf8ByteLength$1} bytes / binary encode: ${binaryByteLength} bytes`);
|
|
4393
4405
|
}
|
|
@@ -4553,7 +4565,7 @@ const testRepeatVarUintEncoding = tc => {
|
|
|
4553
4565
|
* @param {t.TestCase} tc
|
|
4554
4566
|
*/
|
|
4555
4567
|
const testRepeatVarIntEncoding = tc => {
|
|
4556
|
-
const n = uint32
|
|
4568
|
+
const n = uint32(tc.prng, 0, BITS32);
|
|
4557
4569
|
test(`varInt of ${n}`, writeVarInt, readVarInt, n, false);
|
|
4558
4570
|
};
|
|
4559
4571
|
|
|
@@ -4577,7 +4589,7 @@ const testRepeatPeekVarUintEncoding = tc => {
|
|
|
4577
4589
|
* @param {t.TestCase} tc
|
|
4578
4590
|
*/
|
|
4579
4591
|
const testRepeatPeekVarIntEncoding = tc => {
|
|
4580
|
-
const n = uint32
|
|
4592
|
+
const n = uint32(tc.prng, 0, BITS32);
|
|
4581
4593
|
test(`varInt of ${n}`, writeVarInt, peekVarInt, n, false);
|
|
4582
4594
|
};
|
|
4583
4595
|
|
|
@@ -4668,12 +4680,12 @@ const strictComparison = (a, b) => a === b;
|
|
|
4668
4680
|
*/
|
|
4669
4681
|
const encodingPairs = [
|
|
4670
4682
|
{ name: 'uint8Array', read: decoder => readUint8Array(decoder, defLen), write: writeUint8Array, gen: gen => uint8Array(gen, defLen), compare: compare },
|
|
4671
|
-
{ name: 'varUint8Array', read: readVarUint8Array, write: writeVarUint8Array, gen: gen => uint8Array(gen, uint32
|
|
4672
|
-
{ name: 'uint8', read: readUint8, write: writeUint8, gen: gen => uint32
|
|
4673
|
-
{ name: 'uint16', read: readUint16, write: writeUint16, gen: gen => uint32
|
|
4674
|
-
{ name: 'uint32', read: readUint32, write: writeUint32, gen: gen => uint32
|
|
4675
|
-
{ name: 'uint32bigEndian', read: readUint32BigEndian, write: writeUint32BigEndian, gen: gen => uint32
|
|
4676
|
-
{ name: 'varString', read: readVarString, write: writeVarString, gen: gen => utf16String(gen, uint32
|
|
4683
|
+
{ name: 'varUint8Array', read: readVarUint8Array, write: writeVarUint8Array, gen: gen => uint8Array(gen, uint32(gen, 0, defLen)), compare: compare },
|
|
4684
|
+
{ name: 'uint8', read: readUint8, write: writeUint8, gen: gen => uint32(gen, 0, BITS8), compare: strictComparison },
|
|
4685
|
+
{ name: 'uint16', read: readUint16, write: writeUint16, gen: gen => uint32(gen, 0, BITS16), compare: strictComparison },
|
|
4686
|
+
{ name: 'uint32', read: readUint32, write: writeUint32, gen: gen => uint32(gen, 0, BITS32), compare: strictComparison },
|
|
4687
|
+
{ name: 'uint32bigEndian', read: readUint32BigEndian, write: writeUint32BigEndian, gen: gen => uint32(gen, 0, BITS32), compare: strictComparison },
|
|
4688
|
+
{ name: 'varString', read: readVarString, write: writeVarString, gen: gen => utf16String(gen, uint32(gen, 0, defLen)), compare: strictComparison },
|
|
4677
4689
|
{ name: 'varUint', read: readVarUint, write: writeVarUint, gen: gen => uint53(gen, 0, BITS32), compare: strictComparison },
|
|
4678
4690
|
{ name: 'varInt', read: readVarInt, write: writeVarInt, gen: gen => int53(gen, LOWEST_INT32, HIGHEST_INT32), compare: strictComparison },
|
|
4679
4691
|
{ name: 'Any', read: readAny, write: writeAny, gen: genAny, compare: compare }
|
|
@@ -4702,7 +4714,7 @@ const testRepeatRandomWrites = tc => {
|
|
|
4702
4714
|
writeUint8Array(encoder, tailData);
|
|
4703
4715
|
const buf = toUint8Array(encoder);
|
|
4704
4716
|
const decoder = createDecoder(buf);
|
|
4705
|
-
assert(length
|
|
4717
|
+
assert(length(encoder) === buf.byteLength);
|
|
4706
4718
|
for (let i = 0; i < ops.length; i++) {
|
|
4707
4719
|
const o = ops[i];
|
|
4708
4720
|
const val = o.read(decoder);
|
|
@@ -4740,7 +4752,7 @@ const testSetOnOverflow = tc => {
|
|
|
4740
4752
|
encoder.cpos = initialLen - 2;
|
|
4741
4753
|
writeUint32(encoder, BITS32);
|
|
4742
4754
|
const buf = toUint8Array(encoder);
|
|
4743
|
-
assert(length
|
|
4755
|
+
assert(length(encoder) === initialLen + 2);
|
|
4744
4756
|
const decoder = createDecoder(buf);
|
|
4745
4757
|
const space = createUint8ArrayFromArrayBuffer(readUint8Array(decoder, initialLen - 2));
|
|
4746
4758
|
for (let i = 0; i < initialLen - 2; i++) {
|
|
@@ -5065,7 +5077,7 @@ const testComparing = tc => {
|
|
|
5065
5077
|
compare([1, 2], [1, 2], 'simple compare (array)');
|
|
5066
5078
|
compare({ a: [1, 2] }, { a: [1, 2] }, 'simple compare nested');
|
|
5067
5079
|
compare(new Set(['3', 1234]), new Set(['3', 1234]), 'compare Sets');
|
|
5068
|
-
const map1 = create();
|
|
5080
|
+
const map1 = create$7();
|
|
5069
5081
|
map1.set(1, 2);
|
|
5070
5082
|
map1.set('x', {});
|
|
5071
5083
|
map1.set(98, 'tst');
|
|
@@ -5169,17 +5181,17 @@ const testSkipping = () => {
|
|
|
5169
5181
|
};
|
|
5170
5182
|
|
|
5171
5183
|
const testAsync = async () => {
|
|
5172
|
-
await measureTimeAsync('time', () => create$
|
|
5184
|
+
await measureTimeAsync('time', () => create$2(r => setTimeout(r)));
|
|
5173
5185
|
await groupAsync('some description', () => wait(1));
|
|
5174
5186
|
};
|
|
5175
5187
|
|
|
5176
|
-
const
|
|
5188
|
+
const testRepeatRepetition = () => {
|
|
5177
5189
|
const arr = [];
|
|
5178
5190
|
const n = 100;
|
|
5179
5191
|
for (let i = 1; i <= n; i++) {
|
|
5180
5192
|
arr.push(i);
|
|
5181
5193
|
}
|
|
5182
|
-
assert(arr.reduce(add, 0) === (n + 1) * n / 2);
|
|
5194
|
+
assert(arr.reduce(add$1, 0) === (n + 1) * n / 2);
|
|
5183
5195
|
};
|
|
5184
5196
|
|
|
5185
5197
|
var testing = /*#__PURE__*/Object.freeze({
|
|
@@ -5188,7 +5200,7 @@ var testing = /*#__PURE__*/Object.freeze({
|
|
|
5188
5200
|
testFailing: testFailing,
|
|
5189
5201
|
testSkipping: testSkipping,
|
|
5190
5202
|
testAsync: testAsync,
|
|
5191
|
-
|
|
5203
|
+
testRepeatRepetition: testRepeatRepetition
|
|
5192
5204
|
});
|
|
5193
5205
|
|
|
5194
5206
|
/**
|
|
@@ -5202,7 +5214,7 @@ var testing = /*#__PURE__*/Object.freeze({
|
|
|
5202
5214
|
* @return {Error}
|
|
5203
5215
|
*/
|
|
5204
5216
|
/* istanbul ignore next */
|
|
5205
|
-
const create$
|
|
5217
|
+
const create$1 = s => new Error(s);
|
|
5206
5218
|
|
|
5207
5219
|
/* eslint-env browser */
|
|
5208
5220
|
|
|
@@ -5213,7 +5225,7 @@ const create$6 = s => new Error(s);
|
|
|
5213
5225
|
* @return {Promise<any>}
|
|
5214
5226
|
*/
|
|
5215
5227
|
/* istanbul ignore next */
|
|
5216
|
-
const rtop = request => create$
|
|
5228
|
+
const rtop = request => create$2((resolve, reject) => {
|
|
5217
5229
|
/* istanbul ignore next */
|
|
5218
5230
|
// @ts-ignore
|
|
5219
5231
|
request.onerror = event => reject(new Error(event.target.error));
|
|
@@ -5230,7 +5242,7 @@ const rtop = request => create$5((resolve, reject) => {
|
|
|
5230
5242
|
* @return {Promise<IDBDatabase>}
|
|
5231
5243
|
*/
|
|
5232
5244
|
/* istanbul ignore next */
|
|
5233
|
-
const openDB = (name, initDB) => create$
|
|
5245
|
+
const openDB = (name, initDB) => create$2((resolve, reject) => {
|
|
5234
5246
|
const request = indexedDB.open(name);
|
|
5235
5247
|
/**
|
|
5236
5248
|
* @param {any} event
|
|
@@ -5240,7 +5252,7 @@ const openDB = (name, initDB) => create$5((resolve, reject) => {
|
|
|
5240
5252
|
/**
|
|
5241
5253
|
* @param {any} event
|
|
5242
5254
|
*/
|
|
5243
|
-
request.onerror = event => reject(create$
|
|
5255
|
+
request.onerror = event => reject(create$1(event.target.error));
|
|
5244
5256
|
/* istanbul ignore next */
|
|
5245
5257
|
request.onblocked = () => location.reload();
|
|
5246
5258
|
/**
|
|
@@ -5310,7 +5322,7 @@ const put = (store, item, key) =>
|
|
|
5310
5322
|
* @return {Promise<any>}
|
|
5311
5323
|
*/
|
|
5312
5324
|
/* istanbul ignore next */
|
|
5313
|
-
const add
|
|
5325
|
+
const add = (store, item, key) =>
|
|
5314
5326
|
rtop(store.add(item, key));
|
|
5315
5327
|
|
|
5316
5328
|
/**
|
|
@@ -5363,7 +5375,7 @@ const getAllKeysValues = (store, range) =>
|
|
|
5363
5375
|
* @return {Promise<void>}
|
|
5364
5376
|
*/
|
|
5365
5377
|
/* istanbul ignore next */
|
|
5366
|
-
const iterateOnRequest = (request, f) => create$
|
|
5378
|
+
const iterateOnRequest = (request, f) => create$2((resolve, reject) => {
|
|
5367
5379
|
/* istanbul ignore next */
|
|
5368
5380
|
request.onerror = reject;
|
|
5369
5381
|
/**
|
|
@@ -5408,7 +5420,7 @@ const iterateKeys = (store, keyrange, f, direction = 'next') =>
|
|
|
5408
5420
|
* @returns {IDBObjectStore}
|
|
5409
5421
|
*/
|
|
5410
5422
|
/* istanbul ignore next */
|
|
5411
|
-
const getStore = (t, store) => t.objectStore(store);
|
|
5423
|
+
const getStore$1 = (t, store) => t.objectStore(store);
|
|
5412
5424
|
|
|
5413
5425
|
/**
|
|
5414
5426
|
* @param {any} lower
|
|
@@ -5437,7 +5449,7 @@ const createTransaction = db => db.transaction(['test'], 'readwrite');
|
|
|
5437
5449
|
* @param {IDBTransaction} t
|
|
5438
5450
|
* @return {IDBObjectStore}
|
|
5439
5451
|
*/
|
|
5440
|
-
const getStore
|
|
5452
|
+
const getStore = t => getStore$1(t, 'test');
|
|
5441
5453
|
|
|
5442
5454
|
/* istanbul ignore next */
|
|
5443
5455
|
const testRetrieveElements = async () => {
|
|
@@ -5446,7 +5458,7 @@ const testRetrieveElements = async () => {
|
|
|
5446
5458
|
await deleteDB(testDBName);
|
|
5447
5459
|
const db = await openDB(testDBName, initTestDB);
|
|
5448
5460
|
const transaction = createTransaction(db);
|
|
5449
|
-
const store = getStore
|
|
5461
|
+
const store = getStore(transaction);
|
|
5450
5462
|
await put(store, 0, ['t', 1]);
|
|
5451
5463
|
await put(store, 1, ['t', 2]);
|
|
5452
5464
|
const expectedKeys = [['t', 1], ['t', 2]];
|
|
@@ -5501,7 +5513,7 @@ const testRetrieveElements = async () => {
|
|
|
5501
5513
|
const getVDel = await get(store, ['t', 0]);
|
|
5502
5514
|
assert(getVDel === undefined);
|
|
5503
5515
|
describe('idb.add');
|
|
5504
|
-
await add
|
|
5516
|
+
await add(store, 99, 42);
|
|
5505
5517
|
const idbVAdd = await get(store, 42);
|
|
5506
5518
|
assert(idbVAdd === 99);
|
|
5507
5519
|
describe('idb.addAutoKey');
|
|
@@ -5598,7 +5610,7 @@ const genTestData = 5000;
|
|
|
5598
5610
|
* @param {prng.PRNG} gen
|
|
5599
5611
|
*/
|
|
5600
5612
|
const runGenTest = (tc, gen) => {
|
|
5601
|
-
group
|
|
5613
|
+
group('next - average distribution', () => {
|
|
5602
5614
|
let sum = 0;
|
|
5603
5615
|
for (let i = 0; i < genTestData; i++) {
|
|
5604
5616
|
const next = gen.next();
|
|
@@ -5612,7 +5624,7 @@ const runGenTest = (tc, gen) => {
|
|
|
5612
5624
|
assert(avg <= 0.55);
|
|
5613
5625
|
});
|
|
5614
5626
|
|
|
5615
|
-
group
|
|
5627
|
+
group('bool - bool distribution is fair', () => {
|
|
5616
5628
|
let head = 0;
|
|
5617
5629
|
let tail = 0;
|
|
5618
5630
|
let b;
|
|
@@ -5630,12 +5642,12 @@ const runGenTest = (tc, gen) => {
|
|
|
5630
5642
|
assert(tail >= floor(genTestData * 0.45), 'Generated enough tails.');
|
|
5631
5643
|
assert(head >= floor(genTestData * 0.45), 'Generated enough heads.');
|
|
5632
5644
|
});
|
|
5633
|
-
group
|
|
5645
|
+
group('int31 - integers average correctly', () => {
|
|
5634
5646
|
let count = 0;
|
|
5635
5647
|
let i;
|
|
5636
5648
|
|
|
5637
5649
|
for (i = 0; i < genTestData; i++) {
|
|
5638
|
-
count += uint32
|
|
5650
|
+
count += uint32(gen, 0, 100);
|
|
5639
5651
|
}
|
|
5640
5652
|
const average = count / genTestData;
|
|
5641
5653
|
const expectedAverage = 100 / 2;
|
|
@@ -5643,7 +5655,7 @@ const runGenTest = (tc, gen) => {
|
|
|
5643
5655
|
assert(abs(average - expectedAverage) <= 2, 'Expected average is at most 1 off.');
|
|
5644
5656
|
});
|
|
5645
5657
|
|
|
5646
|
-
group
|
|
5658
|
+
group('int32 - generates integer with 32 bits', () => {
|
|
5647
5659
|
let largest = 0;
|
|
5648
5660
|
let smallest = 0;
|
|
5649
5661
|
let i;
|
|
@@ -5664,12 +5676,12 @@ const runGenTest = (tc, gen) => {
|
|
|
5664
5676
|
assert((smallest & BIT32) !== 0, 'Largest number is 32 bits long'); // largest.. assuming we convert int to uint
|
|
5665
5677
|
});
|
|
5666
5678
|
|
|
5667
|
-
group
|
|
5679
|
+
group('uint32 - generates unsigned integer with 32 bits', () => {
|
|
5668
5680
|
let num = 0;
|
|
5669
5681
|
let i;
|
|
5670
5682
|
let newNum;
|
|
5671
5683
|
for (i = 0; i < genTestData; i++) {
|
|
5672
|
-
newNum = uint32
|
|
5684
|
+
newNum = uint32(gen, 0, BITS32);
|
|
5673
5685
|
if (newNum > num) {
|
|
5674
5686
|
num = newNum;
|
|
5675
5687
|
}
|
|
@@ -5678,7 +5690,7 @@ const runGenTest = (tc, gen) => {
|
|
|
5678
5690
|
assert((num & BIT32) !== 0, 'Largest number is 32 bits long.');
|
|
5679
5691
|
});
|
|
5680
5692
|
|
|
5681
|
-
group
|
|
5693
|
+
group('int53 - generates integer exceeding 32 bits', () => {
|
|
5682
5694
|
let largest = 0;
|
|
5683
5695
|
let smallest = 0;
|
|
5684
5696
|
let i;
|
|
@@ -5700,7 +5712,7 @@ const runGenTest = (tc, gen) => {
|
|
|
5700
5712
|
assert(smallest < BITS32, 'Smallest Number is smaller than BITS32 (negative)');
|
|
5701
5713
|
});
|
|
5702
5714
|
|
|
5703
|
-
group
|
|
5715
|
+
group('uint53 - generates integer exceeding 32 bits', () => {
|
|
5704
5716
|
let largest = 0;
|
|
5705
5717
|
let smallest = 10000;
|
|
5706
5718
|
let i;
|
|
@@ -5722,12 +5734,12 @@ const runGenTest = (tc, gen) => {
|
|
|
5722
5734
|
assert(largest > (BITS32 >>> 0), 'Largest number exceeds BITS32');
|
|
5723
5735
|
});
|
|
5724
5736
|
|
|
5725
|
-
group
|
|
5737
|
+
group('int31 - generates integer with 31 bits', () => {
|
|
5726
5738
|
let num = 0;
|
|
5727
5739
|
let i;
|
|
5728
5740
|
let newNum;
|
|
5729
5741
|
for (i = 0; i < genTestData; i++) {
|
|
5730
|
-
newNum = uint32
|
|
5742
|
+
newNum = uint32(gen, 0, BITS31);
|
|
5731
5743
|
if (newNum > num) {
|
|
5732
5744
|
num = newNum;
|
|
5733
5745
|
}
|
|
@@ -5736,7 +5748,7 @@ const runGenTest = (tc, gen) => {
|
|
|
5736
5748
|
assert((num & BIT31) !== 0, 'Largest number is 31 bits long.');
|
|
5737
5749
|
});
|
|
5738
5750
|
|
|
5739
|
-
group
|
|
5751
|
+
group('real - has 53 bit resolution', () => {
|
|
5740
5752
|
let num = 0;
|
|
5741
5753
|
let i;
|
|
5742
5754
|
let newNum;
|
|
@@ -5750,7 +5762,7 @@ const runGenTest = (tc, gen) => {
|
|
|
5750
5762
|
assert((MAX_SAFE_INTEGER - num) / MAX_SAFE_INTEGER < 0.01, 'Largest number is close to MAX_SAFE_INTEGER (at most 1% off).');
|
|
5751
5763
|
});
|
|
5752
5764
|
|
|
5753
|
-
group
|
|
5765
|
+
group('char - generates all ascii characters', () => {
|
|
5754
5766
|
const charSet = new Set();
|
|
5755
5767
|
const chars = ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[/]^_`abcdefghijklmnopqrstuvwxyz{|}~"';
|
|
5756
5768
|
for (let i = chars.length - 1; i >= 0; i--) {
|
|
@@ -5804,7 +5816,7 @@ const printDistribution = (gen, tc) => {
|
|
|
5804
5816
|
const y = int32(gen, 0, DIAMETER);
|
|
5805
5817
|
ctx.fillRect(x, y, 1, 2);
|
|
5806
5818
|
}
|
|
5807
|
-
printCanvas
|
|
5819
|
+
printCanvas(canvas$1, DIAMETER);
|
|
5808
5820
|
};
|
|
5809
5821
|
|
|
5810
5822
|
/* istanbul ignore next */
|
|
@@ -5813,9 +5825,9 @@ const printDistribution = (gen, tc) => {
|
|
|
5813
5825
|
*/
|
|
5814
5826
|
const testNumberDistributions = tc => {
|
|
5815
5827
|
skip(!isBrowser);
|
|
5816
|
-
group
|
|
5817
|
-
group
|
|
5818
|
-
group
|
|
5828
|
+
group('Xoroshiro128plus', () => printDistribution(new Xoroshiro128plus(tc.seed), tc));
|
|
5829
|
+
group('Xorshift32', () => printDistribution(new Xorshift32(tc.seed), tc));
|
|
5830
|
+
group('MT19937', () => printDistribution(new Mt19937(tc.seed), tc));
|
|
5819
5831
|
};
|
|
5820
5832
|
|
|
5821
5833
|
var prng = /*#__PURE__*/Object.freeze({
|
|
@@ -5830,7 +5842,7 @@ var prng = /*#__PURE__*/Object.freeze({
|
|
|
5830
5842
|
* @param {t.TestCase} tc
|
|
5831
5843
|
*/
|
|
5832
5844
|
const testMedian = tc => {
|
|
5833
|
-
assert(isNaN(median([])), 'median([]) = NaN');
|
|
5845
|
+
assert(isNaN$1(median([])), 'median([]) = NaN');
|
|
5834
5846
|
assert(median([1]) === 1, 'median([x]) = x');
|
|
5835
5847
|
assert(median([1, 2, 3]) === 2, 'median([a,b,c]) = b');
|
|
5836
5848
|
assert(median([1, 2, 3, 4]) === (2 + 3) / 2, 'median([a,b,c,d]) = (b+c)/2');
|
|
@@ -5849,7 +5861,7 @@ var statistics = /*#__PURE__*/Object.freeze({
|
|
|
5849
5861
|
const testBitx = tc => {
|
|
5850
5862
|
for (let i = 1; i <= 32; i++) {
|
|
5851
5863
|
// @ts-ignore
|
|
5852
|
-
assert(binary[`BIT${i}`] === (1 << (i - 1)), `BIT${i}=${1 << (i - 1)}`);
|
|
5864
|
+
assert(binary$1[`BIT${i}`] === (1 << (i - 1)), `BIT${i}=${1 << (i - 1)}`);
|
|
5853
5865
|
}
|
|
5854
5866
|
};
|
|
5855
5867
|
|
|
@@ -5861,13 +5873,13 @@ const testBitsx = tc => {
|
|
|
5861
5873
|
for (let i = 1; i < 32; i++) {
|
|
5862
5874
|
const expected = ((1 << i) - 1) >>> 0;
|
|
5863
5875
|
// @ts-ignore
|
|
5864
|
-
const have = binary[`BITS${i}`];
|
|
5876
|
+
const have = binary$1[`BITS${i}`];
|
|
5865
5877
|
assert(have === expected, `BITS${i}=${have}=${expected}`);
|
|
5866
5878
|
}
|
|
5867
5879
|
assert(BITS32 === 0xFFFFFFFF);
|
|
5868
5880
|
};
|
|
5869
5881
|
|
|
5870
|
-
var binary
|
|
5882
|
+
var binary = /*#__PURE__*/Object.freeze({
|
|
5871
5883
|
__proto__: null,
|
|
5872
5884
|
testBitx: testBitx,
|
|
5873
5885
|
testBitsx: testBitsx
|
|
@@ -5884,7 +5896,7 @@ const testUint32 = tc => {
|
|
|
5884
5896
|
let lenSum = 0;
|
|
5885
5897
|
let ones = 0;
|
|
5886
5898
|
for (let i = 0; i < iterations; i++) {
|
|
5887
|
-
newNum = uint32();
|
|
5899
|
+
newNum = uint32$1();
|
|
5888
5900
|
lenSum += newNum.toString().length;
|
|
5889
5901
|
ones += newNum.toString(2).split('').filter(x => x === '1').length;
|
|
5890
5902
|
if (newNum > largest) {
|
|
@@ -5956,7 +5968,7 @@ const measureP = (p, min, max) => {
|
|
|
5956
5968
|
* @param {Promise<T>} p
|
|
5957
5969
|
* @return {Promise<T>}
|
|
5958
5970
|
*/
|
|
5959
|
-
const failsP = p => create$
|
|
5971
|
+
const failsP = p => create$2((resolve, reject) => p.then(() => reject(create$1('Promise should fail')), resolve));
|
|
5960
5972
|
|
|
5961
5973
|
/**
|
|
5962
5974
|
* @param {t.TestCase} tc
|
|
@@ -5982,7 +5994,7 @@ const testRepeatPromise = async tc => {
|
|
|
5982
5994
|
*/
|
|
5983
5995
|
const testispromise = tc => {
|
|
5984
5996
|
assert(isPromise(new Promise(() => {})));
|
|
5985
|
-
assert(isPromise(create$
|
|
5997
|
+
assert(isPromise(create$2(() => {})));
|
|
5986
5998
|
const rej = reject();
|
|
5987
5999
|
assert(isPromise(rej));
|
|
5988
6000
|
rej.catch(() => {});
|
|
@@ -6027,7 +6039,7 @@ class Queue {
|
|
|
6027
6039
|
*
|
|
6028
6040
|
* @return {Queue}
|
|
6029
6041
|
*/
|
|
6030
|
-
const create
|
|
6042
|
+
const create = () => new Queue();
|
|
6031
6043
|
|
|
6032
6044
|
/**
|
|
6033
6045
|
* @param {Queue} queue
|
|
@@ -6038,7 +6050,7 @@ const isEmpty = queue => queue.start === null;
|
|
|
6038
6050
|
* @param {Queue} queue
|
|
6039
6051
|
* @param {QueueNode} n
|
|
6040
6052
|
*/
|
|
6041
|
-
const enqueue
|
|
6053
|
+
const enqueue = (queue, n) => {
|
|
6042
6054
|
if (queue.end !== null) {
|
|
6043
6055
|
queue.end.next = n;
|
|
6044
6056
|
queue.end = n;
|
|
@@ -6080,11 +6092,11 @@ const testEnqueueDequeue = tc => {
|
|
|
6080
6092
|
/**
|
|
6081
6093
|
* @type {queue.Queue}
|
|
6082
6094
|
*/
|
|
6083
|
-
const q = create
|
|
6095
|
+
const q = create();
|
|
6084
6096
|
assert(isEmpty(q));
|
|
6085
6097
|
assert(dequeue(q) === null);
|
|
6086
6098
|
for (let i = 0; i < N; i++) {
|
|
6087
|
-
enqueue
|
|
6099
|
+
enqueue(q, new QueueItem(i));
|
|
6088
6100
|
assert(!isEmpty(q));
|
|
6089
6101
|
}
|
|
6090
6102
|
for (let i = 0; i < N; i++) {
|
|
@@ -6094,7 +6106,7 @@ const testEnqueueDequeue = tc => {
|
|
|
6094
6106
|
assert(dequeue(q) === null);
|
|
6095
6107
|
};
|
|
6096
6108
|
|
|
6097
|
-
var queue
|
|
6109
|
+
var queue = /*#__PURE__*/Object.freeze({
|
|
6098
6110
|
__proto__: null,
|
|
6099
6111
|
testEnqueueDequeue: testEnqueueDequeue
|
|
6100
6112
|
});
|
|
@@ -6103,10 +6115,10 @@ var queue$1 = /*#__PURE__*/Object.freeze({
|
|
|
6103
6115
|
* @param {t.TestCase} tc
|
|
6104
6116
|
*/
|
|
6105
6117
|
const testMap = tc => {
|
|
6106
|
-
const m = create();
|
|
6118
|
+
const m = create$7();
|
|
6107
6119
|
m.set(1, 2);
|
|
6108
6120
|
m.set(2, 3);
|
|
6109
|
-
assert(map(m, (value, key) => value * 2 + key).reduce(add) === 13);
|
|
6121
|
+
assert(map$3(m, (value, key) => value * 2 + key).reduce(add$1) === 13);
|
|
6110
6122
|
let numberOfWrites = 0;
|
|
6111
6123
|
const createT = () => {
|
|
6112
6124
|
numberOfWrites++;
|
|
@@ -6119,7 +6131,7 @@ const testMap = tc => {
|
|
|
6119
6131
|
assert(numberOfWrites === 1);
|
|
6120
6132
|
};
|
|
6121
6133
|
|
|
6122
|
-
var map
|
|
6134
|
+
var map = /*#__PURE__*/Object.freeze({
|
|
6123
6135
|
__proto__: null,
|
|
6124
6136
|
testMap: testMap
|
|
6125
6137
|
});
|
|
@@ -6131,16 +6143,16 @@ const testEventloopOrder = tc => {
|
|
|
6131
6143
|
let currI = 0;
|
|
6132
6144
|
for (let i = 0; i < 10; i++) {
|
|
6133
6145
|
const bi = i;
|
|
6134
|
-
enqueue(() => {
|
|
6146
|
+
enqueue$1(() => {
|
|
6135
6147
|
assert(currI++ === bi);
|
|
6136
6148
|
});
|
|
6137
6149
|
}
|
|
6138
|
-
enqueue(() => {
|
|
6150
|
+
enqueue$1(() => {
|
|
6139
6151
|
assert(currI === 10);
|
|
6140
6152
|
});
|
|
6141
6153
|
assert(currI === 0);
|
|
6142
6154
|
return all([
|
|
6143
|
-
createEmpty(resolve => enqueue(resolve)),
|
|
6155
|
+
createEmpty(resolve => enqueue$1(resolve)),
|
|
6144
6156
|
until(0, () => currI === 10)
|
|
6145
6157
|
])
|
|
6146
6158
|
};
|
|
@@ -6154,7 +6166,7 @@ const testTimeout = async tc => {
|
|
|
6154
6166
|
set = true;
|
|
6155
6167
|
});
|
|
6156
6168
|
timeout$1.destroy();
|
|
6157
|
-
await create$
|
|
6169
|
+
await create$2(resolve => {
|
|
6158
6170
|
timeout(10, resolve);
|
|
6159
6171
|
});
|
|
6160
6172
|
assert(set === false);
|
|
@@ -6192,7 +6204,7 @@ const testAnimationFrame = async tc => {
|
|
|
6192
6204
|
* @param {t.TestCase} tc
|
|
6193
6205
|
*/
|
|
6194
6206
|
const testIdleCallback = async tc => {
|
|
6195
|
-
await create$
|
|
6207
|
+
await create$2(resolve => {
|
|
6196
6208
|
idleCallback(resolve);
|
|
6197
6209
|
});
|
|
6198
6210
|
};
|
|
@@ -6247,18 +6259,18 @@ var time = /*#__PURE__*/Object.freeze({
|
|
|
6247
6259
|
* @param {t.TestCase} tc
|
|
6248
6260
|
*/
|
|
6249
6261
|
const testPair = tc => {
|
|
6250
|
-
const ps = [create$
|
|
6262
|
+
const ps = [create$5(1, 2), create$5(3, 4), createReversed(6, 5)];
|
|
6251
6263
|
describe('Counting elements in pair list');
|
|
6252
6264
|
let countLeft = 0;
|
|
6253
6265
|
let countRight = 0;
|
|
6254
|
-
forEach(ps, (left, right) => {
|
|
6266
|
+
forEach$1(ps, (left, right) => {
|
|
6255
6267
|
countLeft += left;
|
|
6256
6268
|
countRight += right;
|
|
6257
6269
|
});
|
|
6258
6270
|
assert(countLeft === 9);
|
|
6259
6271
|
assert(countRight === 12);
|
|
6260
|
-
assert(countLeft === map$
|
|
6261
|
-
assert(countRight === map$
|
|
6272
|
+
assert(countLeft === map$2(ps, left => left).reduce(add$1));
|
|
6273
|
+
assert(countRight === map$2(ps, (left, right) => right).reduce(add$1));
|
|
6262
6274
|
};
|
|
6263
6275
|
|
|
6264
6276
|
var pair = /*#__PURE__*/Object.freeze({
|
|
@@ -6270,17 +6282,17 @@ var pair = /*#__PURE__*/Object.freeze({
|
|
|
6270
6282
|
* @param {t.TestCase} tc
|
|
6271
6283
|
*/
|
|
6272
6284
|
const testObject = tc => {
|
|
6273
|
-
assert(create$
|
|
6285
|
+
assert(create$4().constructor === undefined, 'object.create creates an empty object without constructor');
|
|
6274
6286
|
describe('object.equalFlat');
|
|
6275
|
-
assert(equalFlat
|
|
6276
|
-
assert(equalFlat
|
|
6277
|
-
assert(equalFlat
|
|
6278
|
-
assert(!equalFlat
|
|
6279
|
-
assert(equalFlat
|
|
6280
|
-
assert(!equalFlat
|
|
6287
|
+
assert(equalFlat({}, {}), 'comparing equal objects');
|
|
6288
|
+
assert(equalFlat({ x: 1 }, { x: 1 }), 'comparing equal objects');
|
|
6289
|
+
assert(equalFlat({ x: 'dtrn' }, { x: 'dtrn' }), 'comparing equal objects');
|
|
6290
|
+
assert(!equalFlat({ x: {} }, { x: {} }), 'flatEqual does not dive deep');
|
|
6291
|
+
assert(equalFlat({ x: undefined }, { x: undefined }), 'flatEqual handles undefined');
|
|
6292
|
+
assert(!equalFlat({ x: undefined }, { y: {} }), 'flatEqual handles undefined');
|
|
6281
6293
|
describe('object.every');
|
|
6282
|
-
assert(every
|
|
6283
|
-
assert(!every
|
|
6294
|
+
assert(every({ a: 1, b: 3 }, (v, k) => (v % 2) === 1 && k !== 'c'));
|
|
6295
|
+
assert(!every({ a: 1, b: 3, c: 5 }, (v, k) => (v % 2) === 1 && k !== 'c'));
|
|
6284
6296
|
describe('object.some');
|
|
6285
6297
|
assert(some({ a: 1, b: 3 }, (v, k) => v === 3 && k === 'b'));
|
|
6286
6298
|
assert(!some({ a: 1, b: 5 }, (v, k) => v === 3));
|
|
@@ -6288,13 +6300,13 @@ const testObject = tc => {
|
|
|
6288
6300
|
assert(!some({ a: 1, b: 5 }, (v, k) => false));
|
|
6289
6301
|
describe('object.forEach');
|
|
6290
6302
|
let forEachSum = 0;
|
|
6291
|
-
forEach
|
|
6303
|
+
forEach({ x: 1, y: 3 }, (v, k) => { forEachSum += v; });
|
|
6292
6304
|
assert(forEachSum === 4);
|
|
6293
6305
|
describe('object.map');
|
|
6294
|
-
assert(map$
|
|
6306
|
+
assert(map$1({ x: 1, z: 5 }, (v, k) => v).reduce(add$1) === 6);
|
|
6295
6307
|
describe('object.length');
|
|
6296
|
-
assert(length({}) === 0);
|
|
6297
|
-
assert(length({ x: 1 }) === 1);
|
|
6308
|
+
assert(length$1({}) === 0);
|
|
6309
|
+
assert(length$1({ x: 1 }) === 1);
|
|
6298
6310
|
};
|
|
6299
6311
|
|
|
6300
6312
|
var object = /*#__PURE__*/Object.freeze({
|
|
@@ -6311,7 +6323,7 @@ const testMath = tc => {
|
|
|
6311
6323
|
assert(abs(Number.MIN_SAFE_INTEGER) === Number.MAX_SAFE_INTEGER);
|
|
6312
6324
|
assert(abs(Number.MAX_SAFE_INTEGER) === Number.MAX_SAFE_INTEGER);
|
|
6313
6325
|
describe('math.add');
|
|
6314
|
-
assert([1, 2, 3, 4, 5].reduce(add) === 15);
|
|
6326
|
+
assert([1, 2, 3, 4, 5].reduce(add$1) === 15);
|
|
6315
6327
|
describe('math.ceil');
|
|
6316
6328
|
assert(ceil(1.5) === 2);
|
|
6317
6329
|
assert(ceil(-1.5) === -1);
|
|
@@ -6319,9 +6331,9 @@ const testMath = tc => {
|
|
|
6319
6331
|
assert(floor(1.5) === 1);
|
|
6320
6332
|
assert(floor(-1.5) === -2);
|
|
6321
6333
|
describe('math.isNaN');
|
|
6322
|
-
assert(isNaN(NaN));
|
|
6334
|
+
assert(isNaN$1(NaN));
|
|
6323
6335
|
// @ts-ignore
|
|
6324
|
-
assert(!isNaN(null));
|
|
6336
|
+
assert(!isNaN$1(null));
|
|
6325
6337
|
describe('math.max');
|
|
6326
6338
|
assert([1, 3, 65, 1, 314, 25, 3475, 2, 1].reduce(max) === 3475);
|
|
6327
6339
|
describe('math.min');
|
|
@@ -6341,11 +6353,11 @@ var math = /*#__PURE__*/Object.freeze({
|
|
|
6341
6353
|
*/
|
|
6342
6354
|
const testNumber = tc => {
|
|
6343
6355
|
describe('isNaN');
|
|
6344
|
-
assert(isNaN
|
|
6345
|
-
assert(!isNaN
|
|
6356
|
+
assert(isNaN(NaN));
|
|
6357
|
+
assert(!isNaN(1 / 0));
|
|
6346
6358
|
// @ts-ignore
|
|
6347
|
-
assert(isNaN
|
|
6348
|
-
assert(!isNaN
|
|
6359
|
+
assert(isNaN('a' / 0));
|
|
6360
|
+
assert(!isNaN(0));
|
|
6349
6361
|
describe('isInteger');
|
|
6350
6362
|
assert(!isInteger(1 / 0));
|
|
6351
6363
|
assert(!isInteger(NaN));
|
|
@@ -6683,7 +6695,7 @@ const decodeQueryParams = url => {
|
|
|
6683
6695
|
* @return {string}
|
|
6684
6696
|
*/
|
|
6685
6697
|
const encodeQueryParams = params =>
|
|
6686
|
-
map$
|
|
6698
|
+
map$1(params, (val, key) => `${encodeURIComponent(key)}=${encodeURIComponent(val)}`).join('&');
|
|
6687
6699
|
|
|
6688
6700
|
/**
|
|
6689
6701
|
* @param {Object<string,any>} params
|
|
@@ -6826,6 +6838,27 @@ var func = /*#__PURE__*/Object.freeze({
|
|
|
6826
6838
|
testDeepEquality: testDeepEquality
|
|
6827
6839
|
});
|
|
6828
6840
|
|
|
6841
|
+
/**
|
|
6842
|
+
* @param {t.TestCase} tc
|
|
6843
|
+
*/
|
|
6844
|
+
const testStorageModule = tc => {
|
|
6845
|
+
const s = varStorage;
|
|
6846
|
+
/**
|
|
6847
|
+
* @type {any}
|
|
6848
|
+
*/
|
|
6849
|
+
let lastEvent = null;
|
|
6850
|
+
onChange(event => {
|
|
6851
|
+
lastEvent = event;
|
|
6852
|
+
});
|
|
6853
|
+
s.setItem('key', 'value');
|
|
6854
|
+
assert(lastEvent === null);
|
|
6855
|
+
};
|
|
6856
|
+
|
|
6857
|
+
var storage = /*#__PURE__*/Object.freeze({
|
|
6858
|
+
__proto__: null,
|
|
6859
|
+
testStorageModule: testStorageModule
|
|
6860
|
+
});
|
|
6861
|
+
|
|
6829
6862
|
/* istanbul ignore if */
|
|
6830
6863
|
if (isBrowser) {
|
|
6831
6864
|
createVConsole(document.body);
|
|
@@ -6841,11 +6874,11 @@ runTests({
|
|
|
6841
6874
|
indexeddb,
|
|
6842
6875
|
prng,
|
|
6843
6876
|
statistics,
|
|
6844
|
-
binary
|
|
6877
|
+
binary,
|
|
6845
6878
|
random,
|
|
6846
6879
|
promise,
|
|
6847
|
-
queue
|
|
6848
|
-
map
|
|
6880
|
+
queue,
|
|
6881
|
+
map,
|
|
6849
6882
|
eventloop,
|
|
6850
6883
|
time,
|
|
6851
6884
|
pair,
|
|
@@ -6856,7 +6889,8 @@ runTests({
|
|
|
6856
6889
|
sort,
|
|
6857
6890
|
url,
|
|
6858
6891
|
metric,
|
|
6859
|
-
func
|
|
6892
|
+
func,
|
|
6893
|
+
storage
|
|
6860
6894
|
}).then(success => {
|
|
6861
6895
|
/* istanbul ignore next */
|
|
6862
6896
|
if (isNode) {
|