packages/babel-types/src/utils/shallowEqual.ts
raw| 1 | export default function shallowEqual<T extends object>( |
| 2 | actual: object, |
| 3 | expected: T, |
| 4 | ): actual is T { |
| 5 | const keys = Object.keys(expected) as (keyof T)[]; |
| 6 | |
| 7 | for (const key of keys) { |
| 8 | if ( |
| 9 | // @ts-expect-error maybe we should check whether key exists first |
| 10 | actual[key] !== expected[key] |
| 11 | ) { |
| 12 | return false; |
| 13 | } |
| 14 | } |
| 15 | |
| 16 | return true; |
| 17 | } |