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

Function deepMergeSnapshot

packages/snapshot/src/port/utils.ts:211–237  ·  view source on GitHub ↗
(target: any, source: any)

Source from the content-addressed store, hash-verified

209 * ```
210 */
211export function deepMergeSnapshot(target: any, source: any): any {
212 if (isObject(target) && isObject(source)) {
213 const mergedOutput = { ...target }
214 Object.keys(source).forEach((key) => {
215 if (isObject(source[key]) && !source[key].$$typeof) {
216 if (!(key in target)) {
217 Object.assign(mergedOutput, { [key]: source[key] })
218 }
219 else {
220 mergedOutput[key] = deepMergeSnapshot(target[key], source[key])
221 }
222 }
223 else if (Array.isArray(source[key])) {
224 mergedOutput[key] = deepMergeArray(target[key], source[key])
225 }
226 else {
227 Object.assign(mergedOutput, { [key]: source[key] })
228 }
229 })
230
231 return mergedOutput
232 }
233 else if (Array.isArray(target) && Array.isArray(source)) {
234 return deepMergeArray(target, source)
235 }
236 return target
237}
238
239export class DefaultMap<K, V> extends Map<K, V> {
240 constructor(

Callers 3

matchMethod · 0.90
utils.spec.tsFile · 0.90
deepMergeArrayFunction · 0.85

Calls 3

isObjectFunction · 0.90
deepMergeArrayFunction · 0.85
keysMethod · 0.80

Tested by

no test coverage detected