mol_plot_all 1.2.131 → 1.2.135
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.d.ts +7 -10
- package/node.deps.json +1 -1
- package/node.esm.js +176 -89
- package/node.esm.js.map +1 -1
- package/node.js +176 -89
- package/node.js.map +1 -1
- package/node.test.js +194 -333
- package/node.test.js.map +1 -1
- package/node.view.tree +5 -1
- package/package.json +1 -1
- package/web.d.ts +7 -10
- package/web.deps.json +1 -1
- package/web.esm.js +176 -89
- package/web.esm.js.map +1 -1
- package/web.js +176 -89
- package/web.js.map +1 -1
- package/web.test.js +15 -241
- package/web.test.js.map +1 -1
- package/web.view.tree +5 -1
package/node.test.js
CHANGED
|
@@ -953,91 +953,125 @@ var $;
|
|
|
953
953
|
"use strict";
|
|
954
954
|
var $;
|
|
955
955
|
(function ($) {
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
956
|
+
let cache = new WeakMap();
|
|
957
|
+
function $mol_compare_deep(left, right) {
|
|
958
|
+
if (Object.is(left, right))
|
|
959
|
+
return true;
|
|
960
|
+
if (left === null)
|
|
961
|
+
return false;
|
|
962
|
+
if (right === null)
|
|
963
|
+
return false;
|
|
964
|
+
if (typeof left !== 'object')
|
|
965
|
+
return false;
|
|
966
|
+
if (typeof right !== 'object')
|
|
967
|
+
return false;
|
|
968
|
+
const left_proto = Reflect.getPrototypeOf(left);
|
|
969
|
+
const right_proto = Reflect.getPrototypeOf(right);
|
|
970
|
+
if (left_proto !== right_proto)
|
|
971
|
+
return false;
|
|
972
|
+
if (left instanceof Boolean)
|
|
973
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
974
|
+
if (left instanceof Number)
|
|
975
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
976
|
+
if (left instanceof String)
|
|
977
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
978
|
+
if (left instanceof Date)
|
|
979
|
+
return Object.is(left.valueOf(), right['valueOf']());
|
|
980
|
+
if (left instanceof RegExp)
|
|
981
|
+
return left.source === right['source'] && left.flags === right['flags'];
|
|
982
|
+
let left_cache = cache.get(left);
|
|
983
|
+
if (left_cache) {
|
|
984
|
+
const right_cache = left_cache.get(right);
|
|
985
|
+
if (typeof right_cache === 'boolean')
|
|
986
|
+
return right_cache;
|
|
987
|
+
}
|
|
988
|
+
else {
|
|
989
|
+
left_cache = new WeakMap([[right, true]]);
|
|
990
|
+
cache.set(left, left_cache);
|
|
991
|
+
}
|
|
992
|
+
let result;
|
|
980
993
|
try {
|
|
981
|
-
|
|
994
|
+
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
995
|
+
result = compare_pojo(left, right);
|
|
996
|
+
else if (Array.isArray(left))
|
|
997
|
+
result = compare_array(left, right);
|
|
998
|
+
else if (left instanceof Set)
|
|
999
|
+
result = compare_set(left, right);
|
|
1000
|
+
else if (left instanceof Map)
|
|
1001
|
+
result = compare_map(left, right);
|
|
1002
|
+
else if (ArrayBuffer.isView(left))
|
|
1003
|
+
result = compare_buffer(left, right);
|
|
1004
|
+
else if (Symbol.toPrimitive in left)
|
|
1005
|
+
result = compare_primitive(left, right);
|
|
1006
|
+
else
|
|
1007
|
+
result = false;
|
|
982
1008
|
}
|
|
983
1009
|
finally {
|
|
984
|
-
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
$.$mol_conform = $mol_conform;
|
|
988
|
-
$.$mol_conform_handlers = new WeakMap();
|
|
989
|
-
function $mol_conform_handler(cl, handler) {
|
|
990
|
-
$.$mol_conform_handlers.set(cl, handler);
|
|
991
|
-
}
|
|
992
|
-
$.$mol_conform_handler = $mol_conform_handler;
|
|
993
|
-
function $mol_conform_array(target, source) {
|
|
994
|
-
if (source.length !== target.length)
|
|
995
|
-
return target;
|
|
996
|
-
for (let i = 0; i < target.length; ++i) {
|
|
997
|
-
if (!Object.is(source[i], target[i]))
|
|
998
|
-
return target;
|
|
999
|
-
}
|
|
1000
|
-
return source;
|
|
1001
|
-
}
|
|
1002
|
-
$.$mol_conform_array = $mol_conform_array;
|
|
1003
|
-
$mol_conform_handler(Array, $mol_conform_array);
|
|
1004
|
-
$mol_conform_handler(Uint8Array, $mol_conform_array);
|
|
1005
|
-
$mol_conform_handler(Uint16Array, $mol_conform_array);
|
|
1006
|
-
$mol_conform_handler(Uint32Array, $mol_conform_array);
|
|
1007
|
-
$mol_conform_handler(({})['constructor'], (target, source) => {
|
|
1008
|
-
let count = 0;
|
|
1009
|
-
let equal = true;
|
|
1010
|
-
for (let key in target) {
|
|
1011
|
-
const conformed = $mol_conform(target[key], source[key]);
|
|
1012
|
-
if (conformed !== target[key]) {
|
|
1013
|
-
try {
|
|
1014
|
-
target[key] = conformed;
|
|
1015
|
-
}
|
|
1016
|
-
catch (error) { }
|
|
1017
|
-
if (!Object.is(conformed, target[key]))
|
|
1018
|
-
equal = false;
|
|
1019
|
-
}
|
|
1020
|
-
if (!Object.is(conformed, source[key]))
|
|
1021
|
-
equal = false;
|
|
1022
|
-
++count;
|
|
1010
|
+
left_cache.set(right, result);
|
|
1023
1011
|
}
|
|
1024
|
-
|
|
1025
|
-
|
|
1012
|
+
return result;
|
|
1013
|
+
}
|
|
1014
|
+
$.$mol_compare_deep = $mol_compare_deep;
|
|
1015
|
+
function compare_array(left, right) {
|
|
1016
|
+
const len = left.length;
|
|
1017
|
+
if (len !== right.length)
|
|
1018
|
+
return false;
|
|
1019
|
+
for (let i = 0; i < len; ++i) {
|
|
1020
|
+
if (!$mol_compare_deep(left[i], right[i]))
|
|
1021
|
+
return false;
|
|
1022
|
+
}
|
|
1023
|
+
return true;
|
|
1024
|
+
}
|
|
1025
|
+
function compare_buffer(left, right) {
|
|
1026
|
+
const len = left.byteLength;
|
|
1027
|
+
if (len !== right.byteLength)
|
|
1028
|
+
return false;
|
|
1029
|
+
for (let i = 0; i < len; ++i) {
|
|
1030
|
+
if (left[i] !== right[i])
|
|
1031
|
+
return false;
|
|
1032
|
+
}
|
|
1033
|
+
return true;
|
|
1034
|
+
}
|
|
1035
|
+
function compare_iterator(left, right, compare) {
|
|
1036
|
+
while (true) {
|
|
1037
|
+
const left_next = left.next();
|
|
1038
|
+
const right_next = right.next();
|
|
1039
|
+
if (left_next.done !== right_next.done)
|
|
1040
|
+
return false;
|
|
1041
|
+
if (left_next.done)
|
|
1026
1042
|
break;
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1043
|
+
if (!compare(left_next.value, right_next.value))
|
|
1044
|
+
return false;
|
|
1045
|
+
}
|
|
1046
|
+
return true;
|
|
1047
|
+
}
|
|
1048
|
+
function compare_set(left, right) {
|
|
1049
|
+
if (left.size !== right.size)
|
|
1050
|
+
return false;
|
|
1051
|
+
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1052
|
+
}
|
|
1053
|
+
function compare_map(left, right) {
|
|
1054
|
+
if (left.size !== right.size)
|
|
1055
|
+
return false;
|
|
1056
|
+
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
1057
|
+
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
1058
|
+
}
|
|
1059
|
+
function compare_pojo(left, right) {
|
|
1060
|
+
const left_keys = Object.getOwnPropertyNames(left);
|
|
1061
|
+
const right_keys = Object.getOwnPropertyNames(right);
|
|
1062
|
+
if (left_keys.length !== right_keys.length)
|
|
1063
|
+
return false;
|
|
1064
|
+
for (let key of left_keys) {
|
|
1065
|
+
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
1068
|
+
return true;
|
|
1069
|
+
}
|
|
1070
|
+
function compare_primitive(left, right) {
|
|
1071
|
+
return Object.is(left[Symbol.toPrimitive]('default'), right[Symbol.toPrimitive]('default'));
|
|
1072
|
+
}
|
|
1039
1073
|
})($ || ($ = {}));
|
|
1040
|
-
//
|
|
1074
|
+
//deep.js.map
|
|
1041
1075
|
;
|
|
1042
1076
|
"use strict";
|
|
1043
1077
|
var $;
|
|
@@ -1364,8 +1398,7 @@ var $;
|
|
|
1364
1398
|
}
|
|
1365
1399
|
}
|
|
1366
1400
|
push(value) {
|
|
1367
|
-
|
|
1368
|
-
if (this.error !== null || !Object.is(this.value, value)) {
|
|
1401
|
+
if (this.error !== null || !$.$mol_compare_deep(this.value, value)) {
|
|
1369
1402
|
if ($mol_fiber.logs)
|
|
1370
1403
|
this.$.$mol_log3_done({
|
|
1371
1404
|
place: this,
|
|
@@ -3280,11 +3313,21 @@ var $;
|
|
|
3280
3313
|
return val;
|
|
3281
3314
|
return null;
|
|
3282
3315
|
}
|
|
3316
|
+
draw_start(event) {
|
|
3317
|
+
if (event !== undefined)
|
|
3318
|
+
return event;
|
|
3319
|
+
return null;
|
|
3320
|
+
}
|
|
3283
3321
|
draw(event) {
|
|
3284
3322
|
if (event !== undefined)
|
|
3285
3323
|
return event;
|
|
3286
3324
|
return null;
|
|
3287
3325
|
}
|
|
3326
|
+
draw_end(event) {
|
|
3327
|
+
if (event !== undefined)
|
|
3328
|
+
return event;
|
|
3329
|
+
return null;
|
|
3330
|
+
}
|
|
3288
3331
|
style() {
|
|
3289
3332
|
return {
|
|
3290
3333
|
...super.style(),
|
|
@@ -3298,7 +3341,7 @@ var $;
|
|
|
3298
3341
|
pointerdown: (event) => this.event_start(event),
|
|
3299
3342
|
pointermove: (event) => this.event_move(event),
|
|
3300
3343
|
pointerup: (event) => this.event_end(event),
|
|
3301
|
-
pointerleave: (event) => this.
|
|
3344
|
+
pointerleave: (event) => this.event_leave(event),
|
|
3302
3345
|
wheel: (event) => this.event_wheel(event)
|
|
3303
3346
|
};
|
|
3304
3347
|
}
|
|
@@ -3317,6 +3360,11 @@ var $;
|
|
|
3317
3360
|
return event;
|
|
3318
3361
|
return null;
|
|
3319
3362
|
}
|
|
3363
|
+
event_leave(event) {
|
|
3364
|
+
if (event !== undefined)
|
|
3365
|
+
return event;
|
|
3366
|
+
return null;
|
|
3367
|
+
}
|
|
3320
3368
|
event_wheel(event) {
|
|
3321
3369
|
if (event !== undefined)
|
|
3322
3370
|
return event;
|
|
@@ -3386,9 +3434,15 @@ var $;
|
|
|
3386
3434
|
__decorate([
|
|
3387
3435
|
$.$mol_mem
|
|
3388
3436
|
], $mol_touch.prototype, "swipe_to_top", null);
|
|
3437
|
+
__decorate([
|
|
3438
|
+
$.$mol_mem
|
|
3439
|
+
], $mol_touch.prototype, "draw_start", null);
|
|
3389
3440
|
__decorate([
|
|
3390
3441
|
$.$mol_mem
|
|
3391
3442
|
], $mol_touch.prototype, "draw", null);
|
|
3443
|
+
__decorate([
|
|
3444
|
+
$.$mol_mem
|
|
3445
|
+
], $mol_touch.prototype, "draw_end", null);
|
|
3392
3446
|
__decorate([
|
|
3393
3447
|
$.$mol_mem
|
|
3394
3448
|
], $mol_touch.prototype, "event_start", null);
|
|
@@ -3398,6 +3452,9 @@ var $;
|
|
|
3398
3452
|
__decorate([
|
|
3399
3453
|
$.$mol_mem
|
|
3400
3454
|
], $mol_touch.prototype, "event_end", null);
|
|
3455
|
+
__decorate([
|
|
3456
|
+
$.$mol_mem
|
|
3457
|
+
], $mol_touch.prototype, "event_leave", null);
|
|
3401
3458
|
__decorate([
|
|
3402
3459
|
$.$mol_mem
|
|
3403
3460
|
], $mol_touch.prototype, "event_wheel", null);
|
|
@@ -3444,10 +3501,14 @@ var $;
|
|
|
3444
3501
|
event_eat(event) {
|
|
3445
3502
|
if (event instanceof PointerEvent) {
|
|
3446
3503
|
const events = this.pointer_events().filter(e => e.pointerId !== event.pointerId);
|
|
3447
|
-
if (event.type !== 'pointerleave')
|
|
3504
|
+
if (event.type !== 'pointerup' && event.type !== 'pointerleave')
|
|
3448
3505
|
events.push(event);
|
|
3449
3506
|
this.pointer_events(events);
|
|
3450
|
-
|
|
3507
|
+
const touch_count = events.filter(e => e.pointerType === 'touch').length;
|
|
3508
|
+
if (this.allow_zoom() && touch_count === 2) {
|
|
3509
|
+
return this.action_type('zoom');
|
|
3510
|
+
}
|
|
3511
|
+
if (this.action_type() === 'zoom' && touch_count === 1) {
|
|
3451
3512
|
return this.action_type('zoom');
|
|
3452
3513
|
}
|
|
3453
3514
|
let button;
|
|
@@ -3480,10 +3541,12 @@ var $;
|
|
|
3480
3541
|
const action_type = this.event_eat(event);
|
|
3481
3542
|
if (!action_type)
|
|
3482
3543
|
return;
|
|
3483
|
-
if (action_type === 'draw')
|
|
3484
|
-
return;
|
|
3485
3544
|
const coords = this.pointer_coords();
|
|
3486
3545
|
this.start_pos(coords.center());
|
|
3546
|
+
if (action_type === 'draw') {
|
|
3547
|
+
this.draw_start(event);
|
|
3548
|
+
return;
|
|
3549
|
+
}
|
|
3487
3550
|
this.start_distance(coords.distance());
|
|
3488
3551
|
this.start_zoom(this.zoom());
|
|
3489
3552
|
}
|
|
@@ -3495,14 +3558,17 @@ var $;
|
|
|
3495
3558
|
return;
|
|
3496
3559
|
const start_pan = this.start_pan();
|
|
3497
3560
|
const action_type = this.event_eat(event);
|
|
3561
|
+
const start_pos = this.start_pos();
|
|
3498
3562
|
let pos = this.pointer_center();
|
|
3499
3563
|
if (!action_type)
|
|
3500
3564
|
return;
|
|
3501
3565
|
if (action_type === 'draw') {
|
|
3502
|
-
|
|
3566
|
+
const distance = new $.$mol_vector(start_pos, pos).distance();
|
|
3567
|
+
if (distance >= 4) {
|
|
3568
|
+
this.draw(event);
|
|
3569
|
+
}
|
|
3503
3570
|
return;
|
|
3504
3571
|
}
|
|
3505
|
-
const start_pos = this.start_pos();
|
|
3506
3572
|
if (!start_pos)
|
|
3507
3573
|
return;
|
|
3508
3574
|
if (action_type === 'pan') {
|
|
@@ -3551,12 +3617,15 @@ var $;
|
|
|
3551
3617
|
}
|
|
3552
3618
|
}
|
|
3553
3619
|
event_end(event) {
|
|
3620
|
+
const action = this.action_type();
|
|
3621
|
+
if (action === 'draw') {
|
|
3622
|
+
this.draw_end(event);
|
|
3623
|
+
}
|
|
3624
|
+
this.event_leave(event);
|
|
3625
|
+
}
|
|
3626
|
+
event_leave(event) {
|
|
3554
3627
|
this.event_eat(event);
|
|
3555
3628
|
this.dom_node().releasePointerCapture(event.pointerId);
|
|
3556
|
-
if (!this.start_pos()) {
|
|
3557
|
-
this.draw(event);
|
|
3558
|
-
return;
|
|
3559
|
-
}
|
|
3560
3629
|
this.start_pos(null);
|
|
3561
3630
|
}
|
|
3562
3631
|
swipe_left(event) {
|
|
@@ -3799,11 +3868,21 @@ var $;
|
|
|
3799
3868
|
allow_zoom() {
|
|
3800
3869
|
return true;
|
|
3801
3870
|
}
|
|
3871
|
+
draw_start(event) {
|
|
3872
|
+
if (event !== undefined)
|
|
3873
|
+
return event;
|
|
3874
|
+
return null;
|
|
3875
|
+
}
|
|
3802
3876
|
draw(event) {
|
|
3803
3877
|
if (event !== undefined)
|
|
3804
3878
|
return event;
|
|
3805
3879
|
return null;
|
|
3806
3880
|
}
|
|
3881
|
+
draw_end(event) {
|
|
3882
|
+
if (event !== undefined)
|
|
3883
|
+
return event;
|
|
3884
|
+
return null;
|
|
3885
|
+
}
|
|
3807
3886
|
cursor_position() {
|
|
3808
3887
|
return this.Touch().pointer_center();
|
|
3809
3888
|
}
|
|
@@ -3820,7 +3899,9 @@ var $;
|
|
|
3820
3899
|
obj.allow_draw = () => this.allow_draw();
|
|
3821
3900
|
obj.allow_pan = () => this.allow_pan();
|
|
3822
3901
|
obj.allow_zoom = () => this.allow_zoom();
|
|
3902
|
+
obj.draw_start = (event) => this.draw_start(event);
|
|
3823
3903
|
obj.draw = (event) => this.draw(event);
|
|
3904
|
+
obj.draw_end = (event) => this.draw_end(event);
|
|
3824
3905
|
return obj;
|
|
3825
3906
|
}
|
|
3826
3907
|
}
|
|
@@ -3902,9 +3983,15 @@ var $;
|
|
|
3902
3983
|
__decorate([
|
|
3903
3984
|
$.$mol_mem
|
|
3904
3985
|
], $mol_plot_pane.prototype, "zoom", null);
|
|
3986
|
+
__decorate([
|
|
3987
|
+
$.$mol_mem
|
|
3988
|
+
], $mol_plot_pane.prototype, "draw_start", null);
|
|
3905
3989
|
__decorate([
|
|
3906
3990
|
$.$mol_mem
|
|
3907
3991
|
], $mol_plot_pane.prototype, "draw", null);
|
|
3992
|
+
__decorate([
|
|
3993
|
+
$.$mol_mem
|
|
3994
|
+
], $mol_plot_pane.prototype, "draw_end", null);
|
|
3908
3995
|
__decorate([
|
|
3909
3996
|
$.$mol_mem
|
|
3910
3997
|
], $mol_plot_pane.prototype, "Touch", null);
|
|
@@ -6156,130 +6243,27 @@ var $;
|
|
|
6156
6243
|
$.$mol_assert_ok($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([0])));
|
|
6157
6244
|
$.$mol_assert_not($.$mol_compare_deep(new Uint8Array([0]), new Uint8Array([1])));
|
|
6158
6245
|
},
|
|
6246
|
+
'Custom comparator'() {
|
|
6247
|
+
class User {
|
|
6248
|
+
name;
|
|
6249
|
+
rand;
|
|
6250
|
+
constructor(name, rand = Math.random()) {
|
|
6251
|
+
this.name = name;
|
|
6252
|
+
this.rand = rand;
|
|
6253
|
+
}
|
|
6254
|
+
[Symbol.toPrimitive](mode) {
|
|
6255
|
+
return this.name;
|
|
6256
|
+
}
|
|
6257
|
+
}
|
|
6258
|
+
$.$mol_assert_ok($.$mol_compare_deep(new User('Jin'), new User('Jin')));
|
|
6259
|
+
$.$mol_assert_not($.$mol_compare_deep(new User('Jin'), new User('John')));
|
|
6260
|
+
},
|
|
6159
6261
|
});
|
|
6160
6262
|
})($ || ($ = {}));
|
|
6161
6263
|
//deep.test.js.map
|
|
6162
6264
|
;
|
|
6163
6265
|
"use strict";
|
|
6164
6266
|
var $;
|
|
6165
|
-
(function ($) {
|
|
6166
|
-
let cache = new WeakMap();
|
|
6167
|
-
function $mol_compare_deep(left, right) {
|
|
6168
|
-
if (Object.is(left, right))
|
|
6169
|
-
return true;
|
|
6170
|
-
if (left === null)
|
|
6171
|
-
return false;
|
|
6172
|
-
if (right === null)
|
|
6173
|
-
return false;
|
|
6174
|
-
if (typeof left !== 'object')
|
|
6175
|
-
return false;
|
|
6176
|
-
if (typeof right !== 'object')
|
|
6177
|
-
return false;
|
|
6178
|
-
const left_proto = Reflect.getPrototypeOf(left);
|
|
6179
|
-
const right_proto = Reflect.getPrototypeOf(right);
|
|
6180
|
-
if (left_proto !== right_proto)
|
|
6181
|
-
return false;
|
|
6182
|
-
if (left instanceof Boolean)
|
|
6183
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
6184
|
-
if (left instanceof Number)
|
|
6185
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
6186
|
-
if (left instanceof String)
|
|
6187
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
6188
|
-
if (left instanceof Date)
|
|
6189
|
-
return Object.is(left.valueOf(), right['valueOf']());
|
|
6190
|
-
if (left instanceof RegExp)
|
|
6191
|
-
return left.source === right['source'] && left.flags === right['flags'];
|
|
6192
|
-
let left_cache = cache.get(left);
|
|
6193
|
-
if (left_cache) {
|
|
6194
|
-
const right_cache = left_cache.get(right);
|
|
6195
|
-
if (typeof right_cache === 'boolean')
|
|
6196
|
-
return right_cache;
|
|
6197
|
-
}
|
|
6198
|
-
else {
|
|
6199
|
-
left_cache = new WeakMap([[right, true]]);
|
|
6200
|
-
cache.set(left, left_cache);
|
|
6201
|
-
}
|
|
6202
|
-
let result;
|
|
6203
|
-
try {
|
|
6204
|
-
if (left_proto && !Reflect.getPrototypeOf(left_proto))
|
|
6205
|
-
result = compare_pojo(left, right);
|
|
6206
|
-
else if (Array.isArray(left))
|
|
6207
|
-
result = compare_array(left, right);
|
|
6208
|
-
else if (left instanceof Set)
|
|
6209
|
-
result = compare_set(left, right);
|
|
6210
|
-
else if (left instanceof Map)
|
|
6211
|
-
result = compare_map(left, right);
|
|
6212
|
-
else if (ArrayBuffer.isView(left))
|
|
6213
|
-
result = compare_buffer(left, right);
|
|
6214
|
-
else
|
|
6215
|
-
result = false;
|
|
6216
|
-
}
|
|
6217
|
-
finally {
|
|
6218
|
-
left_cache.set(right, result);
|
|
6219
|
-
}
|
|
6220
|
-
return result;
|
|
6221
|
-
}
|
|
6222
|
-
$.$mol_compare_deep = $mol_compare_deep;
|
|
6223
|
-
function compare_array(left, right) {
|
|
6224
|
-
const len = left.length;
|
|
6225
|
-
if (len !== right.length)
|
|
6226
|
-
return false;
|
|
6227
|
-
for (let i = 0; i < len; ++i) {
|
|
6228
|
-
if (!$mol_compare_deep(left[i], right[i]))
|
|
6229
|
-
return false;
|
|
6230
|
-
}
|
|
6231
|
-
return true;
|
|
6232
|
-
}
|
|
6233
|
-
function compare_buffer(left, right) {
|
|
6234
|
-
const len = left.byteLength;
|
|
6235
|
-
if (len !== right.byteLength)
|
|
6236
|
-
return false;
|
|
6237
|
-
for (let i = 0; i < len; ++i) {
|
|
6238
|
-
if (left[i] !== right[i])
|
|
6239
|
-
return false;
|
|
6240
|
-
}
|
|
6241
|
-
return true;
|
|
6242
|
-
}
|
|
6243
|
-
function compare_iterator(left, right, compare) {
|
|
6244
|
-
while (true) {
|
|
6245
|
-
const left_next = left.next();
|
|
6246
|
-
const right_next = right.next();
|
|
6247
|
-
if (left_next.done !== right_next.done)
|
|
6248
|
-
return false;
|
|
6249
|
-
if (left_next.done)
|
|
6250
|
-
break;
|
|
6251
|
-
if (!compare(left_next.value, right_next.value))
|
|
6252
|
-
return false;
|
|
6253
|
-
}
|
|
6254
|
-
return true;
|
|
6255
|
-
}
|
|
6256
|
-
function compare_set(left, right) {
|
|
6257
|
-
if (left.size !== right.size)
|
|
6258
|
-
return false;
|
|
6259
|
-
return compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
6260
|
-
}
|
|
6261
|
-
function compare_map(left, right) {
|
|
6262
|
-
if (left.size !== right.size)
|
|
6263
|
-
return false;
|
|
6264
|
-
return compare_iterator(left.keys(), right.keys(), Object.is)
|
|
6265
|
-
&& compare_iterator(left.values(), right.values(), $mol_compare_deep);
|
|
6266
|
-
}
|
|
6267
|
-
function compare_pojo(left, right) {
|
|
6268
|
-
const left_keys = Object.getOwnPropertyNames(left);
|
|
6269
|
-
const right_keys = Object.getOwnPropertyNames(right);
|
|
6270
|
-
if (left_keys.length !== right_keys.length)
|
|
6271
|
-
return false;
|
|
6272
|
-
for (let key of left_keys) {
|
|
6273
|
-
if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
|
|
6274
|
-
return false;
|
|
6275
|
-
}
|
|
6276
|
-
return true;
|
|
6277
|
-
}
|
|
6278
|
-
})($ || ($ = {}));
|
|
6279
|
-
//deep.js.map
|
|
6280
|
-
;
|
|
6281
|
-
"use strict";
|
|
6282
|
-
var $;
|
|
6283
6267
|
(function ($) {
|
|
6284
6268
|
$.$mol_test({
|
|
6285
6269
|
'must be false'() {
|
|
@@ -6684,129 +6668,6 @@ var $;
|
|
|
6684
6668
|
;
|
|
6685
6669
|
"use strict";
|
|
6686
6670
|
var $;
|
|
6687
|
-
(function ($) {
|
|
6688
|
-
$.$mol_test({
|
|
6689
|
-
'return source when same object'() {
|
|
6690
|
-
const target = {};
|
|
6691
|
-
$.$mol_assert_equal($.$mol_conform(target, target), target);
|
|
6692
|
-
},
|
|
6693
|
-
'return target when some is not object'() {
|
|
6694
|
-
const obj = { a: 1 };
|
|
6695
|
-
$.$mol_assert_equal($.$mol_conform(true, obj), true);
|
|
6696
|
-
$.$mol_assert_equal($.$mol_conform(obj, true), obj);
|
|
6697
|
-
},
|
|
6698
|
-
'return target when some is null'() {
|
|
6699
|
-
const obj = { a: 1 };
|
|
6700
|
-
$.$mol_assert_equal($.$mol_conform(null, obj), null);
|
|
6701
|
-
$.$mol_assert_equal($.$mol_conform(obj, null), obj);
|
|
6702
|
-
},
|
|
6703
|
-
'return target when some is undefined'() {
|
|
6704
|
-
const obj = { a: 1 };
|
|
6705
|
-
$.$mol_assert_equal($.$mol_conform(undefined, obj), undefined);
|
|
6706
|
-
$.$mol_assert_equal($.$mol_conform(obj, undefined), obj);
|
|
6707
|
-
},
|
|
6708
|
-
'return target when different keys count'() {
|
|
6709
|
-
const target = [1, 2, 3];
|
|
6710
|
-
const source = [1, 2, 3, undefined];
|
|
6711
|
-
const result = $.$mol_conform(target, source);
|
|
6712
|
-
$.$mol_assert_equal(result, target);
|
|
6713
|
-
$.$mol_assert_equal(result.join(','), '1,2,3');
|
|
6714
|
-
},
|
|
6715
|
-
'return source when array values are strong equal'() {
|
|
6716
|
-
const source = [1, 2, 3];
|
|
6717
|
-
$.$mol_assert_equal($.$mol_conform([1, 2, 3], source), source);
|
|
6718
|
-
},
|
|
6719
|
-
'return source when object values are strong equal'() {
|
|
6720
|
-
const source = { a: 1, b: 2 };
|
|
6721
|
-
$.$mol_assert_equal($.$mol_conform({ a: 1, b: 2 }, source), source);
|
|
6722
|
-
},
|
|
6723
|
-
'return target when some values are not equal'() {
|
|
6724
|
-
const target = [1, 2, 3];
|
|
6725
|
-
const source = [1, 2, 5];
|
|
6726
|
-
const result = $.$mol_conform(target, source);
|
|
6727
|
-
$.$mol_assert_equal(result, target);
|
|
6728
|
-
$.$mol_assert_equal(result.join(','), '1,2,3');
|
|
6729
|
-
},
|
|
6730
|
-
'return source when values are deep equal'() {
|
|
6731
|
-
const source = { foo: { bar: 1 } };
|
|
6732
|
-
$.$mol_assert_equal($.$mol_conform({ foo: { bar: 1 } }, source), source);
|
|
6733
|
-
},
|
|
6734
|
-
'return target with equal values from source and not equal from target'() {
|
|
6735
|
-
const source = { foo: { xxx: 1 }, bar: { xxx: 2 } };
|
|
6736
|
-
const target = { foo: { xxx: 1 }, bar: { xxx: 3 } };
|
|
6737
|
-
const result = $.$mol_conform(target, source);
|
|
6738
|
-
$.$mol_assert_equal(result, target);
|
|
6739
|
-
$.$mol_assert_equal(result.foo, source.foo);
|
|
6740
|
-
$.$mol_assert_equal(result.bar, target.bar);
|
|
6741
|
-
},
|
|
6742
|
-
'return target when equal but with different class'() {
|
|
6743
|
-
const target = { '0': 1 };
|
|
6744
|
-
$.$mol_assert_equal($.$mol_conform(target, [1]), target);
|
|
6745
|
-
},
|
|
6746
|
-
'return target when conformer for class is not defined'() {
|
|
6747
|
-
const Obj = class {
|
|
6748
|
-
};
|
|
6749
|
-
const source = new Obj;
|
|
6750
|
-
const target = new Obj;
|
|
6751
|
-
const result = $.$mol_conform(target, source);
|
|
6752
|
-
$.$mol_assert_equal(result, target);
|
|
6753
|
-
},
|
|
6754
|
-
'return target when has cyclic reference'() {
|
|
6755
|
-
const source = { foo: {} };
|
|
6756
|
-
source['self'] = source;
|
|
6757
|
-
const target = { foo: {} };
|
|
6758
|
-
target['self'] = target;
|
|
6759
|
-
const result = $.$mol_conform(target, source);
|
|
6760
|
-
$.$mol_assert_equal(result, target);
|
|
6761
|
-
$.$mol_assert_equal(result['self'], target);
|
|
6762
|
-
$.$mol_assert_equal(result.foo, source.foo);
|
|
6763
|
-
},
|
|
6764
|
-
'return source when equal dates'() {
|
|
6765
|
-
const source = new Date(12345);
|
|
6766
|
-
const target = new Date(12345);
|
|
6767
|
-
const result = $.$mol_conform(target, source);
|
|
6768
|
-
$.$mol_assert_equal(result, source);
|
|
6769
|
-
},
|
|
6770
|
-
'return source when equal regular expressions'() {
|
|
6771
|
-
const source = /\x22/mig;
|
|
6772
|
-
const target = /\x22/mig;
|
|
6773
|
-
const result = $.$mol_conform(target, source);
|
|
6774
|
-
$.$mol_assert_equal(result, source);
|
|
6775
|
-
},
|
|
6776
|
-
'return cached value if already conformed'() {
|
|
6777
|
-
const source = { foo: { xxx: 1 }, bar: { xxx: 3 } };
|
|
6778
|
-
const target = { foo: { xxx: 2 }, bar: { xxx: 3 } };
|
|
6779
|
-
const result = $.$mol_conform(target, source);
|
|
6780
|
-
target.foo.xxx = 1;
|
|
6781
|
-
$.$mol_assert_equal($.$mol_conform(target.foo, source.foo), target.foo);
|
|
6782
|
-
},
|
|
6783
|
-
'skip readlony fields'() {
|
|
6784
|
-
const source = { foo: {}, bar: {} };
|
|
6785
|
-
const target = { foo: {}, bar: {} };
|
|
6786
|
-
Object.defineProperty(target, 'bar', { value: {}, writable: false });
|
|
6787
|
-
const result = $.$mol_conform(target, source);
|
|
6788
|
-
$.$mol_assert_equal(result, target);
|
|
6789
|
-
$.$mol_assert_equal(result.foo, source.foo);
|
|
6790
|
-
$.$mol_assert_equal(result.bar, target.bar);
|
|
6791
|
-
},
|
|
6792
|
-
'object with NaN'() {
|
|
6793
|
-
const source = { foo: Number.NaN };
|
|
6794
|
-
const target = { foo: Number.NaN };
|
|
6795
|
-
const result = $.$mol_conform(target, source);
|
|
6796
|
-
$.$mol_assert_equal(result, source);
|
|
6797
|
-
},
|
|
6798
|
-
'array with NaN'() {
|
|
6799
|
-
const source = [Number.NaN];
|
|
6800
|
-
const target = [Number.NaN];
|
|
6801
|
-
const result = $.$mol_conform(target, source);
|
|
6802
|
-
$.$mol_assert_equal(result, source);
|
|
6803
|
-
},
|
|
6804
|
-
});
|
|
6805
|
-
})($ || ($ = {}));
|
|
6806
|
-
//conform.test.js.map
|
|
6807
|
-
;
|
|
6808
|
-
"use strict";
|
|
6809
|
-
var $;
|
|
6810
6671
|
(function ($) {
|
|
6811
6672
|
$.$mol_test({
|
|
6812
6673
|
'trim array'() {
|