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