MCPcopy
hub / github.com/vitest-dev/vitest / deepMergeArray

Function deepMergeArray

packages/snapshot/src/port/utils.ts:178–197  ·  view source on GitHub ↗
(target: any[] = [], source: any[] = [])

Source from the content-addressed store, hash-verified

176}
177
178function deepMergeArray(target: any[] = [], source: any[] = []) {
179 const mergedOutput = Array.from(target)
180
181 source.forEach((sourceElement, index) => {
182 const targetElement = mergedOutput[index]
183
184 if (Array.isArray(target[index])) {
185 mergedOutput[index] = deepMergeArray(target[index], sourceElement)
186 }
187 else if (isObject(targetElement)) {
188 mergedOutput[index] = deepMergeSnapshot(target[index], sourceElement)
189 }
190 else {
191 // Source does not exist in target or target is primitive and cannot be deep merged
192 mergedOutput[index] = sourceElement
193 }
194 })
195
196 return mergedOutput
197}
198
199/**
200 * Deep merge, but considers asymmetric matchers. Unlike base util's deep merge,

Callers 1

deepMergeSnapshotFunction · 0.85

Calls 2

isObjectFunction · 0.90
deepMergeSnapshotFunction · 0.85

Tested by

no test coverage detected