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/node.test.js CHANGED
@@ -6100,23 +6100,16 @@ var $;
6100
6100
  $.$mol_assert_ok($.$mol_compare_deep(1, 1));
6101
6101
  $.$mol_assert_ok($.$mol_compare_deep(Number.NaN, Number.NaN));
6102
6102
  $.$mol_assert_not($.$mol_compare_deep(1, 2));
6103
- },
6104
- 'Number'() {
6105
6103
  $.$mol_assert_ok($.$mol_compare_deep(Object(1), Object(1)));
6106
- $.$mol_assert_ok($.$mol_compare_deep(Object(Number.NaN), Object(Number.NaN)));
6107
6104
  $.$mol_assert_not($.$mol_compare_deep(Object(1), Object(2)));
6108
6105
  },
6109
- 'empty POJOs'() {
6106
+ 'POJO'() {
6110
6107
  $.$mol_assert_ok($.$mol_compare_deep({}, {}));
6111
- },
6112
- 'different POJOs'() {
6113
6108
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { b: 2 }));
6114
- },
6115
- 'different POJOs with same keys but different values'() {
6116
6109
  $.$mol_assert_not($.$mol_compare_deep({ a: 1 }, { a: 2 }));
6117
- },
6118
- 'different POJOs with different keys but same values'() {
6119
6110
  $.$mol_assert_not($.$mol_compare_deep({}, { a: undefined }));
6111
+ $.$mol_assert_ok($.$mol_compare_deep({ a: 1, b: 2 }, { b: 2, a: 1 }));
6112
+ $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
6120
6113
  },
6121
6114
  'Array'() {
6122
6115
  $.$mol_assert_ok($.$mol_compare_deep([], []));
@@ -6124,17 +6117,12 @@ var $;
6124
6117
  $.$mol_assert_not($.$mol_compare_deep([1, 2], [1, 3]));
6125
6118
  $.$mol_assert_not($.$mol_compare_deep([1, 2,], [1, 3, undefined]));
6126
6119
  },
6127
- 'same POJO trees'() {
6128
- $.$mol_assert_ok($.$mol_compare_deep({ a: { b: 1 } }, { a: { b: 1 } }));
6129
- },
6130
- 'different classes with same values'() {
6131
- class Obj {
6132
- foo = 1;
6120
+ 'Non POJO are different'() {
6121
+ class Thing extends Object {
6133
6122
  }
6134
- const a = new Obj;
6135
- const b = new class extends Obj {
6136
- };
6137
- $.$mol_assert_not($.$mol_compare_deep(a, b));
6123
+ $.$mol_assert_not($.$mol_compare_deep(new Thing, new Thing));
6124
+ $.$mol_assert_not($.$mol_compare_deep(() => 1, () => 1));
6125
+ $.$mol_assert_not($.$mol_compare_deep(new RangeError('Test error'), new RangeError('Test error')));
6138
6126
  },
6139
6127
  'same POJOs with cyclic reference'() {
6140
6128
  const a = { foo: {} };
@@ -6143,41 +6131,6 @@ var $;
6143
6131
  b['self'] = b;
6144
6132
  $.$mol_assert_ok($.$mol_compare_deep(a, b));
6145
6133
  },
6146
- 'empty Element'() {
6147
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("div", null)));
6148
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null), $.$mol_jsx("span", null)));
6149
- },
6150
- 'Element with attributes'() {
6151
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "rtl" })));
6152
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", null)));
6153
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { dir: "rtl" }), $.$mol_jsx("div", { dir: "ltr" })));
6154
- },
6155
- 'Element with styles'() {
6156
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'red' } })));
6157
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: {} })));
6158
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { style: { color: 'red' } }), $.$mol_jsx("div", { style: { color: 'blue' } })));
6159
- },
6160
- 'Element with content'() {
6161
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", null,
6162
- "foo",
6163
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
6164
- "foo",
6165
- $.$mol_jsx("br", null))));
6166
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
6167
- "foo",
6168
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
6169
- "bar",
6170
- $.$mol_jsx("br", null))));
6171
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", null,
6172
- "foo",
6173
- $.$mol_jsx("br", null)), $.$mol_jsx("div", null,
6174
- "foo",
6175
- $.$mol_jsx("hr", null))));
6176
- },
6177
- 'Element with handlers'() {
6178
- $.$mol_assert_ok($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 1 })));
6179
- $.$mol_assert_not($.$mol_compare_deep($.$mol_jsx("div", { onclick: () => 1 }), $.$mol_jsx("div", { onclick: () => 2 })));
6180
- },
6181
6134
  'Date'() {
6182
6135
  $.$mol_assert_ok($.$mol_compare_deep(new Date(12345), new Date(12345)));
6183
6136
  $.$mol_assert_not($.$mol_compare_deep(new Date(12345), new Date(12346)));
@@ -6189,8 +6142,9 @@ var $;
6189
6142
  },
6190
6143
  'Map'() {
6191
6144
  $.$mol_assert_ok($.$mol_compare_deep(new Map, new Map));
6192
- $.$mol_assert_ok($.$mol_compare_deep(new Map([[[1], [2]]]), new Map([[[1], [2]]])));
6145
+ $.$mol_assert_ok($.$mol_compare_deep(new Map([[1, [2]]]), new Map([[1, [2]]])));
6193
6146
  $.$mol_assert_not($.$mol_compare_deep(new Map([[1, 2]]), new Map([[1, 3]])));
6147
+ $.$mol_assert_not($.$mol_compare_deep(new Map([[[1], 2]]), new Map([[[1], 2]])));
6194
6148
  },
6195
6149
  'Set'() {
6196
6150
  $.$mol_assert_ok($.$mol_compare_deep(new Set, new Set));
@@ -6209,97 +6163,118 @@ var $;
6209
6163
  "use strict";
6210
6164
  var $;
6211
6165
  (function ($) {
6212
- const a_stack = [];
6213
- const b_stack = [];
6214
- let cache = null;
6215
- function $mol_compare_deep(a, b) {
6216
- if (Object.is(a, b))
6166
+ let cache = new WeakMap();
6167
+ function $mol_compare_deep(left, right) {
6168
+ if (Object.is(left, right))
6217
6169
  return true;
6218
- const a_type = typeof a;
6219
- const b_type = typeof b;
6220
- if (a_type !== b_type)
6170
+ if (left === null)
6221
6171
  return false;
6222
- if (a_type === 'function')
6223
- return a['toString']() === b['toString']();
6224
- if (a_type !== 'object')
6172
+ if (right === null)
6225
6173
  return false;
6226
- if (!a || !b)
6174
+ if (typeof left !== 'object')
6227
6175
  return false;
6228
- if (a instanceof Error)
6176
+ if (typeof right !== 'object')
6229
6177
  return false;
6230
- if (a['constructor'] !== b['constructor'])
6178
+ const left_proto = Reflect.getPrototypeOf(left);
6179
+ const right_proto = Reflect.getPrototypeOf(right);
6180
+ if (left_proto !== right_proto)
6231
6181
  return false;
6232
- if (a instanceof RegExp)
6233
- return a.toString() === b['toString']();
6234
- const ref = a_stack.indexOf(a);
6235
- if (ref >= 0) {
6236
- return Object.is(b_stack[ref], b);
6237
- }
6238
- if (!cache)
6239
- cache = new WeakMap;
6240
- let a_cache = cache.get(a);
6241
- if (a_cache) {
6242
- const b_cache = a_cache.get(b);
6243
- if (typeof b_cache === 'boolean')
6244
- return b_cache;
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;
6245
6197
  }
6246
6198
  else {
6247
- a_cache = new WeakMap();
6248
- cache.set(a, a_cache);
6199
+ left_cache = new WeakMap([[right, true]]);
6200
+ cache.set(left, left_cache);
6249
6201
  }
6250
- a_stack.push(a);
6251
- b_stack.push(b);
6252
6202
  let result;
6253
6203
  try {
6254
- if (Symbol.iterator in a) {
6255
- const a_iter = a[Symbol.iterator]();
6256
- const b_iter = b[Symbol.iterator]();
6257
- while (true) {
6258
- const a_next = a_iter.next();
6259
- const b_next = b_iter.next();
6260
- if (a_next.done !== b_next.done)
6261
- return result = false;
6262
- if (a_next.done)
6263
- break;
6264
- if (!$mol_compare_deep(a_next.value, b_next.value))
6265
- return result = false;
6266
- }
6267
- return result = true;
6268
- }
6269
- let count = 0;
6270
- for (let key in a) {
6271
- try {
6272
- if (!$mol_compare_deep(a[key], b[key]))
6273
- return result = false;
6274
- }
6275
- catch (error) {
6276
- $.$mol_fail_hidden(new $.$mol_error_mix(`Failed ${JSON.stringify(key)} fields comparison of ${a} and ${b}`, error));
6277
- }
6278
- ++count;
6279
- }
6280
- for (let key in b) {
6281
- --count;
6282
- if (count < 0)
6283
- return result = false;
6284
- }
6285
- if (a instanceof Number || a instanceof String || a instanceof Symbol || a instanceof Boolean || a instanceof Date) {
6286
- if (!Object.is(a['valueOf'](), b['valueOf']()))
6287
- return result = false;
6288
- }
6289
- return result = true;
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;
6290
6216
  }
6291
6217
  finally {
6292
- a_stack.pop();
6293
- b_stack.pop();
6294
- if (a_stack.length === 0) {
6295
- cache = null;
6296
- }
6297
- else {
6298
- a_cache.set(b, result);
6299
- }
6218
+ left_cache.set(right, result);
6300
6219
  }
6220
+ return result;
6301
6221
  }
6302
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
+ }
6303
6278
  })($ || ($ = {}));
6304
6279
  //deep.js.map
6305
6280
  ;
@@ -7474,92 +7449,6 @@ var $;
7474
7449
  ;
7475
7450
  "use strict";
7476
7451
  var $;
7477
- (function ($) {
7478
- $.$mol_test({
7479
- 'equal paths'() {
7480
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]);
7481
- $.$mol_assert_like(diff, {
7482
- prefix: [1, 2, 3, 4],
7483
- suffix: [[], [], []],
7484
- });
7485
- },
7486
- 'different suffix'() {
7487
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2, 3, 5], [1, 2, 5, 4]);
7488
- $.$mol_assert_like(diff, {
7489
- prefix: [1, 2],
7490
- suffix: [[3, 4], [3, 5], [5, 4]],
7491
- });
7492
- },
7493
- 'one contains other'() {
7494
- const diff = $.$mol_diff_path([1, 2, 3, 4], [1, 2], [1, 2, 3]);
7495
- $.$mol_assert_like(diff, {
7496
- prefix: [1, 2],
7497
- suffix: [[3, 4], [], [3]],
7498
- });
7499
- },
7500
- 'fully different'() {
7501
- const diff = $.$mol_diff_path([1, 2], [3, 4], [5, 6]);
7502
- $.$mol_assert_like(diff, {
7503
- prefix: [],
7504
- suffix: [[1, 2], [3, 4], [5, 6]],
7505
- });
7506
- },
7507
- });
7508
- })($ || ($ = {}));
7509
- //path.test.js.map
7510
- ;
7511
- "use strict";
7512
- var $;
7513
- (function ($) {
7514
- function $mol_diff_path(...paths) {
7515
- const limit = Math.min(...paths.map(path => path.length));
7516
- lookup: for (var i = 0; i < limit; ++i) {
7517
- const first = paths[0][i];
7518
- for (let j = 1; j < paths.length; ++j) {
7519
- if (paths[j][i] !== first)
7520
- break lookup;
7521
- }
7522
- }
7523
- return {
7524
- prefix: paths[0].slice(0, i),
7525
- suffix: paths.map(path => path.slice(i)),
7526
- };
7527
- }
7528
- $.$mol_diff_path = $mol_diff_path;
7529
- })($ || ($ = {}));
7530
- //path.js.map
7531
- ;
7532
- "use strict";
7533
- var $;
7534
- (function ($) {
7535
- class $mol_error_mix extends Error {
7536
- errors;
7537
- constructor(message, ...errors) {
7538
- super(message);
7539
- this.errors = errors;
7540
- if (errors.length) {
7541
- const stacks = [...errors.map(error => error.stack), this.stack];
7542
- const diff = $.$mol_diff_path(...stacks.map(stack => {
7543
- if (!stack)
7544
- return [];
7545
- return stack.split('\n').reverse();
7546
- }));
7547
- const head = diff.prefix.reverse().join('\n');
7548
- const tails = diff.suffix.map(path => path.reverse().map(line => line.replace(/^(?!\s+at)/, '\tat (.) ')).join('\n')).join('\n\tat (.) -----\n');
7549
- this.stack = `Error: ${this.constructor.name}\n\tat (.) /"""\\\n${tails}\n\tat (.) \\___/\n${head}`;
7550
- this.message += errors.map(error => '\n' + error.message).join('');
7551
- }
7552
- }
7553
- toJSON() {
7554
- return this.message;
7555
- }
7556
- }
7557
- $.$mol_error_mix = $mol_error_mix;
7558
- })($ || ($ = {}));
7559
- //mix.js.map
7560
- ;
7561
- "use strict";
7562
- var $;
7563
7452
  (function ($) {
7564
7453
  class $mol_view_tree_test_attributes_super extends $.$mol_view {
7565
7454
  some() {