MCPcopy
hub / github.com/Tencent/westore / syncKeys

Function syncKeys

packages/westore/index.common.js:14–34  ·  view source on GitHub ↗
(current, previous)

Source from the content-addressed store, hash-verified

12}
13
14function syncKeys(current, previous) {
15 if (current === previous) return
16 const rootCurrentType = getType(current)
17 const rootPreType = getType(previous)
18 if (rootCurrentType == OBJECTTYPE && rootPreType == OBJECTTYPE) {
19 for (let key in previous) {
20 const currentValue = current[key]
21 if (currentValue === undefined) {
22 current[key] = null
23 } else {
24 syncKeys(currentValue, previous[key])
25 }
26 }
27 } else if (rootCurrentType == ARRAYTYPE && rootPreType == ARRAYTYPE) {
28 if (current.length >= previous.length) {
29 previous.forEach((item, index) => {
30 syncKeys(current[index], item)
31 })
32 }
33 }
34}
35
36function _diff(current, previous, path, result) {
37 if (current === previous) return

Callers 1

diffDataFunction · 0.70

Calls 1

getTypeFunction · 0.70

Tested by

no test coverage detected