MCPcopy
hub / github.com/bbycroft/llm-viz / assignImm

Function assignImm

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

Source from the content-addressed store, hash-verified

15}
16
17export function assignImm<T>(target: T, source: Partial<T>): T {
18 let keys = Object.keys(source);
19 let changed = false;
20 target = target ?? {} as any;
21 for (let k of keys) {
22 let src = (source as any)[k];
23 let dst = (target as any)[k];
24 if ((src === dst) ||
25 (src instanceof Date && dst instanceof Date && +src === +dst) ||
26 (src instanceof Vec3 && dst instanceof Vec3 && src.distSq(dst) === 0.0)
27 ) {
28 continue;
29 }
30 changed = true;
31 }
32 return changed ? Object.assign({}, target, source) : target;
33}
34
35export function assignImmFull<T>(target: T | null, source: T | null): T | null {
36 return source && target ? assignImm(target, source) : source;

Callers 15

TooltipFunction · 0.90
handleChangeFunction · 0.90
WelcomePopupFunction · 0.90
hideFunction · 0.90
onCreateEditClickedFunction · 0.90
handleResizeFunction · 0.90
resizeCompBoxFunction · 0.90
movePortToNewLocationFunction · 0.90
wiresFromLsStateFunction · 0.90
handleWireCreateDragFunction · 0.90

Calls 1

distSqMethod · 0.45

Tested by

no test coverage detected