(obj)
| 6 | * @returns {boolean} True if the argument appears to be a plain object. |
| 7 | */ |
| 8 | export default function isPlainObject(obj) { |
| 9 | if (!obj || typeof obj !== 'object') { |
| 10 | return false; |
| 11 | } |
| 12 | |
| 13 | const proto = |
| 14 | typeof obj.constructor === 'function' |
| 15 | ? Object.getPrototypeOf(obj) |
| 16 | : Object.prototype; |
| 17 | |
| 18 | if (proto === null) { |
| 19 | return true; |
| 20 | } |
| 21 | |
| 22 | const constructor = proto.constructor; |
| 23 | |
| 24 | return ( |
| 25 | typeof constructor === 'function' && |
| 26 | constructor instanceof constructor && |
| 27 | fnToString(constructor) === fnToString(Object) |
| 28 | ); |
| 29 | } |
no test coverage detected