(o: unknown)
| 3 | } |
| 4 | |
| 5 | export function isPlainObject(o: unknown) { |
| 6 | if (isObject(o) === false) return false; |
| 7 | |
| 8 | // If has modified constructor |
| 9 | const ctor = (o as { constructor: unknown }).constructor; |
| 10 | if (ctor === undefined) return true; |
| 11 | |
| 12 | // If has modified prototype |
| 13 | const prot = (ctor as { prototype: unknown }).prototype; |
| 14 | if (isObject(prot) === false) return false; |
| 15 | |
| 16 | // If constructor does not have an Object-specific method |
| 17 | if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) { |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | // Most likely a plain Object |
| 22 | return true; |
| 23 | } |
no test coverage detected