MCPcopy Create free account
hub / github.com/zenstackhq/zenstack / isPlainObject

Function isPlainObject

packages/common-helpers/src/is-plain-object.ts:5–23  ·  view source on GitHub ↗
(o: unknown)

Source from the content-addressed store, hash-verified

3}
4
5export function isPlainObject(o: unknown) {
6 if (isObject(o) === false) return false;
7
8 // If has modified constructor
9 const ctor = (o as { constructor: unknown }).constructor;
10 if (ctor === undefined) return true;
11
12 // If has modified prototype
13 const prot = (ctor as { prototype: unknown }).prototype;
14 if (isObject(prot) === false) return false;
15
16 // If constructor does not have an Object-specific method
17 if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOf') === false) {
18 return false;
19 }
20
21 // Most likely a plain Object
22 return true;
23}

Callers 5

cloneFunction · 0.90
buildStandardFilterFunction · 0.90
doNormalizeArgsFunction · 0.90
isEmptyObjectFunction · 0.90

Calls 1

isObjectFunction · 0.85

Tested by

no test coverage detected