From 2796ef5170bd4f8518ef4f574c014ece2eb8ba5c Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Thu, 17 Oct 2024 18:15:32 +0200 Subject: [PATCH 1/2] feat: objectPlain Event handling --- src/common/data/object.ts | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/common/data/object.ts b/src/common/data/object.ts index 0359b8c..fb449cb 100644 --- a/src/common/data/object.ts +++ b/src/common/data/object.ts @@ -130,13 +130,37 @@ export function objectPlain(obj: any, opt?: { if (obj instanceof Set || isBinaryArray(obj)) obj = Array.from(obj as any) + if (typeof ErrorEvent !== 'undefined' && obj instanceof ErrorEvent) { + return { + __class: 'ErrorEvent', + message: obj.message, + filename: obj.filename, + lineno: obj.lineno, + colno: obj.colno, + error: obj.error ? handleObject(obj.error, depth + 1) : undefined, + } + } + + if (obj instanceof Event) { + return { + __class: 'Event', + type: obj.type, + eventPhase: obj.eventPhase, + bubbles: obj.bubbles, + cancelable: obj.cancelable, + defaultPrevented: obj.defaultPrevented, + composed: obj.composed, + timeStamp: obj.timeStamp, + } + } + if (obj instanceof Error) { return { __class: 'Error', name: obj.name, message: obj.message, stack: errorTrace ? obj.stack : undefined, - cause: (obj as any).cause ? String((obj as any).cause) : undefined, + cause: (obj as any).cause ? String((obj as any).cause) : undefined, } } // return `${obj.name || 'Error'}: ${obj.message}${errorTrace ? `\n${obj.stack}` : ''}` From d91b4c383ec51de7a6a12aea6fd197ed44b0646a Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Thu, 17 Oct 2024 18:15:36 +0200 Subject: [PATCH 2/2] 0.25.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b7d092..cca53e7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeed", "type": "module", - "version": "0.24.23", + "version": "0.25.0", "description": "🌱 Simple foundation library", "author": { "name": "Dirk Holtwick",