MCPcopy Index your code
hub / github.com/TanStack/query / isPlainObject

Function isPlainObject

packages/query-core/src/utils.ts:328–357  ·  view source on GitHub ↗
(o: any)

Source from the content-addressed store, hash-verified

326
327// Copied from: https://github.com/jonschlinkert/is-plain-object
328export 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
359function hasObjectPrototype(o: any): boolean {
360 return Object.prototype.toString.call(o) === '[object Object]'

Callers 3

utils.test.tsxFile · 0.90
hashKeyFunction · 0.70
replaceEqualDeepFunction · 0.70

Calls 1

hasObjectPrototypeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…