(o: any)
| 350 | |
| 351 | // Copied from: https://github.com/jonschlinkert/is-plain-object |
| 352 | export function isPlainObject(o: any): o is Record<PropertyKey, unknown> { |
| 353 | if (!hasObjectPrototype(o)) { |
| 354 | return false |
| 355 | } |
| 356 | |
| 357 | // If has no constructor |
| 358 | const ctor = o.constructor |
| 359 | if (ctor === undefined) { |
| 360 | return true |
| 361 | } |
| 362 | |
| 363 | // If has modified prototype |
| 364 | const prot = ctor.prototype |
| 365 | if (!hasObjectPrototype(prot)) { |
| 366 | return false |
| 367 | } |
| 368 | |
| 369 | // If constructor does not have an Object-specific method |
| 370 | if (!prot.hasOwnProperty('isPrototypeOf')) { |
| 371 | return false |
| 372 | } |
| 373 | |
| 374 | // Handles Objects created by Object.create(<arbitrary prototype>) |
| 375 | if (Object.getPrototypeOf(o) !== Object.prototype) { |
| 376 | return false |
| 377 | } |
| 378 | |
| 379 | // Most likely a plain Object |
| 380 | return true |
| 381 | } |
| 382 | |
| 383 | function hasObjectPrototype(o: any): boolean { |
| 384 | return Object.prototype.toString.call(o) === '[object Object]' |
no test coverage detected