MCPcopy Create free account
hub / github.com/SvelteStack/svelte-query / isPlainObject

Function isPlainObject

src/queryCore/core/utils.ts:393–417  ·  view source on GitHub ↗
(o: any)

Source from the content-addressed store, hash-verified

391
392// Copied from: https://github.com/jonschlinkert/is-plain-object
393export function isPlainObject(o: any): o is Object {
394 if (!hasObjectPrototype(o)) {
395 return false
396 }
397
398 // If has modified constructor
399 const ctor = o.constructor
400 if (typeof ctor === 'undefined') {
401 return true
402 }
403
404 // If has modified prototype
405 const prot = ctor.prototype
406 if (!hasObjectPrototype(prot)) {
407 return false
408 }
409
410 // If constructor does not have an Object-specific method
411 if (!prot.hasOwnProperty('isPrototypeOf')) {
412 return false
413 }
414
415 // Most likely a plain Object
416 return true
417}
418
419function hasObjectPrototype(o: any): boolean {
420 return Object.prototype.toString.call(o) === '[object Object]'

Callers 2

stableValueHashFunction · 0.85
replaceEqualDeepFunction · 0.85

Calls 1

hasObjectPrototypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…