Skip to content

Commit e9c8c66

Browse files
committed
[serialise] improve native object detection
1 parent bf86979 commit e9c8c66

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/serialize.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
function isNativeObject(value: object) {
2-
return /^\[object .+?Constructor]$/.test(Object.prototype.toString.call(value))
2+
return !!Reflect.ownKeys(global).map(key => (global as any)[key as string])
3+
.find(obj => obj?.constructor === value.constructor || obj === value.constructor || obj === value)
34
}
45

56
export const classes: Map<string, Function> = new Map()

0 commit comments

Comments
 (0)