mol_plot_all 1.2.1645 → 1.2.1647

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.js CHANGED
@@ -371,6 +371,14 @@ var $;
371
371
  ;
372
372
  "use strict";
373
373
 
374
+ ;
375
+ "use strict";
376
+ var $;
377
+ (function ($) {
378
+ $.$mol_key_handle = Symbol.for('$mol_key_handle');
379
+ $.$mol_key_store = new WeakMap();
380
+ })($ || ($ = {}));
381
+
374
382
  ;
375
383
  "use strict";
376
384
  var $;
@@ -407,6 +415,9 @@ var $;
407
415
  static toJSON() {
408
416
  return this.toString();
409
417
  }
418
+ static [$mol_key_handle]() {
419
+ return this.toString();
420
+ }
410
421
  destructor() { }
411
422
  static destructor() { }
412
423
  [Symbol.dispose]() {
@@ -2398,46 +2409,50 @@ var $;
2398
2409
  "use strict";
2399
2410
  var $;
2400
2411
  (function ($) {
2401
- $.$mol_key_store = new WeakMap();
2402
2412
  const TypedArray = Object.getPrototypeOf(Uint8Array);
2403
2413
  function $mol_key(value) {
2404
- if (typeof value === 'bigint')
2405
- return value.toString() + 'n';
2406
- if (typeof value === 'symbol')
2407
- return value.description;
2408
- if (!value)
2409
- return JSON.stringify(value);
2410
- if (typeof value !== 'object' && typeof value !== 'function')
2411
- return JSON.stringify(value);
2412
- return JSON.stringify(value, (field, value) => {
2414
+ primitives: {
2413
2415
  if (typeof value === 'bigint')
2414
2416
  return value.toString() + 'n';
2415
2417
  if (typeof value === 'symbol')
2416
- return value.description;
2418
+ return `Symbol(${value.description})`;
2417
2419
  if (!value)
2418
- return value;
2420
+ return JSON.stringify(value);
2419
2421
  if (typeof value !== 'object' && typeof value !== 'function')
2420
- return value;
2422
+ return JSON.stringify(value);
2423
+ }
2424
+ caching: {
2425
+ let key = $mol_key_store.get(value);
2426
+ if (key)
2427
+ return key;
2428
+ }
2429
+ objects: {
2430
+ if (value instanceof TypedArray) {
2431
+ return `${value[Symbol.toStringTag]}([${[...value].map(v => $mol_key(v))}])`;
2432
+ }
2421
2433
  if (Array.isArray(value))
2422
- return value;
2423
- const proto = Reflect.getPrototypeOf(value);
2424
- if (!proto)
2425
- return value;
2426
- if (Reflect.getPrototypeOf(proto) === null)
2427
- return value;
2428
- if ('toJSON' in value)
2429
- return value;
2434
+ return `[${value.map(v => $mol_key(v))}]`;
2430
2435
  if (value instanceof RegExp)
2431
2436
  return value.toString();
2432
- if (value instanceof TypedArray)
2433
- return [...value];
2434
- let key = $.$mol_key_store.get(value);
2435
- if (key)
2436
- return key;
2437
- key = $mol_guid();
2438
- $.$mol_key_store.set(value, key);
2437
+ if (value instanceof Date)
2438
+ return `Date(${value.valueOf()})`;
2439
+ }
2440
+ structures: {
2441
+ const proto = Reflect.getPrototypeOf(value);
2442
+ if (!proto || !Reflect.getPrototypeOf(proto)) {
2443
+ return `{${Object.entries(value).map(([k, v]) => JSON.stringify(k) + ':' + $mol_key(v))}}`;
2444
+ }
2445
+ }
2446
+ handlers: {
2447
+ if ($mol_key_handle in value) {
2448
+ return value[$mol_key_handle]();
2449
+ }
2450
+ }
2451
+ containers: {
2452
+ const key = JSON.stringify('#' + $mol_guid());
2453
+ $mol_key_store.set(value, key);
2439
2454
  return key;
2440
- });
2455
+ }
2441
2456
  }
2442
2457
  $.$mol_key = $mol_key;
2443
2458
  })($ || ($ = {}));
@@ -2596,8 +2611,15 @@ var $;
2596
2611
  (this.host ?? this.task)[this.field()] = null;
2597
2612
  }
2598
2613
  else {
2599
- ;
2600
- (this.host ?? this.task)[this.field()].delete($mol_key(this.args[0]));
2614
+ const key = $mol_key(this.args[0]);
2615
+ const map = (this.host ?? this.task)[this.field()];
2616
+ if (!map.has(key))
2617
+ this.$.$mol_log3_warn({
2618
+ place: this,
2619
+ message: 'Absent key on destruction',
2620
+ hint: 'Check for $mol_key(key) is not changed',
2621
+ });
2622
+ map.delete(key);
2601
2623
  }
2602
2624
  }
2603
2625
  put(next) {