Skip to content

Commit

Permalink
perf: remove BlacklistedRecordProps
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens committed May 14, 2024
1 parent 83d7620 commit 70d1c9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 20 deletions.
23 changes: 6 additions & 17 deletions src/types/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ export type DeepMergeMergeFunctionsDefaultURIs = Readonly<{
DeepMergeOthersURI: DeepMergeLeafURI;
}>;

/**
* A union of all the props that should not be included in type information for
* merged records.
*/
type BlacklistedRecordProps = "__proto__";

/**
* Deep merge records.
*/
Expand All @@ -61,12 +55,7 @@ export type DeepMergeRecordsDefaultHKT<
M,
> =
Ts extends Readonly<readonly [unknown, ...Readonly<ReadonlyArray<unknown>>]>
? FlatternAlias<
Omit<
DeepMergeRecordsDefaultHKTInternalProps<Ts, MF, M>,
BlacklistedRecordProps
>
>
? FlatternAlias<DeepMergeRecordsDefaultHKTInternalProps<Ts, MF, M>>
: {};

/**
Expand Down Expand Up @@ -175,35 +164,35 @@ export type GetDeepMergeMergeFunctionsURIs<
> = Readonly<{
// prettier-ignore
DeepMergeRecordsURI:

PMF["DeepMergeRecordsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any>
? PMF["DeepMergeRecordsURI"]
: DeepMergeRecordsDefaultURI;

// prettier-ignore
DeepMergeArraysURI:

PMF["DeepMergeArraysURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any>
? PMF["DeepMergeArraysURI"]
: DeepMergeArraysDefaultURI;

// prettier-ignore
DeepMergeSetsURI:

PMF["DeepMergeSetsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any>
? PMF["DeepMergeSetsURI"]
: DeepMergeSetsDefaultURI;

// prettier-ignore
DeepMergeMapsURI:

PMF["DeepMergeMapsURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any>
? PMF["DeepMergeMapsURI"]
: DeepMergeMapsDefaultURI;

// prettier-ignore
DeepMergeOthersURI:

PMF["DeepMergeOthersURI"] extends keyof DeepMergeMergeFunctionURItoKind<any, any, any>
? PMF["DeepMergeOthersURI"]
: DeepMergeLeafURI;
Expand Down
1 change: 0 additions & 1 deletion src/types/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,6 @@ export type DeepMergeMergeFunctionUtils<
/**
* The utils provided to the merge functions.
*/

export type DeepMergeMergeIntoFunctionUtils<
in out M,
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
Expand Down
7 changes: 5 additions & 2 deletions src/types/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@
* Flatten a complex type such as a union or intersection of objects into a
* single object.
*/
export type FlatternAlias<T> =
Is<T, unknown> extends true ? T : { [P in keyof T]: T[P] } & {};
export type FlatternAlias<T> = T extends {} ? FlatternRecord<T> : T;

type FlatternRecord<T extends {}> = {
[K in keyof T]: T[K];
} & {};

/**
* Get the value of the given key in the given object.
Expand Down

0 comments on commit 70d1c9b

Please sign in to comment.