es-toolkit 1.52.0-dev.2133 → 1.52.0-dev.2134
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/types/DistributiveOmit.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Removes the given keys from each union member while preserving its remaining properties.
|
|
4
|
+
* Unlike the built-in `Omit`, preserves properties specific to each member.
|
|
5
|
+
* Ignores missing keys and preserves readonly and optional modifiers.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type to remove properties from.
|
|
8
|
+
* @template K - The keys to remove. Must extend PropertyKey (string, number, or symbol).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* type Card = { kind: 'card'; cardNo: string; note: string };
|
|
12
|
+
* type Bank = { kind: 'bank'; accountNo: string; note: string };
|
|
13
|
+
* type Payment = DistributiveOmit<Card | Bank, 'note'>;
|
|
14
|
+
* // => { kind: 'card'; cardNo: string } | { kind: 'bank'; accountNo: string }
|
|
15
|
+
*/
|
|
16
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DistributiveOmit };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/types/DistributiveOmit.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Removes the given keys from each union member while preserving its remaining properties.
|
|
4
|
+
* Unlike the built-in `Omit`, preserves properties specific to each member.
|
|
5
|
+
* Ignores missing keys and preserves readonly and optional modifiers.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type to remove properties from.
|
|
8
|
+
* @template K - The keys to remove. Must extend PropertyKey (string, number, or symbol).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* type Card = { kind: 'card'; cardNo: string; note: string };
|
|
12
|
+
* type Bank = { kind: 'bank'; accountNo: string; note: string };
|
|
13
|
+
* type Payment = DistributiveOmit<Card | Bank, 'note'>;
|
|
14
|
+
* // => { kind: 'card'; cardNo: string } | { kind: 'bank'; accountNo: string }
|
|
15
|
+
*/
|
|
16
|
+
type DistributiveOmit<T, K extends PropertyKey> = T extends unknown ? Omit<T, K> : never;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { DistributiveOmit };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -9,6 +9,7 @@ import { ToSnakeCaseKeys } from "./ToSnakeCaseKeys.mjs";
|
|
|
9
9
|
import { Primitive } from "./Primitive.mjs";
|
|
10
10
|
import { DeepPartial } from "./DeepPartial.mjs";
|
|
11
11
|
import { DeepReadonly } from "./DeepReadonly.mjs";
|
|
12
|
+
import { DistributiveOmit } from "./DistributiveOmit.mjs";
|
|
12
13
|
import { EmptyObject } from "./EmptyObject.mjs";
|
|
13
14
|
import { IsEqual } from "./IsEqual.mjs";
|
|
14
15
|
import { JSONValue } from "./JSONValue.mjs";
|
|
@@ -18,4 +19,4 @@ import { SetRequired } from "./SetRequired.mjs";
|
|
|
18
19
|
import { UnknownRecord } from "./UnknownRecord.mjs";
|
|
19
20
|
import { ValueOf } from "./ValueOf.mjs";
|
|
20
21
|
import { Writable } from "./Writable.mjs";
|
|
21
|
-
export { type DeepPartial, type DeepReadonly, type EmptyObject, type IsEqual, type JSONValue, type Merge, type NonEmptyArray, type ObjectKeys, type Primitive, type SetOptional, type SetRequired, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type UnknownRecord, type ValueOf, type Writable };
|
|
22
|
+
export { type DeepPartial, type DeepReadonly, type DistributiveOmit, type EmptyObject, type IsEqual, type JSONValue, type Merge, type NonEmptyArray, type ObjectKeys, type Primitive, type SetOptional, type SetRequired, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type UnknownRecord, type ValueOf, type Writable };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import { ToSnakeCaseKeys } from "./ToSnakeCaseKeys.js";
|
|
|
9
9
|
import { Primitive } from "./Primitive.js";
|
|
10
10
|
import { DeepPartial } from "./DeepPartial.js";
|
|
11
11
|
import { DeepReadonly } from "./DeepReadonly.js";
|
|
12
|
+
import { DistributiveOmit } from "./DistributiveOmit.js";
|
|
12
13
|
import { EmptyObject } from "./EmptyObject.js";
|
|
13
14
|
import { IsEqual } from "./IsEqual.js";
|
|
14
15
|
import { JSONValue } from "./JSONValue.js";
|
|
@@ -18,4 +19,4 @@ import { SetRequired } from "./SetRequired.js";
|
|
|
18
19
|
import { UnknownRecord } from "./UnknownRecord.js";
|
|
19
20
|
import { ValueOf } from "./ValueOf.js";
|
|
20
21
|
import { Writable } from "./Writable.js";
|
|
21
|
-
export { type DeepPartial, type DeepReadonly, type EmptyObject, type IsEqual, type JSONValue, type Merge, type NonEmptyArray, type ObjectKeys, type Primitive, type SetOptional, type SetRequired, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type UnknownRecord, type ValueOf, type Writable };
|
|
22
|
+
export { type DeepPartial, type DeepReadonly, type DistributiveOmit, type EmptyObject, type IsEqual, type JSONValue, type Merge, type NonEmptyArray, type ObjectKeys, type Primitive, type SetOptional, type SetRequired, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type UnknownRecord, type ValueOf, type Writable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.52.0-dev.
|
|
3
|
+
"version": "1.52.0-dev.2134+5fa53167",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|