MCPcopy Index your code
hub / github.com/gridstack/gridstack.js / clone

Method clone

src/utils.ts:612–622  ·  view source on GitHub ↗

single level clone, returning a new object with same top fields. This will share sub objects and arrays

(obj: T)

Source from the content-addressed store, hash-verified

610
611 /** single level clone, returning a new object with same top fields. This will share sub objects and arrays */
612 static clone<T>(obj: T): T {
613 if (obj === null || obj === undefined || typeof(obj) !== 'object') {
614 return obj;
615 }
616 // return Object.assign({}, obj);
617 if (obj instanceof Array) {
618 // eslint-disable-next-line @typescript-eslint/no-explicit-any
619 return [...obj] as any;
620 }
621 return {...obj};
622 }
623
624 /**
625 * Recursive clone version that returns a full copy, checking for nested objects and arrays ONLY.

Callers 2

cloneDeepMethod · 0.80
utils-spec.tsFile · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected