MCPcopy Create free account
hub / github.com/activejs/activejs / deepCopy

Function deepCopy

packages/core/src/utils/funcs.ts:111–125  ·  view source on GitHub ↗
(o: T)

Source from the content-addressed store, hash-verified

109 * @category Global
110 */
111export function deepCopy<T>(o: T): T {
112 if (o == null || typeof o !== 'object') {
113 return o;
114 }
115 if (Array.isArray(o)) {
116 return (o as any).map(v => deepCopy(v));
117 }
118 if (isDict(o)) {
119 return Object.keys(o).reduce((newO, k) => {
120 newO[k] = deepCopy(o[k]);
121 return newO;
122 }, {} as T);
123 }
124 return o;
125}
126
127/**
128 * @internal please do not use.

Callers 4

deepCopyMaybeFunction · 0.90
extras.spec.tsFile · 0.90
dict-unit.spec.tsFile · 0.90
list-unit.spec.tsFile · 0.90

Calls 1

isDictFunction · 0.85

Tested by

no test coverage detected