Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions docs/ja/reference/object/omitDeep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# omitDeep

指定されたネストされたパスを除外した新しいオブジェクトを返します。

```typescript
const result = omitDeep(object, paths);
```

## 使用法

### `omitDeep(object, paths)`

オブジェクトから特定のネストされたプロパティを除外したい時に`omitDeep`を使用してください。ドット(`.`)で区切られたパスに対応するプロパティを削除した新しいオブジェクトを返します。ネストされたオブジェクトと配列内のオブジェクトも再帰的に処理されます。

```typescript
import { omitDeep } from 'es-toolkit/object';

// ネストされたプロパティを除外
const obj = { a: 1, b: { x: 2, y: 3 }, c: 4 };
const result = omitDeep(obj, ['b.x']);
// resultは{ a: 1, b: { y: 3 }, c: 4 }になります

// 深くネストされたプロパティを除外
const nested = {
user: {
id: 1,
profile: {
name: 'John',
email: 'john@example.com',
},
},
};
const nestedResult = omitDeep(nested, ['user.profile.email']);
// nestedResultは{
// user: {
// id: 1,
// profile: {
// name: 'John',
// },
// },
// }になります

// 配列内のすべてのオブジェクトからプロパティを除外
const users = {
users: [
{ id: 1, secret: 'abc' },
{ id: 2, secret: 'def' },
],
};
const withoutSecrets = omitDeep(users, ['users.secret']);
// withoutSecretsは{
// users: [
// { id: 1 },
// { id: 2 },
// ],
// }になります

// ネストされたオブジェクトや配列全体を除外
const data = {
user: { id: 1, profile: { name: 'John' } },
items: [1, 2, 3],
};
const trimmed = omitDeep(data, ['user.profile', 'items']);
// trimmedは{ user: { id: 1 } }になります
```

#### パラメータ

- `object` (`T`): パスを除外するオブジェクトです。
- `paths` (`readonly string[]`): オブジェクトから除外するドット区切りのパスの配列です。

#### 戻り値

(`OmitDeep<T, P>`): 指定されたパスが除外された新しいオブジェクトを返します。
74 changes: 74 additions & 0 deletions docs/ko/reference/object/omitDeep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# omitDeep

지정된 중첩 경로들을 제외한 새로운 객체를 반환해요.

```typescript
const result = omitDeep(object, paths);
```

## 사용법

### `omitDeep(object, paths)`

객체에서 특정 중첩 속성들을 제외하고 싶을 때 `omitDeep`을 사용하세요. 점(`.`)으로 구분된 경로에 해당하는 속성들을 제거한 새로운 객체를 반환해요. 중첩된 객체와 배열 내의 객체들도 재귀적으로 처리돼요.

```typescript
import { omitDeep } from 'es-toolkit/object';

// 중첩된 속성을 제외해요
const obj = { a: 1, b: { x: 2, y: 3 }, c: 4 };
const result = omitDeep(obj, ['b.x']);
// result는 { a: 1, b: { y: 3 }, c: 4 }가 돼요

// 깊게 중첩된 속성을 제외해요
const nested = {
user: {
id: 1,
profile: {
name: 'John',
email: 'john@example.com',
},
},
};
const nestedResult = omitDeep(nested, ['user.profile.email']);
// nestedResult는 {
// user: {
// id: 1,
// profile: {
// name: 'John',
// },
// },
// }가 돼요

// 배열 내 모든 객체에서 특정 속성을 제외해요
const users = {
users: [
{ id: 1, secret: 'abc' },
{ id: 2, secret: 'def' },
],
};
const withoutSecrets = omitDeep(users, ['users.secret']);
// withoutSecrets는 {
// users: [
// { id: 1 },
// { id: 2 },
// ],
// }가 돼요

// 중첩된 객체나 배열 전체를 제외해요
const data = {
user: { id: 1, profile: { name: 'John' } },
items: [1, 2, 3],
};
const trimmed = omitDeep(data, ['user.profile', 'items']);
// trimmed는 { user: { id: 1 } }가 돼요
```

#### 파라미터

- `object` (`T`): 경로를 제외할 객체예요.
- `paths` (`readonly string[]`): 객체에서 제외할 점으로 구분된 경로들의 배열이에요.

#### 반환 값

(`OmitDeep<T, P>`): 지정된 경로들이 제외된 새로운 객체를 반환해요.
74 changes: 74 additions & 0 deletions docs/reference/object/omitDeep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# omitDeep

Returns a new object excluding the specified nested paths.

```typescript
const result = omitDeep(object, paths);
```

## Usage

### `omitDeep(object, paths)`

Use `omitDeep` when you want to exclude specific nested properties from an object. It returns a new object with the properties corresponding to the specified dot-separated paths removed. Nested objects and objects within arrays are processed recursively.

```typescript
import { omitDeep } from 'es-toolkit/object';

// Omit a nested property
const obj = { a: 1, b: { x: 2, y: 3 }, c: 4 };
const result = omitDeep(obj, ['b.x']);
// result is { a: 1, b: { y: 3 }, c: 4 }

// Omit deeply nested properties
const nested = {
user: {
id: 1,
profile: {
name: 'John',
email: 'john@example.com',
},
},
};
const nestedResult = omitDeep(nested, ['user.profile.email']);
// nestedResult is {
// user: {
// id: 1,
// profile: {
// name: 'John',
// },
// },
// }

// Omit a property from every object in an array
const users = {
users: [
{ id: 1, secret: 'abc' },
{ id: 2, secret: 'def' },
],
};
const withoutSecrets = omitDeep(users, ['users.secret']);
// withoutSecrets is {
// users: [
// { id: 1 },
// { id: 2 },
// ],
// }

// Omit an entire nested object or array
const data = {
user: { id: 1, profile: { name: 'John' } },
items: [1, 2, 3],
};
const trimmed = omitDeep(data, ['user.profile', 'items']);
// trimmed is { user: { id: 1 } }
```

#### Parameters

- `object` (`T`): The object to exclude paths from.
- `paths` (`readonly string[]`): An array of dot-separated paths to exclude from the object.

#### Returns

(`OmitDeep<T, P>`): A new object with the specified paths excluded.
74 changes: 74 additions & 0 deletions docs/zh_hans/reference/object/omitDeep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# omitDeep

返回一个排除指定嵌套路径的新对象。

```typescript
const result = omitDeep(object, paths);
```

## 用法

### `omitDeep(object, paths)`

当您想要从对象中排除特定的嵌套属性时,请使用 `omitDeep`。它返回一个新对象,其中删除了与指定点分隔路径对应的属性。嵌套对象和数组中的对象也会递归处理。

```typescript
import { omitDeep } from 'es-toolkit/object';

// 排除嵌套属性
const obj = { a: 1, b: { x: 2, y: 3 }, c: 4 };
const result = omitDeep(obj, ['b.x']);
// result 是 { a: 1, b: { y: 3 }, c: 4 }

// 排除深层嵌套属性
const nested = {
user: {
id: 1,
profile: {
name: 'John',
email: 'john@example.com',
},
},
};
const nestedResult = omitDeep(nested, ['user.profile.email']);
// nestedResult 是 {
// user: {
// id: 1,
// profile: {
// name: 'John',
// },
// },
// }

// 从数组中的每个对象排除属性
const users = {
users: [
{ id: 1, secret: 'abc' },
{ id: 2, secret: 'def' },
],
};
const withoutSecrets = omitDeep(users, ['users.secret']);
// withoutSecrets 是 {
// users: [
// { id: 1 },
// { id: 2 },
// ],
// }

// 排除整个嵌套对象或数组
const data = {
user: { id: 1, profile: { name: 'John' } },
items: [1, 2, 3],
};
const trimmed = omitDeep(data, ['user.profile', 'items']);
// trimmed 是 { user: { id: 1 } }
```

#### 参数

- `object` (`T`):要排除路径的对象。
- `paths` (`readonly string[]`):要从对象中排除的点分隔路径的数组。

#### 返回值

(`OmitDeep<T, P>`):排除了指定路径的新对象。
1 change: 1 addition & 0 deletions src/object/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export { merge } from './merge.ts';
export { mergeWith } from './mergeWith.ts';
export { omit } from './omit.ts';
export { omitBy } from './omitBy.ts';
export { omitDeep, type OmitDeep } from './omitDeep.ts';
export { pick } from './pick.ts';
export { pickBy } from './pickBy.ts';
export { sortKeys } from './sortKeys.ts';
Expand Down
Loading