(key: any, newValue: any)
| 69 | // key must be a suitable weakmap key. pass the new value |
| 70 | // it will return the prevValue (for object equality) if the new value is deep equal to the prev value |
| 71 | function deepCompareReturnPrev(key: any, newValue: any): any { |
| 72 | if (key == null) { |
| 73 | return newValue; |
| 74 | } |
| 75 | const previousValue = prevValueCache.get(key); |
| 76 | if (previousValue !== undefined && JSON.stringify(newValue) === JSON.stringify(previousValue)) { |
| 77 | return previousValue; |
| 78 | } |
| 79 | prevValueCache.set(key, newValue); |
| 80 | return newValue; |
| 81 | } |
| 82 | |
| 83 | // works for json-like objects (arrays, objects, strings, numbers, booleans) |
| 84 | function jsonDeepEqual(v1: any, v2: any): boolean { |
no test coverage detected