Skip to content

Commit fd4d2d4

Browse files
refactor!: rename DeepMergeMerge* to DeepMerge*
1 parent 0784f63 commit fd4d2d4

File tree

11 files changed

+187
-198
lines changed

11 files changed

+187
-198
lines changed

docs/API.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,33 +27,33 @@ All these options are optional.
2727

2828
#### `mergeRecords`
2929

30-
Type: `false | (values: Record<any, unknown>[], utils: DeepMergeMergeFunctionUtils, meta: MetaData) => unknown`
30+
Type: `false | (values: Record<any, unknown>[], utils: DeepMergeFunctionUtils, meta: MetaData) => unknown`
3131

3232
If `false`, records won't be merged. If set to a function, that function will be used to merge records.
3333

3434
Note: Records are "vanilla" objects (e.g. `{ foo: "hello", bar: "world" }`).
3535

3636
#### `mergeArrays`
3737

38-
Type: `false | (values: unknown[][], utils: DeepMergeMergeFunctionUtils, meta: MetaData) => unknown`
38+
Type: `false | (values: unknown[][], utils: DeepMergeFunctionUtils, meta: MetaData) => unknown`
3939

4040
If `false`, arrays won't be merged. If set to a function, that function will be used to merge arrays.
4141

4242
#### `mergeMaps`
4343

44-
Type: `false | (values: Map<unknown, unknown>[], utils: DeepMergeMergeFunctionUtils, meta: MetaData) => unknown`
44+
Type: `false | (values: Map<unknown, unknown>[], utils: DeepMergeFunctionUtils, meta: MetaData) => unknown`
4545

4646
If `false`, maps won't be merged. If set to a function, that function will be used to merge maps.
4747

4848
#### `mergeSets`
4949

50-
Type: `false | (values: Set<unknown>[], utils: DeepMergeMergeFunctionUtils, meta: MetaData) => unknown`
50+
Type: `false | (values: Set<unknown>[], utils: DeepMergeFunctionUtils, meta: MetaData) => unknown`
5151

5252
If `false`, sets won't be merged. If set to a function, that function will be used to merge sets.
5353

5454
#### `mergeOthers`
5555

56-
Type: `(values: unknown[], utils: DeepMergeMergeFunctionUtils, meta: MetaData) => unknown`
56+
Type: `(values: unknown[], utils: DeepMergeFunctionUtils, meta: MetaData) => unknown`
5757

5858
If set to a function, that function will be used to merge everything else.
5959

@@ -72,7 +72,7 @@ Type: `MetaData`
7272

7373
The given meta data value will be passed to root level merges.
7474

75-
### DeepMergeMergeFunctionUtils
75+
### DeepMergeFunctionUtils
7676

7777
This is a set of utility functions that are made available to your custom merge functions.
7878

@@ -115,7 +115,7 @@ All these options are optional.
115115

116116
#### `mergeRecords`
117117

118-
Type: `false | (target: DeepMergeValueReference<Record<PropertyKey, unknown>>, values: Record<any, unknown>[], utils: DeepMergeMergeFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
118+
Type: `false | (target: DeepMergeValueReference<Record<PropertyKey, unknown>>, values: Record<any, unknown>[], utils: DeepMergeFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
119119

120120
If `false`, records won't be merged. If set to a function, that function will be used to merge records by mutating
121121
`target.value`.
@@ -124,28 +124,28 @@ Note: Records are "vanilla" objects (e.g. `{ foo: "hello", bar: "world" }`).
124124

125125
#### `mergeArrays`
126126

127-
Type: `false | (target: DeepMergeValueReference<unknown[]>, values: unknown[][], utils: DeepMergeMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
127+
Type: `false | (target: DeepMergeValueReference<unknown[]>, values: unknown[][], utils: DeepMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
128128

129129
If `false`, arrays won't be merged. If set to a function, that function will be used to merge arrays by mutating
130130
`target.value`.
131131

132132
#### `mergeMaps`
133133

134-
Type: `false | (target: DeepMergeValueReference<Map<unknown, unknown>>, values: Map<unknown, unknown>[], utils: DeepMergeMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
134+
Type: `false | (target: DeepMergeValueReference<Map<unknown, unknown>>, values: Map<unknown, unknown>[], utils: DeepMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
135135

136136
If `false`, maps won't be merged. If set to a function, that function will be used to merge maps by mutating
137137
`target.value`.
138138

139139
#### `mergeSets`
140140

141-
Type: `false | (target: DeepMergeValueReference<Set<unknown>>, values: Set<unknown>[], utils: DeepMergeMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
141+
Type: `false | (target: DeepMergeValueReference<Set<unknown>>, values: Set<unknown>[], utils: DeepMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
142142

143143
If `false`, sets won't be merged. If set to a function, that function will be used to merge sets by mutating
144144
`target.value`.
145145

146146
#### `mergeOthers`
147147

148-
Type: `(target: DeepMergeValueReference<unknown>, values: unknown[], utils: DeepMergeMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
148+
Type: `(target: DeepMergeValueReference<unknown>, values: unknown[], utils: DeepMergeIntoFunctionUtils, meta: MetaData) => void | symbol` <!-- markdownlint-disable-line MD013 -->
149149

150150
If set to a function, that function will be used to merge everything else by mutating `target.value`.
151151

@@ -164,7 +164,7 @@ Type: `MetaData`
164164

165165
The given meta data value will be passed to root level merges.
166166

167-
### DeepMergeMergeIntoFunctionUtils
167+
### DeepMergeIntoFunctionUtils
168168

169169
This is a set of utility functions that are made available to your custom merge functions.
170170

docs/deepmergeCustom.md

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ const y = { foo: [5, 6] };
159159
customDeepmerge(x, y); // => { foo: [5, 6], bar: [3, 4] }
160160
```
161161

162-
When resolving a HKT, we use a lookup inside an interface called `DeepMergeMergeFunctionURItoKind`.
162+
When resolving a HKT, we use a lookup inside an interface called `DeepMergeFunctionURItoKind`.
163163
This interface needs to contain all the mappings of the URIs to their actual type.
164164

165165
When defining your own HKT for use with deepmerge, you need to extend this interface with your mapping.
@@ -168,9 +168,9 @@ declaring a module block for this library and defining the same interface.
168168

169169
```ts
170170
declare module "deepmerge-ts" {
171-
interface DeepMergeMergeFunctionURItoKind<
171+
interface DeepMergeFunctionURItoKind<
172172
Ts extends ReadonlyArray<unknown>,
173-
MF extends DeepMergeMergeFunctionsURIs,
173+
MF extends DeepMergeFunctionsURIs,
174174
M,
175175
> {
176176
readonly MyCustomMergeURI: MyValue;
@@ -184,9 +184,9 @@ Here's an example of creating a custom deepmerge function that amalgamates dates
184184

185185
```ts
186186
import {
187+
type DeepMergeFunctionURItoKind,
188+
type DeepMergeFunctionsURIs,
187189
type DeepMergeLeaf,
188-
type DeepMergeMergeFunctionURItoKind,
189-
type DeepMergeMergeFunctionsURIs,
190190
deepmergeCustom,
191191
} from "deepmerge-ts";
192192

@@ -213,9 +213,9 @@ const z = { foo: new Date("2022-03-03") };
213213
customDeepmerge(x, y, z); // => { foo: [Date, Date, Date] }
214214

215215
declare module "deepmerge-ts" {
216-
interface DeepMergeMergeFunctionURItoKind<
216+
interface DeepMergeFunctionURItoKind<
217217
Ts extends ReadonlyArray<unknown>,
218-
MF extends DeepMergeMergeFunctionsURIs,
218+
MF extends DeepMergeFunctionsURIs,
219219
M,
220220
> {
221221
readonly MyDeepMergeDatesURI: EveryIsDate<Ts> extends true
@@ -247,8 +247,8 @@ Be sure to also set the `DeepMergeFilterValuesURI` to `DeepMergeNoFilteringURI`
247247

248248
```ts
249249
import {
250-
type DeepMergeMergeFunctionURItoKind,
251-
type DeepMergeMergeFunctionsURIs,
250+
type DeepMergeFunctionURItoKind,
251+
type DeepMergeFunctionsURIs,
252252
type DeepMergeNoFilteringURI,
253253
deepmergeCustom,
254254
} from "deepmerge-ts";
@@ -275,8 +275,8 @@ Here's an example that creates a custom deepmerge function that filters out all
275275

276276
```ts
277277
import {
278-
type DeepMergeMergeFunctionURItoKind,
279-
type DeepMergeMergeFunctionsURIs,
278+
type DeepMergeFunctionURItoKind,
279+
type DeepMergeFunctionsURIs,
280280
type FilterOut,
281281
deepmergeCustom,
282282
} from "deepmerge-ts";
@@ -299,9 +299,9 @@ const z = { key1: { subkey2: `two` } };
299299
customizedDeepmerge(x, y, z); // => { key1: { subkey1: `one`, subkey2: `two` } }
300300

301301
declare module "deepmerge-ts" {
302-
interface DeepMergeMergeFunctionURItoKind<
302+
interface DeepMergeFunctionURItoKind<
303303
Ts extends Readonly<ReadonlyArray<unknown>>,
304-
MF extends DeepMergeMergeFunctionsURIs,
304+
MF extends DeepMergeFunctionsURIs,
305305
M,
306306
> {
307307
readonly FilterNullValues: FilterOut<Ts, null>;
@@ -318,9 +318,9 @@ under.
318318

319319
```ts
320320
import {
321+
type DeepMergeFunctionURItoKind,
322+
type DeepMergeFunctionsURIs,
321323
type DeepMergeLeaf,
322-
type DeepMergeMergeFunctionURItoKind,
323-
type DeepMergeMergeFunctionsURIs,
324324
deepmergeCustom,
325325
} from "deepmerge-ts";
326326

@@ -370,9 +370,9 @@ Here's an example that uses custom metadata that accumulates the full key path.
370370

371371
```ts
372372
import {
373+
type DeepMergeFunctionURItoKind,
374+
type DeepMergeFunctionsURIs,
373375
type DeepMergeLeaf,
374-
type DeepMergeMergeFunctionURItoKind,
375-
type DeepMergeMergeFunctionsURIs,
376376
deepmergeCustom,
377377
} from "deepmerge-ts";
378378

@@ -431,9 +431,9 @@ const y = {
431431
customizedDeepmerge(x, y); // => { foo: { bar: { baz: "special merge", bar: { baz: 6, qux: 7 }, qux: 2 } }, bar: { baz: "special merge", qux: 9 }, }
432432

433433
declare module "deepmerge-ts" {
434-
interface DeepMergeMergeFunctionURItoKind<
434+
interface DeepMergeFunctionURItoKind<
435435
Ts extends Readonly<ReadonlyArray<unknown>>,
436-
MF extends DeepMergeMergeFunctionsURIs,
436+
MF extends DeepMergeFunctionsURIs,
437437
M, // This is the meta data type
438438
> {
439439
readonly KeyPathBasedMerge: Ts[number] extends number
@@ -507,10 +507,10 @@ type CustomizedDeepmergeInto = <
507507
DeepMergeHKT<
508508
[Target, ...Ts], // Don't forget to pass the `Target` type here too.
509509
{
510-
DeepMergeRecordsURI: DeepMergeMergeFunctionsDefaultURIs["DeepMergeRecordsURI"]; // Use default behavior.
511-
DeepMergeArraysURI: DeepMergeMergeFunctionsDefaultURIs["DeepMergeArraysURI"]; // Use default behavior.
512-
DeepMergeSetsURI: DeepMergeMergeFunctionsDefaultURIs["DeepMergeSetsURI"]; // Use default behavior.
513-
DeepMergeMapsURI: DeepMergeMergeFunctionsDefaultURIs["DeepMergeMapsURI"]; // Use default behavior.
510+
DeepMergeRecordsURI: DeepMergeFunctionsDefaultURIs["DeepMergeRecordsURI"]; // Use default behavior.
511+
DeepMergeArraysURI: DeepMergeFunctionsDefaultURIs["DeepMergeArraysURI"]; // Use default behavior.
512+
DeepMergeSetsURI: DeepMergeFunctionsDefaultURIs["DeepMergeSetsURI"]; // Use default behavior.
513+
DeepMergeMapsURI: DeepMergeFunctionsDefaultURIs["DeepMergeMapsURI"]; // Use default behavior.
514514
DeepMergeOthersURI: "CustomDeepMergeOthersURI"; // Use custom behavior (see deepmergeCustom's docs above for details).
515515
},
516516
DeepMergeBuiltInMetaData // Use default meta data.

src/deepmerge-into.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import {
66
import * as defaultMergeIntoFunctions from "./defaults/into";
77
import {
88
type DeepMergeBuiltInMetaData,
9+
type DeepMergeFunctionsDefaultURIs,
910
type DeepMergeHKT,
11+
type DeepMergeIntoFunctionUtils,
1012
type DeepMergeIntoOptions,
11-
type DeepMergeMergeFunctionsDefaultURIs,
12-
type DeepMergeMergeIntoFunctionUtils,
1313
type Reference,
1414
} from "./types";
1515
import { type SimplifyObject } from "./types/utils";
@@ -42,7 +42,7 @@ export function deepmergeInto<
4242
Target &
4343
DeepMergeHKT<
4444
[Target, ...Ts],
45-
DeepMergeMergeFunctionsDefaultURIs,
45+
DeepMergeFunctionsDefaultURIs,
4646
DeepMergeBuiltInMetaData
4747
>
4848
>;
@@ -57,7 +57,7 @@ export function deepmergeInto<
5757
Target &
5858
DeepMergeHKT<
5959
[Target, ...Ts],
60-
DeepMergeMergeFunctionsDefaultURIs,
60+
DeepMergeFunctionsDefaultURIs,
6161
DeepMergeBuiltInMetaData
6262
>
6363
> {
@@ -119,7 +119,7 @@ export function deepmergeIntoCustom<
119119
...objects: Ts
120120
) => void;
121121

122-
const utils: DeepMergeMergeIntoFunctionUtils<MetaData, MetaMetaData> =
122+
const utils: DeepMergeIntoFunctionUtils<MetaData, MetaMetaData> =
123123
getIntoUtils(options, customizedDeepmergeInto as CustomizedDeepmergeInto);
124124

125125
/**
@@ -150,11 +150,8 @@ function getIntoUtils<
150150
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
151151
>(
152152
options: DeepMergeIntoOptions<M, MM>,
153-
customizedDeepmergeInto: DeepMergeMergeIntoFunctionUtils<
154-
M,
155-
MM
156-
>["deepmergeInto"],
157-
): DeepMergeMergeIntoFunctionUtils<M, MM> {
153+
customizedDeepmergeInto: DeepMergeIntoFunctionUtils<M, MM>["deepmergeInto"],
154+
): DeepMergeIntoFunctionUtils<M, MM> {
158155
return {
159156
defaultMergeFunctions: defaultMergeIntoFunctions,
160157
mergeFunctions: {
@@ -170,9 +167,9 @@ function getIntoUtils<
170167
: [key, option],
171168
),
172169
),
173-
} as DeepMergeMergeIntoFunctionUtils<M, MM>["mergeFunctions"],
170+
} as DeepMergeIntoFunctionUtils<M, MM>["mergeFunctions"],
174171
metaDataUpdater: (options.metaDataUpdater ??
175-
defaultMetaDataUpdater) as unknown as DeepMergeMergeIntoFunctionUtils<
172+
defaultMetaDataUpdater) as unknown as DeepMergeIntoFunctionUtils<
176173
M,
177174
MM
178175
>["metaDataUpdater"],
@@ -193,7 +190,7 @@ function getIntoUtils<
193190
*/
194191
export function mergeUnknownsInto<
195192
Ts extends ReadonlyArray<unknown>,
196-
U extends DeepMergeMergeIntoFunctionUtils<M, MM>,
193+
U extends DeepMergeIntoFunctionUtils<M, MM>,
197194
M,
198195
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
199196
>(
@@ -291,7 +288,7 @@ export function mergeUnknownsInto<
291288
* @param values - The records.
292289
*/
293290
function mergeRecordsInto<
294-
U extends DeepMergeMergeIntoFunctionUtils<M, MM>,
291+
U extends DeepMergeIntoFunctionUtils<M, MM>,
295292
M,
296293
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
297294
>(
@@ -324,7 +321,7 @@ function mergeRecordsInto<
324321
* @param values - The arrays.
325322
*/
326323
function mergeArraysInto<
327-
U extends DeepMergeMergeIntoFunctionUtils<M, MM>,
324+
U extends DeepMergeIntoFunctionUtils<M, MM>,
328325
M,
329326
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
330327
>(
@@ -352,7 +349,7 @@ function mergeArraysInto<
352349
* @param values - The sets.
353350
*/
354351
function mergeSetsInto<
355-
U extends DeepMergeMergeIntoFunctionUtils<M, MM>,
352+
U extends DeepMergeIntoFunctionUtils<M, MM>,
356353
M,
357354
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
358355
>(
@@ -375,7 +372,7 @@ function mergeSetsInto<
375372
* @param values - The maps.
376373
*/
377374
function mergeMapsInto<
378-
U extends DeepMergeMergeIntoFunctionUtils<M, MM>,
375+
U extends DeepMergeIntoFunctionUtils<M, MM>,
379376
M,
380377
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
381378
>(
@@ -398,7 +395,7 @@ function mergeMapsInto<
398395
* @param values - The other things.
399396
*/
400397
function mergeOthersInto<
401-
U extends DeepMergeMergeIntoFunctionUtils<M, MM>,
398+
U extends DeepMergeIntoFunctionUtils<M, MM>,
402399
M,
403400
MM extends DeepMergeBuiltInMetaData = DeepMergeBuiltInMetaData,
404401
>(

0 commit comments

Comments
 (0)