mol_data_all 1.1.151 → 1.1.152

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_data_all",
3
- "version": "1.1.151",
3
+ "version": "1.1.152",
4
4
  "main": "node.js",
5
5
  "module": "node.esm.js",
6
6
  "browser": "web.js",
package/web.test.js CHANGED
@@ -339,23 +339,15 @@ 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
+ $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(1)));
342
343
  },
343
- 'Number'() {
344
- $.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
345
- $.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
346
- $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
347
- },
348
- 'empty POJOs'() {
344
+ 'POJO'() {
349
345
  $.$mol_assert_ok($.$mol_compare_deep({}, {}));
350
- },
351
- 'different POJOs'() {
352
346
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
353
- },
354
- 'different POJOs with same keys but different values'() {
355
347
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
356
- },
357
- 'different POJOs with different keys but same values'() {
358
348
  $.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
349
+ $.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
350
+ $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
359
351
  },
360
352
  'Array'() {
361
353
  $.$mol_assert_ok($.$mol_compare_deep([], []));
@@ -363,17 +355,12 @@ var $;
363
355
  $.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
364
356
  $.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
365
357
  },
366
- 'same POJO trees'() {
367
- $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
368
- },
369
- 'different classes with same values'() {
370
- class Obj {
371
- foo = 1;
358
+ 'Non POJO are different'() {
359
+ class Thing extends Object {
372
360
  }
373
- const a = new Obj;
374
- const b = new class extends Obj {
375
- };
376
- $.$mol_assert_not($.$mol_compare_deep(a, b));
361
+ $.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
362
+ $.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
363
+ $.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
377
364
  },
378
365
  'same POJOs with cyclic reference'() {
379
366
  const a = { foo: {} };
@@ -382,41 +369,6 @@ var $;
382
369
  b['self'] = b;
383
370
  $.$mol_assert_ok($.$mol_compare_deep(a, b));
384
371
  },
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
372
  'Date'() {
421
373
  $.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
422
374
  $.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
@@ -448,94 +400,74 @@ var $;
448
400
  "use strict";
449
401
  var $;
450
402
  (function ($) {
451
- const a_stack = [];
452
- const b_stack = [];
453
- let cache = null;
454
- function $mol_compare_deep(a, b) {
455
- if (Object.is(a, b))
403
+ let cache = new WeakMap();
404
+ function $mol_compare_deep(left, right) {
405
+ if (Object.is(left, right))
456
406
  return true;
457
- const a_type = typeof a;
458
- const b_type = typeof b;
459
- if (a_type !== b_type)
407
+ if (left === null)
460
408
  return false;
461
- if (a_type === 'function')
462
- return a['toString']() === b['toString']();
463
- if (a_type !== 'object')
409
+ if (right === null)
464
410
  return false;
465
- if (!a || !b)
411
+ if (typeof left !== 'object')
466
412
  return false;
467
- if (a instanceof Error)
413
+ if (typeof right !== 'object')
468
414
  return false;
469
- if (a['constructor'] !== b['constructor'])
415
+ if (left['constructor'] !== right['constructor'])
470
416
  return false;
471
- if (a instanceof RegExp)
472
- return a.toString() === b['toString']();
473
- const ref = a_stack.indexOf(a);
474
- if (ref >= 0) {
475
- return Object.is(b_stack[ref], b);
476
- }
477
- if (!cache)
478
- cache = new WeakMap;
479
- let a_cache = cache.get(a);
480
- if (a_cache) {
481
- const b_cache = a_cache.get(b);
482
- if (typeof b_cache === 'boolean')
483
- return b_cache;
417
+ let left_cache = cache.get(left);
418
+ if (left_cache) {
419
+ const right_cache = left_cache.get(right);
420
+ if (typeof right_cache === 'boolean')
421
+ return right_cache;
484
422
  }
485
423
  else {
486
- a_cache = new WeakMap();
487
- cache.set(a, a_cache);
424
+ left_cache = new WeakMap();
425
+ cache.set(left, left_cache);
426
+ left_cache.set(right, true);
488
427
  }
489
- a_stack.push(a);
490
- b_stack.push(b);
428
+ if (left instanceof RegExp)
429
+ return left.toString() === right['toString']();
430
+ if (left instanceof Date)
431
+ return Object.is(left.valueOf(), right['valueOf']());
491
432
  let result;
492
433
  try {
493
- if (Symbol.iterator in a) {
494
- const a_iter = a[Symbol.iterator]();
495
- const b_iter = b[Symbol.iterator]();
434
+ if (Symbol.iterator in left) {
435
+ const left_iter = left[Symbol.iterator]();
436
+ const right_iter = right[Symbol.iterator]();
496
437
  while (true) {
497
- const a_next = a_iter.next();
498
- const b_next = b_iter.next();
499
- if (a_next.done !== b_next.done)
438
+ const left_next = left_iter.next();
439
+ const right_next = right_iter.next();
440
+ if (left_next.done !== right_next.done)
500
441
  return result = false;
501
- if (a_next.done)
442
+ if (left_next.done)
502
443
  break;
503
- if (!$mol_compare_deep(a_next.value, b_next.value))
444
+ if (!$mol_compare_deep(left_next.value, right_next.value))
504
445
  return result = false;
505
446
  }
506
447
  return result = true;
507
448
  }
449
+ if (left['constructor'] !== ({}).constructor)
450
+ return result = false;
508
451
  let count = 0;
509
- for (let key in a) {
452
+ for (let key in left) {
510
453
  try {
511
- if (!$mol_compare_deep(a[key], b[key]))
454
+ if (!$mol_compare_deep(left[key], right[key]))
512
455
  return result = false;
513
456
  }
514
457
  catch (error) {
515
- $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
458
+ $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${left} and ${right}`, error));
516
459
  }
517
460
  ++count;
518
461
  }
519
- for (let key in b) {
462
+ for (let key in right) {
520
463
  --count;
521
464
  if (count < 0)
522
465
  return result = false;
523
466
  }
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
467
  return result = true;
529
468
  }
530
469
  finally {
531
- a_stack.pop();
532
- b_stack.pop();
533
- if (a_stack.length === 0) {
534
- cache = null;
535
- }
536
- else {
537
- a_cache.set(b, result);
538
- }
470
+ left_cache.set(right, result);
539
471
  }
540
472
  }
541
473
  $.$mol_compare_deep = $mol_compare_deep;
@@ -1335,7 +1267,8 @@ var $;
1335
1267
  }
1336
1268
  }
1337
1269
  const boxify = $.$mol_data_pipe((input) => input.toString(), Box);
1338
- $.$mol_assert_like(boxify(5), new Box('5'));
1270
+ $.$mol_assert_ok(boxify(5) instanceof Box);
1271
+ $.$mol_assert_like(boxify(5).value, '5');
1339
1272
  },
1340
1273
  });
1341
1274
  })($ || ($ = {}));