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