mol_plot_all 1.2.130 → 1.2.131

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mol_plot_all",
3
- "version": "1.2.130",
3
+ "version": "1.2.131",
4
4
  "main": "node.js",
5
5
  "module": "node.esm.js",
6
6
  "browser": "web.js",
package/web.test.js CHANGED
@@ -271,23 +271,16 @@ var $;
271
271
  $.$mol_assert_ok($.$mol_compare_deep(1, 1));
272
272
  $.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
273
273
  $.$mol_assert_not($.$mol_compare_deep(1, 2));
274
- },
275
- 'Number'() {
276
274
  $.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
277
- $.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
278
275
  $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
279
276
  },
280
- 'empty POJOs'() {
277
+ 'POJO'() {
281
278
  $.$mol_assert_ok($.$mol_compare_deep({}, {}));
282
- },
283
- 'different POJOs'() {
284
279
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
285
- },
286
- 'different POJOs with same keys but different values'() {
287
280
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
288
- },
289
- 'different POJOs with different keys but same values'() {
290
281
  $.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
282
+ $.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
283
+ $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
291
284
  },
292
285
  'Array'() {
293
286
  $.$mol_assert_ok($.$mol_compare_deep([], []));
@@ -295,17 +288,12 @@ var $;
295
288
  $.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
296
289
  $.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
297
290
  },
298
- 'same POJO trees'() {
299
- $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
300
- },
301
- 'different classes with same values'() {
302
- class Obj {
303
- foo = 1;
291
+ 'Non POJO are different'() {
292
+ class Thing extends Object {
304
293
  }
305
- const a = new Obj;
306
- const b = new class extends Obj {
307
- };
308
- $.$mol_assert_not($.$mol_compare_deep(a, b));
294
+ $.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
295
+ $.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
296
+ $.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
309
297
  },
310
298
  'same POJOs with cyclic reference'() {
311
299
  const a = { foo: {} };
@@ -314,41 +302,6 @@ var $;
314
302
  b['self'] = b;
315
303
  $.$mol_assert_ok($.$mol_compare_deep(a, b));
316
304
  },
317
- 'empty Element'() {
318
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
319
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
320
- },
321
- 'Element with attributes'() {
322
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
323
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
324
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
325
- },
326
- 'Element with styles'() {
327
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
328
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
329
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
330
- },
331
- 'Element with content'() {
332
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
333
- "foo",
334
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
335
- "foo",
336
- $.$mol_jsx("br", null))));
337
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
338
- "foo",
339
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
340
- "bar",
341
- $.$mol_jsx("br", null))));
342
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
343
- "foo",
344
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
345
- "foo",
346
- $.$mol_jsx("hr", null))));
347
- },
348
- 'Element with handlers'() {
349
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
350
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
351
- },
352
305
  'Date'() {
353
306
  $.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
354
307
  $.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
@@ -360,8 +313,9 @@ var $;
360
313
  },
361
314
  'Map'() {
362
315
  $.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
363
- $.$mol_assert_ok($.$mol_compare_deep(new Map([[[1], [2]]]), new Map([[[1], [2]]])));
316
+ $.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
364
317
  $.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
318
+ $.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
365
319
  },
366
320
  'Set'() {
367
321
  $.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
@@ -380,97 +334,118 @@ var $;
380
334
  "use strict";
381
335
  var $;
382
336
  (function ($) {
383
- const a_stack = [];
384
- const b_stack = [];
385
- let cache = null;
386
- function $mol_compare_deep(a, b) {
387
- if (Object.is(a, b))
337
+ let cache = new WeakMap();
338
+ function $mol_compare_deep(left, right) {
339
+ if (Object.is(left, right))
388
340
  return true;
389
- const a_type = typeof a;
390
- const b_type = typeof b;
391
- if (a_type !== b_type)
341
+ if (left === null)
392
342
  return false;
393
- if (a_type === 'function')
394
- return a['toString']() === b['toString']();
395
- if (a_type !== 'object')
343
+ if (right === null)
396
344
  return false;
397
- if (!a || !b)
345
+ if (typeof left !== 'object')
398
346
  return false;
399
- if (a instanceof Error)
347
+ if (typeof right !== 'object')
400
348
  return false;
401
- if (a['constructor'] !== b['constructor'])
349
+ const left_proto = Reflect.getPrototypeOf(left);
350
+ const right_proto = Reflect.getPrototypeOf(right);
351
+ if (left_proto !== right_proto)
402
352
  return false;
403
- if (a instanceof RegExp)
404
- return a.toString() === b['toString']();
405
- const ref = a_stack.indexOf(a);
406
- if (ref >= 0) {
407
- return Object.is(b_stack[ref], b);
408
- }
409
- if (!cache)
410
- cache = new WeakMap;
411
- let a_cache = cache.get(a);
412
- if (a_cache) {
413
- const b_cache = a_cache.get(b);
414
- if (typeof b_cache === 'boolean')
415
- return b_cache;
353
+ if (left instanceof Boolean)
354
+ return Object.is(left.valueOf(), right['valueOf']());
355
+ if (left instanceof Number)
356
+ return Object.is(left.valueOf(), right['valueOf']());
357
+ if (left instanceof String)
358
+ return Object.is(left.valueOf(), right['valueOf']());
359
+ if (left instanceof Date)
360
+ return Object.is(left.valueOf(), right['valueOf']());
361
+ if (left instanceof RegExp)
362
+ return left.source === right['source'] && left.flags === right['flags'];
363
+ let left_cache = cache.get(left);
364
+ if (left_cache) {
365
+ const right_cache = left_cache.get(right);
366
+ if (typeof right_cache === 'boolean')
367
+ return right_cache;
416
368
  }
417
369
  else {
418
- a_cache = new WeakMap();
419
- cache.set(a, a_cache);
370
+ left_cache = new WeakMap([[right, true]]);
371
+ cache.set(left, left_cache);
420
372
  }
421
- a_stack.push(a);
422
- b_stack.push(b);
423
373
  let result;
424
374
  try {
425
- if (Symbol.iterator in a) {
426
- const a_iter = a[Symbol.iterator]();
427
- const b_iter = b[Symbol.iterator]();
428
- while (true) {
429
- const a_next = a_iter.next();
430
- const b_next = b_iter.next();
431
- if (a_next.done !== b_next.done)
432
- return result = false;
433
- if (a_next.done)
434
- break;
435
- if (!$mol_compare_deep(a_next.value, b_next.value))
436
- return result = false;
437
- }
438
- return result = true;
439
- }
440
- let count = 0;
441
- for (let key in a) {
442
- try {
443
- if (!$mol_compare_deep(a[key], b[key]))
444
- return result = false;
445
- }
446
- catch (error) {
447
- $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
448
- }
449
- ++count;
450
- }
451
- for (let key in b) {
452
- --count;
453
- if (count < 0)
454
- return result = false;
455
- }
456
- if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
457
- if (!Object.is(a['valueOf'](), b['valueOf']()))
458
- return result = false;
459
- }
460
- return result = true;
375
+ if (left_proto && !Reflect.getPrototypeOf(left_proto))
376
+ result = compare_pojo(left, right);
377
+ else if (Array.isArray(left))
378
+ result = compare_array(left, right);
379
+ else if (left instanceof Set)
380
+ result = compare_set(left, right);
381
+ else if (left instanceof Map)
382
+ result = compare_map(left, right);
383
+ else if (ArrayBuffer.isView(left))
384
+ result = compare_buffer(left, right);
385
+ else
386
+ result = false;
461
387
  }
462
388
  finally {
463
- a_stack.pop();
464
- b_stack.pop();
465
- if (a_stack.length === 0) {
466
- cache = null;
467
- }
468
- else {
469
- a_cache.set(b, result);
470
- }
389
+ left_cache.set(right, result);
471
390
  }
391
+ return result;
472
392
  }
473
393
  $.$mol_compare_deep = $mol_compare_deep;
394
+ function compare_array(left, right) {
395
+ const len = left.length;
396
+ if (len !== right.length)
397
+ return false;
398
+ for (let i = 0; i < len; ++i) {
399
+ if (!$mol_compare_deep(left[i], right[i]))
400
+ return false;
401
+ }
402
+ return true;
403
+ }
404
+ function compare_buffer(left, right) {
405
+ const len = left.byteLength;
406
+ if (len !== right.byteLength)
407
+ return false;
408
+ for (let i = 0; i < len; ++i) {
409
+ if (left[i] !== right[i])
410
+ return false;
411
+ }
412
+ return true;
413
+ }
414
+ function compare_iterator(left, right, compare) {
415
+ while (true) {
416
+ const left_next = left.next();
417
+ const right_next = right.next();
418
+ if (left_next.done !== right_next.done)
419
+ return false;
420
+ if (left_next.done)
421
+ break;
422
+ if (!compare(left_next.value, right_next.value))
423
+ return false;
424
+ }
425
+ return true;
426
+ }
427
+ function compare_set(left, right) {
428
+ if (left.size !== right.size)
429
+ return false;
430
+ return compare_iterator(left.values(), right.values(), $mol_compare_deep);
431
+ }
432
+ function compare_map(left, right) {
433
+ if (left.size !== right.size)
434
+ return false;
435
+ return compare_iterator(left.keys(), right.keys(), Object.is)
436
+ && compare_iterator(left.values(), right.values(), $mol_compare_deep);
437
+ }
438
+ function compare_pojo(left, right) {
439
+ const left_keys = Object.getOwnPropertyNames(left);
440
+ const right_keys = Object.getOwnPropertyNames(right);
441
+ if (left_keys.length !== right_keys.length)
442
+ return false;
443
+ for (let key of left_keys) {
444
+ if (!$mol_compare_deep(left[key], Reflect.get(right, key)))
445
+ return false;
446
+ }
447
+ return true;
448
+ }
474
449
  })($ || ($ = {}));
475
450
  //deep.js.map
476
451
  ;
@@ -1585,92 +1560,6 @@ var $;
1585
1560
  ;
1586
1561
  "use strict";
1587
1562
  var $;
1588
- (function ($) {
1589
- $.$mol_test({
1590
- 'equal paths'() {
1591
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
1592
- $.$mol_assert_like(diff, {
1593
- prefix: [1, 2, 3, 4],
1594
- suffix: [[], [], []],
1595
- });
1596
- },
1597
- 'different suffix'() {
1598
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
1599
- $.$mol_assert_like(diff, {
1600
- prefix: [1, 2],
1601
- suffix: [[3, 4], [3, 5], [5, 4]],
1602
- });
1603
- },
1604
- 'one contains other'() {
1605
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
1606
- $.$mol_assert_like(diff, {
1607
- prefix: [1, 2],
1608
- suffix: [[3, 4], [], [3]],
1609
- });
1610
- },
1611
- 'fully different'() {
1612
- const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
1613
- $.$mol_assert_like(diff, {
1614
- prefix: [],
1615
- suffix: [[1, 2], [3, 4], [5, 6]],
1616
- });
1617
- },
1618
- });
1619
- })($ || ($ = {}));
1620
- //path.test.js.map
1621
- ;
1622
- "use strict";
1623
- var $;
1624
- (function ($) {
1625
- function $mol_diff_path(...paths) {
1626
- const limit = Math.min(...paths.map(path => path.length));
1627
- lookup: for (var i = 0; i < limit; ++i) {
1628
- const first = paths[0][i];
1629
- for (let j = 1; j < paths.length; ++j) {
1630
- if (paths[j][i] !== first)
1631
- break lookup;
1632
- }
1633
- }
1634
- return {
1635
- prefix: paths[0].slice(0, i),
1636
- suffix: paths.map(path => path.slice(i)),
1637
- };
1638
- }
1639
- $.$mol_diff_path = $mol_diff_path;
1640
- })($ || ($ = {}));
1641
- //path.js.map
1642
- ;
1643
- "use strict";
1644
- var $;
1645
- (function ($) {
1646
- class $mol_error_mix extends Error {
1647
- errors;
1648
- constructor(message, ...errors) {
1649
- super(message);
1650
- this.errors = errors;
1651
- if (errors.length) {
1652
- const stacks = [...errors.map(error => error.stack), this.stack];
1653
- const diff = $.$mol_diff_path(...stacks.map(stack => {
1654
- if (!stack)
1655
- return [];
1656
- return stack.split('\n').reverse();
1657
- }));
1658
- const head = diff.prefix.reverse().join('\n');
1659
- const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
1660
- this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
1661
- this.message += errors.map(error => '\n' + error.message).join('');
1662
- }
1663
- }
1664
- toJSON() {
1665
- return this.message;
1666
- }
1667
- }
1668
- $.$mol_error_mix = $mol_error_mix;
1669
- })($ || ($ = {}));
1670
- //mix.js.map
1671
- ;
1672
- "use strict";
1673
- var $;
1674
1563
  (function ($) {
1675
1564
  class $mol_view_tree_test_attributes_super extends $.$mol_view {
1676
1565
  some() {