-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(utils): deepCopy -> cloneDeep 네이밍 변경 및 기능 개선
- Loading branch information
Showing
12 changed files
with
109 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@modern-kit/utils': minor | ||
--- | ||
|
||
fix(utils): deepCopy -> cloneDeep 네이밍 변경 및 기능 개선 - @ssi02014 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# cloneDeep | ||
|
||
인자로 주어진 값을 `깊은 복사`를 수행하는 함수입니다. | ||
|
||
<br /> | ||
|
||
## Code | ||
[🔗 실제 구현 코드 확인](https://github.com/modern-agile-team/modern-kit/blob/main/packages/utils/src/common/cloneDeep/index.ts) | ||
|
||
## Benchmark | ||
- `hz`: 초당 작업 수 | ||
- `mean`: 평균 응답 시간(ms) | ||
|
||
|이름|hz|mean|성능| | ||
|------|---|---|---| | ||
|modern-kit/cloneDeep|1,529,157.20|0.0007|`fastest`| | ||
|lodash/cloneDeep|650,320.39|0.0015|-| | ||
|
||
- **modern-kit/cloneDeep** | ||
- `2.35x` faster than lodash/cloneDeep | ||
|
||
## Interface | ||
```ts title="typescript" | ||
function cloneDeep<T>(value: T): T | ||
``` | ||
|
||
## Usage | ||
```ts title="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); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { bench, describe } from 'vitest'; | ||
import { cloneDeep as cloneDeep } from '.'; | ||
import { cloneDeep as cloneDeepLodash } from 'lodash-es'; | ||
|
||
describe('cloneDeep', () => { | ||
bench('@modern-kit/cloneDeep', () => { | ||
cloneDeep({ a: 1, b: 2, c: { d: 4, e: [1, 2, 3] } }); | ||
}); | ||
|
||
bench('lodash/cloneDeep', () => { | ||
cloneDeepLodash({ a: 1, b: 2, c: { d: 4, e: [1, 2, 3] } }); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { deepCopy } from '../deepCopy'; | ||
import { cloneDeep } from '../cloneDeep'; | ||
|
||
export function wrapInArray<T>(value: T | T[]): T[] { | ||
const copiedValue = deepCopy(value); | ||
const copiedValue = cloneDeep(value); | ||
|
||
return Array.isArray(copiedValue) ? copiedValue : [copiedValue]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters