MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / cloneDeep

Function cloneDeep

packages/utils/src/clone-deep.ts:3–24  ·  view source on GitHub ↗
(src: any)

Source from the content-addressed store, hash-verified

1import { isPlainObject } from './is-plain-object';
2
3export function cloneDeep(src: any): any {
4 const type = typeof src;
5
6 let data: any;
7 if (src === null || src === undefined) {
8 data = src;
9 } else if (Array.isArray(src)) {
10 data = src.map(item => cloneDeep(item));
11 } else if (type === 'object' && isPlainObject(src)) {
12 data = {};
13 for (const key in src) {
14 // eslint-disable-next-line no-prototype-builtins
15 if (src.hasOwnProperty(key)) {
16 data[key] = cloneDeep(src[key]);
17 }
18 }
19 } else {
20 data = src;
21 }
22
23 return data;
24}

Callers 5

clone-deep.test.tsFile · 0.90
getHotValueMethod · 0.85
project.test.tsFile · 0.85
node.add.test.tsFile · 0.85

Calls 2

isPlainObjectFunction · 0.90
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…