MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / mergeObjects

Function mergeObjects

src/utils/utils.ts:271–294  ·  view source on GitHub ↗
(target: T, source: Partial<T>)

Source from the content-addressed store, hash-verified

269}
270
271export function mergeObjects<T>(target: T, source: Partial<T>): T {
272 for (const key in source) {
273 if (Object.prototype.hasOwnProperty.call(source, key)) {
274 const sourceValue = source[key]
275 const targetValue = target[key]
276
277 if (typeof sourceValue === 'object' && !Array.isArray(sourceValue) && sourceValue !== null) {
278 if (
279 typeof targetValue === 'object' &&
280 !Array.isArray(targetValue) &&
281 targetValue !== null
282 ) {
283 target[key] = mergeObjects(targetValue, sourceValue)
284 } else {
285 target[key] = sourceValue as T[Extract<keyof T, string>]
286 }
287 } else {
288 // 如果不是对象,则直接覆盖
289 target[key] = sourceValue as T[Extract<keyof T, string>]
290 }
291 }
292 }
293 return target
294}
295
296export async function restartSelf() {
297 await invoke('restart_self')

Callers 2

modifyOpenlistConfigFunction · 0.90
readNmConfigFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected