mol_data_all 1.1.150 → 1.1.154
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/node.test.js +135 -132
- package/node.test.js.map +1 -1
- package/package.json +1 -1
- package/web.test.js +135 -132
- package/web.test.js.map +1 -1
package/package.json
CHANGED
package/web.test.js
CHANGED
|
@@ -339,23 +339,16 @@ var $;
|
|
|
339
339
|
$.$mol_assert_ok($.$mol_compare_deep(1, 1));
|
|
340
340
|
$.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
|
|
341
341
|
$.$mol_assert_not($.$mol_compare_deep(1, 2));
|
|
342
|
-
},
|
|
343
|
-
'Number'() {
|
|
344
342
|
$.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
|
|
345
|
-
$.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
|
|
346
343
|
$.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
|
|
347
344
|
},
|
|
348
|
-
'
|
|
345
|
+
'POJO'() {
|
|
349
346
|
$.$mol_assert_ok($.$mol_compare_deep({}, {}));
|
|
350
|
-
},
|
|
351
|
-
'different POJOs'() {
|
|
352
347
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
|
|
353
|
-
},
|
|
354
|
-
'different POJOs with same keys but different values'() {
|
|
355
348
|
$.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
|
|
356
|
-
},
|
|
357
|
-
'different POJOs with different keys but same values'() {
|
|
358
349
|
$.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
|
|
350
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
|
|
351
|
+
$.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
|
|
359
352
|
},
|
|
360
353
|
'Array'() {
|
|
361
354
|
$.$mol_assert_ok($.$mol_compare_deep([], []));
|
|
@@ -363,17 +356,12 @@ var $;
|
|
|
363
356
|
$.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
|
|
364
357
|
$.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
|
|
365
358
|
},
|
|
366
|
-
'
|
|
367
|
-
|
|
368
|
-
},
|
|
369
|
-
'different classes with same values'() {
|
|
370
|
-
class Obj {
|
|
371
|
-
foo = 1;
|
|
359
|
+
'Non POJO are different'() {
|
|
360
|
+
class Thing extends Object {
|
|
372
361
|
}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
$.$mol_assert_not($.$mol_compare_deep(a, b));
|
|
362
|
+
$.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
|
|
363
|
+
$.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
|
|
364
|
+
$.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
|
|
377
365
|
},
|
|
378
366
|
'same POJOs with cyclic reference'() {
|
|
379
367
|
const a = { foo: {} };
|
|
@@ -382,41 +370,6 @@ var $;
|
|
|
382
370
|
b['self'] = b;
|
|
383
371
|
$.$mol_assert_ok($.$mol_compare_deep(a, b));
|
|
384
372
|
},
|
|
385
|
-
'empty Element'() {
|
|
386
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
|
|
387
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
|
|
388
|
-
},
|
|
389
|
-
'Element with attributes'() {
|
|
390
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
|
|
391
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
|
|
392
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
|
|
393
|
-
},
|
|
394
|
-
'Element with styles'() {
|
|
395
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
|
|
396
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
|
|
397
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
|
|
398
|
-
},
|
|
399
|
-
'Element with content'() {
|
|
400
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
401
|
-
"foo",
|
|
402
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
403
|
-
"foo",
|
|
404
|
-
$.$mol_jsx("br", null))));
|
|
405
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
406
|
-
"foo",
|
|
407
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
408
|
-
"bar",
|
|
409
|
-
$.$mol_jsx("br", null))));
|
|
410
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
|
|
411
|
-
"foo",
|
|
412
|
-
$.$mol_jsx("br", null)), $.$mol_jsx("div", null,
|
|
413
|
-
"foo",
|
|
414
|
-
$.$mol_jsx("hr", null))));
|
|
415
|
-
},
|
|
416
|
-
'Element with handlers'() {
|
|
417
|
-
$.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
|
|
418
|
-
$.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
|
|
419
|
-
},
|
|
420
373
|
'Date'() {
|
|
421
374
|
$.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
|
|
422
375
|
$.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
|
|
@@ -428,8 +381,9 @@ var $;
|
|
|
428
381
|
},
|
|
429
382
|
'Map'() {
|
|
430
383
|
$.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
|
|
431
|
-
$.$mol_assert_ok($.$mol_compare_deep(new Map([[
|
|
384
|
+
$.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
|
|
432
385
|
$.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
|
|
386
|
+
$.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
|
|
433
387
|
},
|
|
434
388
|
'Set'() {
|
|
435
389
|
$.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
|
|
@@ -441,6 +395,21 @@ var $;
|
|
|
441
395
|
$.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
442
396
|
$.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
443
397
|
},
|
|
398
|
+
'Custom comparator'() {
|
|
399
|
+
class User {
|
|
400
|
+
name;
|
|
401
|
+
rand;
|
|
402
|
+
constructor(name, rand = Math.random()) {
|
|
403
|
+
this.name = name;
|
|
404
|
+
this.rand = rand;
|
|
405
|
+
}
|
|
406
|
+
[Symbol.toPrimitive](mode) {
|
|
407
|
+
return this.name;
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
$.$mol_assert_ok($.$mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
411
|
+
$.$mol_assert_not($.$mol_compare_deep(new User('Jin'), new User('John')));
|
|
412
|
+
},
|
|
444
413
|
});
|
|
445
414
|
})($ || ($ = {}));
|
|
446
415
|
//deep.test.js.map
|
|
@@ -448,97 +417,123 @@ var $;
|
|
|
448
417
|
"use strict";
|
|
449
418
|
var $;
|
|
450
419
|
(function ($) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
function $mol_compare_deep(a, b) {
|
|
455
|
-
if (Object.is(a, b))
|
|
420
|
+
let cache = new WeakMap();
|
|
421
|
+
function $mol_compare_deep(left, right) {
|
|
422
|
+
if (Object.is(left, right))
|
|
456
423
|
return true;
|
|
457
|
-
|
|
458
|
-
const b_type = typeof b;
|
|
459
|
-
if (a_type !== b_type)
|
|
424
|
+
if (left === null)
|
|
460
425
|
return false;
|
|
461
|
-
if (
|
|
462
|
-
return a['toString']() === b['toString']();
|
|
463
|
-
if (a_type !== 'object')
|
|
426
|
+
if (right === null)
|
|
464
427
|
return false;
|
|
465
|
-
if (
|
|
428
|
+
if (typeof left !== 'object')
|
|
466
429
|
return false;
|
|
467
|
-
if (
|
|
430
|
+
if (typeof right !== 'object')
|
|
468
431
|
return false;
|
|
469
|
-
|
|
432
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
433
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
434
|
+
if (left_proto !== right_proto)
|
|
470
435
|
return false;
|
|
471
|
-
if (
|
|
472
|
-
return
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
if (
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
436
|
+
if (left instanceof Boolean)
|
|
437
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
438
|
+
if (left instanceof Number)
|
|
439
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
440
|
+
if (left instanceof String)
|
|
441
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
442
|
+
if (left instanceof Date)
|
|
443
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
444
|
+
if (left instanceof RegExp)
|
|
445
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
446
|
+
let left_cache = cache.get(left);
|
|
447
|
+
if (left_cache) {
|
|
448
|
+
const right_cache = left_cache.get(right);
|
|
449
|
+
if (typeof right_cache === 'boolean')
|
|
450
|
+
return right_cache;
|
|
484
451
|
}
|
|
485
452
|
else {
|
|
486
|
-
|
|
487
|
-
cache.set(
|
|
453
|
+
left_cache = new WeakMap([[right, true]]);
|
|
454
|
+
cache.set(left, left_cache);
|
|
488
455
|
}
|
|
489
|
-
a_stack.push(a);
|
|
490
|
-
b_stack.push(b);
|
|
491
456
|
let result;
|
|
492
457
|
try {
|
|
493
|
-
if (
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
let count = 0;
|
|
509
|
-
for (let key in a) {
|
|
510
|
-
try {
|
|
511
|
-
if (!$mol_compare_deep(a[key], b[key]))
|
|
512
|
-
return result = false;
|
|
513
|
-
}
|
|
514
|
-
catch (error) {
|
|
515
|
-
$.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
|
|
516
|
-
}
|
|
517
|
-
++count;
|
|
518
|
-
}
|
|
519
|
-
for (let key in b) {
|
|
520
|
-
--count;
|
|
521
|
-
if (count < 0)
|
|
522
|
-
return result = false;
|
|
523
|
-
}
|
|
524
|
-
if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
|
|
525
|
-
if (!Object.is(a['valueOf'](), b['valueOf']()))
|
|
526
|
-
return result = false;
|
|
527
|
-
}
|
|
528
|
-
return result = true;
|
|
458
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
459
|
+
result = compare_pojo(left, right);
|
|
460
|
+
else if (Array.isArray(left))
|
|
461
|
+
result = compare_array(left, right);
|
|
462
|
+
else if (left instanceof Set)
|
|
463
|
+
result = compare_set(left, right);
|
|
464
|
+
else if (left instanceof Map)
|
|
465
|
+
result = compare_map(left, right);
|
|
466
|
+
else if (ArrayBuffer.isView(left))
|
|
467
|
+
result = compare_buffer(left, right);
|
|
468
|
+
else if (Symbol.toPrimitive in left)
|
|
469
|
+
result = compare_primitive(left, right);
|
|
470
|
+
else
|
|
471
|
+
result = false;
|
|
529
472
|
}
|
|
530
473
|
finally {
|
|
531
|
-
|
|
532
|
-
b_stack.pop();
|
|
533
|
-
if (a_stack.length === 0) {
|
|
534
|
-
cache = null;
|
|
535
|
-
}
|
|
536
|
-
else {
|
|
537
|
-
a_cache.set(b, result);
|
|
538
|
-
}
|
|
474
|
+
left_cache.set(right, result);
|
|
539
475
|
}
|
|
476
|
+
return result;
|
|
540
477
|
}
|
|
541
478
|
$.$mol_compare_deep = $mol_compare_deep;
|
|
479
|
+
function compare_array(left, right) {
|
|
480
|
+
const len = left.length;
|
|
481
|
+
if (len !== right.length)
|
|
482
|
+
return false;
|
|
483
|
+
for (let i = 0; i < len; ++i) {
|
|
484
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
485
|
+
return false;
|
|
486
|
+
}
|
|
487
|
+
return true;
|
|
488
|
+
}
|
|
489
|
+
function compare_buffer(left, right) {
|
|
490
|
+
const len = left.byteLength;
|
|
491
|
+
if (len !== right.byteLength)
|
|
492
|
+
return false;
|
|
493
|
+
for (let i = 0; i < len; ++i) {
|
|
494
|
+
if (left[i] !== right[i])
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
return true;
|
|
498
|
+
}
|
|
499
|
+
function compare_iterator(left, right, compare) {
|
|
500
|
+
while (true) {
|
|
501
|
+
const left_next = left.next();
|
|
502
|
+
const right_next = right.next();
|
|
503
|
+
if (left_next.done !== right_next.done)
|
|
504
|
+
return false;
|
|
505
|
+
if (left_next.done)
|
|
506
|
+
break;
|
|
507
|
+
if (!compare(left_next.value, right_next.value))
|
|
508
|
+
return false;
|
|
509
|
+
}
|
|
510
|
+
return true;
|
|
511
|
+
}
|
|
512
|
+
function compare_set(left, right) {
|
|
513
|
+
if (left.size !== right.size)
|
|
514
|
+
return false;
|
|
515
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
516
|
+
}
|
|
517
|
+
function compare_map(left, right) {
|
|
518
|
+
if (left.size !== right.size)
|
|
519
|
+
return false;
|
|
520
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
521
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
522
|
+
}
|
|
523
|
+
function compare_pojo(left, right) {
|
|
524
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
525
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
526
|
+
if (left_keys.length !== right_keys.length)
|
|
527
|
+
return false;
|
|
528
|
+
for (let key of left_keys) {
|
|
529
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
530
|
+
return false;
|
|
531
|
+
}
|
|
532
|
+
return true;
|
|
533
|
+
}
|
|
534
|
+
function compare_primitive(left, right) {
|
|
535
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
536
|
+
}
|
|
542
537
|
})($ || ($ = {}));
|
|
543
538
|
//deep.js.map
|
|
544
539
|
;
|
|
@@ -1134,6 +1129,10 @@ var $;
|
|
|
1134
1129
|
'format typed'() {
|
|
1135
1130
|
$.$mol_assert_equal(new $.$mol_time_duration('P1Y2M3DT4h5m6s').toString('P#Y#M#DT#h#m#s'), 'P1Y2M3DT4H5M6S');
|
|
1136
1131
|
},
|
|
1132
|
+
'comparison'() {
|
|
1133
|
+
const iso = 'P1Y1M1DT1h1m1s';
|
|
1134
|
+
$.$mol_assert_like(new $.$mol_time_duration(iso), new $.$mol_time_duration(iso));
|
|
1135
|
+
},
|
|
1137
1136
|
});
|
|
1138
1137
|
})($ || ($ = {}));
|
|
1139
1138
|
//duration.test.js.map
|
|
@@ -1233,6 +1232,9 @@ var $;
|
|
|
1233
1232
|
toString(pattern = 'P#Y#M#DT#h#m#s') {
|
|
1234
1233
|
return super.toString(pattern);
|
|
1235
1234
|
}
|
|
1235
|
+
[Symbol.toPrimitive](mode) {
|
|
1236
|
+
return mode === 'number' ? this.valueOf() : this.toString();
|
|
1237
|
+
}
|
|
1236
1238
|
static patterns = {
|
|
1237
1239
|
'#Y': (duration) => {
|
|
1238
1240
|
if (!duration.year)
|
|
@@ -1335,7 +1337,8 @@ var $;
|
|
|
1335
1337
|
}
|
|
1336
1338
|
}
|
|
1337
1339
|
const boxify = $.$mol_data_pipe((input) => input.toString(), Box);
|
|
1338
|
-
$.$
|
|
1340
|
+
$.$mol_assert_ok(boxify(5) instanceof Box);
|
|
1341
|
+
$.$mol_assert_like(boxify(5).value, '5');
|
|
1339
1342
|
},
|
|
1340
1343
|
});
|
|
1341
1344
|
})($ || ($ = {}));
|