(node: InspectableObject, another: InspectableObject)
| 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. |
| 35 | export function deepEquals(node: InspectableObject, another: InspectableObject): boolean { |
| 36 | // eslint-disable-next-line guard-for-in |
| 37 | for (const key in node) { |
| 38 | const a = node[key] |
| 39 | const b = another[key] |
| 40 | |
| 41 | if (isPlainObject(a) && isPlainObject(b)) { |
| 42 | if (!deepEquals(a, b)) { |
| 43 | return false |
| 44 | } |
| 45 | } else if (Array.isArray(a) && Array.isArray(b)) { |
| 46 | if (a.length !== b.length) return false |
| 47 | for (let i = 0; i < a.length; i++) { |
| 48 | if (a[i] !== b[i]) { |
| 49 | return false |
| 50 | } |
| 51 | } |
| 52 | } else if (a !== b) { |
| 53 | return false |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | for (const key in another) { |
| 58 | if (node[key] === undefined && another[key] !== undefined) { |
| 59 | return false |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | return true |
| 64 | } |
| 65 | |
| 66 | export function pick<TObj extends Record<string, any>, TKeys extends keyof TObj>( |
| 67 | obj: TObj, |
no test coverage detected
searching dependent graphs…