From 8a939bfcb9645c9ce6a9c8ebb5aa161e5f84e2c3 Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Fri, 8 Nov 2024 12:18:59 +0100 Subject: [PATCH 1/2] fix: add checks for undefined types before instance checks in objectPlain function --- src/common/data/object.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/common/data/object.ts b/src/common/data/object.ts index fb449cb..afbf6c7 100644 --- a/src/common/data/object.ts +++ b/src/common/data/object.ts @@ -110,24 +110,24 @@ export function objectPlain(obj: any, opt?: { if (isPrimitive(obj)) return obj - if (obj instanceof Date) { + if (typeof Date !== 'undefined' && obj instanceof Date) { return { __class: 'Date', value: obj.toISOString(), } } - if (obj instanceof RegExp) { + if (typeof RegExp !== 'undefined' && obj instanceof RegExp) { return { __class: 'RegExp', source: obj.toString(), } } - if (obj instanceof Map) + if (typeof Map !== 'undefined' && obj instanceof Map) obj = Object.fromEntries(obj) - if (obj instanceof Set || isBinaryArray(obj)) + if (typeof Set !== 'undefined' && obj instanceof Set || isBinaryArray(obj)) obj = Array.from(obj as any) if (typeof ErrorEvent !== 'undefined' && obj instanceof ErrorEvent) { @@ -141,7 +141,7 @@ export function objectPlain(obj: any, opt?: { } } - if (obj instanceof Event) { + if (typeof Event !== 'undefined' && obj instanceof Event) { return { __class: 'Event', type: obj.type, @@ -150,17 +150,17 @@ export function objectPlain(obj: any, opt?: { cancelable: obj.cancelable, defaultPrevented: obj.defaultPrevented, composed: obj.composed, - timeStamp: obj.timeStamp, + timeStamp: obj.timeStamp, } } - if (obj instanceof Error) { + if (typeof Error !== 'undefined' && 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 d5392d1d7e2c7ff8042142e36b7785bb4a7e1e68 Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Fri, 8 Nov 2024 12:19:03 +0100 Subject: [PATCH 2/2] 0.26.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index abd3f6c..cd15bdd 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeed", "type": "module", - "version": "0.26.0", + "version": "0.26.1", "description": "🌱 Simple foundation library", "author": { "name": "Dirk Holtwick",