(o: any)
| 326 | |
| 327 | // Copied from: https://github.com/jonschlinkert/is-plain-object |
| 328 | export function isPlainObject(o: any): o is Record<PropertyKey, unknown> { |
| 329 | if (!hasObjectPrototype(o)) { |
| 330 | return false |
| 331 | } |
| 332 | |
| 333 | // If has no constructor |
| 334 | const ctor = o.constructor |
| 335 | if (ctor === undefined) { |
| 336 | return true |
| 337 | } |
| 338 | |
| 339 | // If has modified prototype |
| 340 | const prot = ctor.prototype |
| 341 | if (!hasObjectPrototype(prot)) { |
| 342 | return false |
| 343 | } |
| 344 | |
| 345 | // If constructor does not have an Object-specific method |
| 346 | if (!prot.hasOwnProperty('isPrototypeOf')) { |
| 347 | return false |
| 348 | } |
| 349 | |
| 350 | // Handles Objects created by Object.create(<arbitrary prototype>) |
| 351 | if (Object.getPrototypeOf(o) !== Object.prototype) { |
| 352 | return false |
| 353 | } |
| 354 | |
| 355 | // Most likely a plain Object |
| 356 | return true |
| 357 | } |
| 358 | |
| 359 | function hasObjectPrototype(o: any): boolean { |
| 360 | return Object.prototype.toString.call(o) === '[object Object]' |
no test coverage detected
searching dependent graphs…