MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / cloneObject

Method cloneObject

src/LiteGraphGlobal.ts:621–632  ·  view source on GitHub ↗

@deprecated Prefer structuredClone

(obj: T, target?: T)

Source from the content-addressed store, hash-verified

619 // separated just to improve if it doesn't work
620 /** @deprecated Prefer {@link structuredClone} */
621 cloneObject<T extends object | undefined | null>(obj: T, target?: T): WhenNullish<T, null> {
622 if (obj == null) return null as WhenNullish<T, null>
623
624 const r = JSON.parse(JSON.stringify(obj))
625 if (!target) return r
626
627 for (const i in r) {
628 // @ts-expect-error deprecated
629 target[i] = r[i]
630 }
631 return target
632 }
633
634 /** @see {@link createUuidv4} @inheritdoc */
635 uuidv4 = createUuidv4

Callers 4

configureMethod · 0.80
serializeMethod · 0.80
cloneMethod · 0.80
multiCloneFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected