MCPcopy Create free account
hub / github.com/wavetermdev/waveterm / deepCompareReturnPrev

Function deepCompareReturnPrev

frontend/util/util.ts:71–81  ·  view source on GitHub ↗
(key: any, newValue: any)

Source from the content-addressed store, hash-verified

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
71function 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)
84function jsonDeepEqual(v1: any, v2: any): boolean {

Callers 1

getSettingsPrefixAtomFunction · 0.90

Calls 2

getMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected