Last active
January 9, 2023 03:04
-
-
Save JetLua/c89b2b175ff2172cbcfd1ec9bfa55cd8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function pureObject(o: unknown) { | |
if (!isObject(o)) return false | |
const ctor = o.constructor | |
if (ctor == null) return true | |
const prot = ctor.prototype | |
if (!isObject(prot)) return false | |
if (!Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf')) return false | |
return true | |
} | |
function isObject(o: unknown) { | |
return Object.prototype.toString.call(o) === '[object Object]' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment