Skip to main content

cloneDeep

인자로 주어진 값을 깊은 복사를 수행하는 함수입니다.


Code

🔗 실제 구현 코드 확인

Benchmark

  • hz: 초당 작업 수
  • mean: 평균 응답 시간(ms)
이름hzmean성능
modern-kit/cloneDeep1,529,157.200.0007fastest
lodash/cloneDeep650,320.390.0015-
  • modern-kit/cloneDeep
    • 2.35x faster than lodash/cloneDeep

Interface

typescript
function cloneDeep<T>(value: T): T

Usage

typescript
import { cloneDeep } from '@modern-kit/utils';

const originNum = 42;
const copyNum = cloneDeep(originNum);

const originObj = { a: 1, b: { c: 2 } };
const copyObj = cloneDeep(originObj);

const originArray = [1, 2, [3, 4]];
const copyArray = cloneDeep(originArray);

const originSet = new Set([1, 2, 3]);
const copySet = cloneDeep(originSet);

const originMap = new Map([
['a', 1],
['b', 2],
]);
const copyMap = cloneDeep(originMap);