mol_crypto_lib 0.1.1391 → 0.1.1393

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.mjs CHANGED
@@ -365,17 +365,36 @@ require = (req => Object.assign(function require(name) {
365
365
  "use strict";
366
366
  var $;
367
367
  (function ($) {
368
+ function cause_serialize(cause) {
369
+ return JSON.stringify(cause, null, ' ')
370
+ .replace(/\(/, '<')
371
+ .replace(/\)/, ' >');
372
+ }
373
+ function frame_normalize(frame) {
374
+ return (typeof frame === 'string' ? frame : cause_serialize(frame))
375
+ .trim()
376
+ .replace(/at /gm, ' at ')
377
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
378
+ }
368
379
  class $mol_error_mix extends AggregateError {
369
380
  cause;
370
381
  name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
371
382
  constructor(message, cause = {}, ...errors) {
372
383
  super(errors, message, { cause });
373
384
  this.cause = cause;
374
- const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
385
+ const desc = Object.getOwnPropertyDescriptor(this, 'stack');
386
+ const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
375
387
  Object.defineProperty(this, 'stack', {
376
- get: () => (stack_get.call(this) ?? this.message) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
377
- .replace(/at /gm, ' at ')
378
- .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
388
+ get: () => stack_get() + '\n' + [
389
+ this.cause ?? 'no cause',
390
+ ...this.errors.flatMap(e => [
391
+ e.stack,
392
+ ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
393
+ ])
394
+ ].map(frame_normalize).join('\n')
395
+ });
396
+ Object.defineProperty(this, 'cause', {
397
+ get: () => cause
379
398
  });
380
399
  }
381
400
  static [Symbol.toPrimitive]() {
package/node.test.js CHANGED
@@ -356,17 +356,36 @@ require = (req => Object.assign(function require(name) {
356
356
  "use strict";
357
357
  var $;
358
358
  (function ($) {
359
+ function cause_serialize(cause) {
360
+ return JSON.stringify(cause, null, ' ')
361
+ .replace(/\(/, '<')
362
+ .replace(/\)/, ' >');
363
+ }
364
+ function frame_normalize(frame) {
365
+ return (typeof frame === 'string' ? frame : cause_serialize(frame))
366
+ .trim()
367
+ .replace(/at /gm, ' at ')
368
+ .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)');
369
+ }
359
370
  class $mol_error_mix extends AggregateError {
360
371
  cause;
361
372
  name = $$.$mol_func_name(this.constructor).replace(/^\$/, '') + '_Error';
362
373
  constructor(message, cause = {}, ...errors) {
363
374
  super(errors, message, { cause });
364
375
  this.cause = cause;
365
- const stack_get = Object.getOwnPropertyDescriptor(this, 'stack')?.get ?? (() => super.stack);
376
+ const desc = Object.getOwnPropertyDescriptor(this, 'stack');
377
+ const stack_get = () => desc?.get?.() ?? super.stack ?? desc?.value ?? this.message;
366
378
  Object.defineProperty(this, 'stack', {
367
- get: () => (stack_get.call(this) ?? this.message) + '\n' + [JSON.stringify(this.cause, null, ' ') ?? 'no cause', ...this.errors.map(e => e.stack)].map(e => e.trim()
368
- .replace(/at /gm, ' at ')
369
- .replace(/^(?! +at )(.*)/gm, ' at | $1 (#)')).join('\n')
379
+ get: () => stack_get() + '\n' + [
380
+ this.cause ?? 'no cause',
381
+ ...this.errors.flatMap(e => [
382
+ e.stack,
383
+ ...e instanceof $mol_error_mix || !e.cause ? [] : [e.cause]
384
+ ])
385
+ ].map(frame_normalize).join('\n')
386
+ });
387
+ Object.defineProperty(this, 'cause', {
388
+ get: () => cause
370
389
  });
371
390
  }
372
391
  static [Symbol.toPrimitive]() {