MCPcopy Create free account
hub / github.com/editablejs/editable / isPlainObject

Function isPlainObject

packages/yjs-transform/src/object.ts:7–31  ·  view source on GitHub ↗
(o: unknown)

Source from the content-addressed store, hash-verified

5}
6
7export function isPlainObject(o: unknown): o is InspectableObject {
8 if (!isObject(o)) {
9 return false
10 }
11
12 // If has modified constructor
13 const ctor = o.constructor
14 if (ctor === undefined) {
15 return true
16 }
17
18 // If has modified prototype
19 const prot = ctor.prototype
20 if (isObject(prot) === false) {
21 return false
22 }
23
24 // If constructor does not have an Object-specific method
25 if (prot.hasOwnProperty('isPrototypeOf') === false) {
26 return false
27 }
28
29 // Most likely a plain Object
30 return true
31}
32
33// Slates deep equality function: https://github.com/ianstormtaylor/slate/blob/68aff89e892fe15a16314398ff052ade6068900b/packages/slate/src/utils/deep-equal.ts#L13
34// We have to match slates deepEquals behavior to merge insert deltas in the same way slate does.

Callers 2

deepEqualsFunction · 0.85
isHistoryStackFunction · 0.85

Calls 1

isObjectFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…