(o: unknown)
| 5 | } |
| 6 | |
| 7 | export 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. |
no test coverage detected
searching dependent graphs…