Skip to content

Commit

Permalink
docs: Update docs for cloneDeepWith
Browse files Browse the repository at this point in the history
  • Loading branch information
raon0211 committed Dec 1, 2024
1 parent d42fc96 commit 3393707
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/ja/reference/object/cloneDeepWith.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function cloneDeepWith<T>(
### パラメータ

- `obj` (`T`): クローンするオブジェクト。
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T | undefined, stack: Map<any, any>) => any`): 値をクローンする方法を示す関数。デフォルトの方法を使用せずに値をクローンして返すことができます。`undefined`を返すと、デフォルトの方法で値がクローンされます。
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any`): 値をクローンする方法を示す関数。デフォルトの方法を使用せずに値をクローンして返すことができます。`undefined`を返すと、デフォルトの方法で値がクローンされます。
- `value`: 現在クローンされている値。
- `key`: 現在クローンされている値のプロパティ名。
- `obj`: クローンする全体のオブジェクト `obj`
Expand Down
4 changes: 2 additions & 2 deletions docs/ko/reference/object/cloneDeepWith.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
```typescript
function cloneDeepWith<T>(
obj: T,
cloneValue: (value: any, key: PropertyKey | undefined, obj: T | undefined, stack: Map<any, any>) => any
cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any
): T;
```

### 파라미터

- `obj` (`T`): 복사할 객체.
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T | undefined, stack: Map<any, any>) => any`): 값을 복사하는 방법을 나타내는 함수. 기본 방법을 사용하지 않고 값을 복사해서 반환할 수 있어요. `undefined`를 반환하면 기본 방법으로 값이 복사돼요.
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any`): 값을 복사하는 방법을 나타내는 함수. 기본 방법을 사용하지 않고 값을 복사해서 반환할 수 있어요. `undefined`를 반환하면 기본 방법으로 값이 복사돼요.
- `value`: 현재 복사되고 있는 값.
- `key`: 현재 복사되고 있는 값에 대한 프로퍼티 이름.
- `obj`: 복사할 전체 객체 `obj`.
Expand Down
4 changes: 2 additions & 2 deletions docs/reference/object/cloneDeepWith.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ You can customize the deep cloning process using the `cloneValue` function. The
```typescript
function cloneDeepWith<T>(
obj: T,
cloneValue: (value: any, key: PropertyKey | undefined, obj: T | undefined, stack: Map<any, any>) => any
cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any
): T;
```

### Parameters

- `obj` (`T`): The object to clone.
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T | undefined, stack: Map<any, any>) => any`): A function that specifies how to clone the value. It can return a cloned value instead of using the default method. If it returns `undefined`, the default method is used to clone the value.
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any`): A function that specifies how to clone the value. It can return a cloned value instead of using the default method. If it returns `undefined`, the default method is used to clone the value.
- `value`: The current value being cloned.
- `key`: The property name of the current value being cloned.
- `obj`: The entire object `obj` to clone.
Expand Down
4 changes: 2 additions & 2 deletions docs/zh_hans/reference/object/cloneDeepWith.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
```typescript
function cloneDeepWith<T>(
obj: T,
cloneValue: (value: any, key: PropertyKey | undefined, obj: T | undefined, stack: Map<any, any>) => any
cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any
): T;
```

### 参数

- `obj` (`T`): 要克隆的对象。
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T | undefined, stack: Map<any, any>) => any`): 表示如何克隆值的函数。可以返回克隆后的值而不是使用默认方法。如果返回 `undefined`,则使用默认方法克隆值。
- `cloneValue` (`(value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any`): 表示如何克隆值的函数。可以返回克隆后的值而不是使用默认方法。如果返回 `undefined`,则使用默认方法克隆值。
- `value`: 当前正在克隆的值。
- `key`: 当前正在克隆的值的属性名。
- `obj`: 要克隆的整个对象 `obj`
Expand Down
17 changes: 9 additions & 8 deletions src/object/cloneDeepWith.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { isPrimitive } from '../predicate/isPrimitive.ts';
import { isTypedArray } from '../predicate/isTypedArray.ts';

/**
* Creates a deep clone of the given object using a customizer function.
* Deeply clones the given object.
*
* You can customize the deep cloning process using the `cloneValue` function.
* The function takes the current value `value`, the property name `key`, and the entire object `obj` as arguments.
* If the function returns a value, that value is used;
* if it returns `undefined`, the default cloning method is used.
*
* @template T - The type of the object.
* @param {T} obj - The object to clone.
Expand Down Expand Up @@ -39,7 +44,7 @@ import { isTypedArray } from '../predicate/isTypedArray.ts';
*/
export function cloneDeepWith<T>(
obj: T,
cloneValue: (value: any, key: PropertyKey | undefined, object: T | undefined, stack: Map<any, any>) => any
cloneValue: (value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any
): T {
return cloneDeepWithImpl(obj, undefined, obj, new Map(), cloneValue);
}
Expand All @@ -49,9 +54,7 @@ export function cloneDeepWithImpl<T>(
keyToClone: PropertyKey | undefined,
objectToClone: T,
stack = new Map<any, any>(),
cloneValue:
| ((value: any, key: PropertyKey | undefined, object: T | undefined, stack: Map<any, any>) => any)
| undefined = undefined
cloneValue: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any) | undefined = undefined
): T {
const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);

Expand Down Expand Up @@ -212,9 +215,7 @@ export function copyProperties<T>(
source: any,
objectToClone: T = target,
stack?: Map<any, any> | undefined,
cloneValue?:
| ((value: any, key: PropertyKey | undefined, object: T | undefined, stack: Map<any, any>) => any)
| undefined
cloneValue?: ((value: any, key: PropertyKey | undefined, obj: T, stack: Map<any, any>) => any) | undefined
): void {
const keys = [...Object.keys(source), ...getSymbols(source)];

Expand Down

0 comments on commit 3393707

Please sign in to comment.