Skip to content

Commit

Permalink
chore(release): 3.0.0-beta.7 [skip ci]
Browse files Browse the repository at this point in the history
# [3.0.0-beta.7](v3.0.0-beta.6...v3.0.0-beta.7) (2022-02-18)

### Features

* lone values will now be passed to mergeOthers rather than just returned ([#57](#57)) ([14a09ca](14a09ca))
  • Loading branch information
semantic-release-bot committed Feb 18, 2022
1 parent 14a09ca commit a3accd5
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 48 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
# Changelog
All notable changes to this project will be documented in this file. Dates are displayed in UTC.

# [3.0.0-beta.7](https://github.com/RebeccaStevens/deepmerge-ts/compare/v3.0.0-beta.6...v3.0.0-beta.7) (2022-02-18)


### Features

* lone values will now be passed to mergeOthers rather than just returned ([#57](https://github.com/RebeccaStevens/deepmerge-ts/issues/57)) ([14a09ca](https://github.com/RebeccaStevens/deepmerge-ts/commit/14a09ca2d67ffbb5341719c633873e91a5565d89))

# [3.0.0-beta.6](https://github.com/RebeccaStevens/deepmerge-ts/compare/v3.0.0-beta.5...v3.0.0-beta.6) (2022-02-17)


Expand Down
28 changes: 15 additions & 13 deletions dist/deno/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,22 +93,24 @@ console.log(merged);

// Prettierfied output:
//
// {
// record: {
// prop1: "changed",
// prop2: "value2",
// prop3: "value3"
// }
// array: (6) [1, 2, 3, 2, 3, 4]
// set: Set(4) {1, 2, 3, 4}
// map: Map(3) {
// "key1" => "value1",
// "key2" => "changed",
// "key3" => "value3"
// }
// Object {
// "record": Object {
// "prop1": "changed",
// "prop2": "value2",
// "prop3": "value3",
// },
// "array": Array [1, 2, 3, 2, 3, 4],
// "set": Set { 1, 2, 3, 4 },
// "map": Map {
// "key1" => "value1",
// "key2" => "changed",
// "key3" => "value3",
// },
// }
```

You can try out this example at [codesandbox.io](https://codesandbox.io/s/deepmerge-ts-example-iltxby?file=/src/example.ts).

### Using customized config

[See deepmerge custom docs](./docs/deepmergeCustom.md).
Expand Down
31 changes: 16 additions & 15 deletions dist/deno/deepmerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,6 @@ export function deepmergeCustom<
* The customized deepmerge function.
*/
function customizedDeepmerge(...objects: ReadonlyArray<unknown>) {
if (objects.length === 0) {
return undefined;
}
if (objects.length === 1) {
return objects[0];
}

return mergeUnknowns<
ReadonlyArray<unknown>,
typeof utils,
Expand Down Expand Up @@ -186,6 +179,17 @@ function mergeUnknowns<
M,
MM extends Readonly<Record<PropertyKey, unknown>>
>(values: Ts, utils: U, meta: M | undefined): DeepMergeHKT<Ts, MF, M> {
if (values.length === 0) {
return undefined as DeepMergeHKT<Ts, MF, M>;
}
if (values.length === 1) {
return utils.mergeFunctions.mergeOthers(
values,
utils,
meta
) as DeepMergeHKT<Ts, MF, M>;
}

const type = getObjectType(values[0]);

// eslint-disable-next-line functional/no-conditional-statement -- add an early escape for better performance.
Expand Down Expand Up @@ -274,14 +278,11 @@ function mergeRecords<
parents: values,
} as unknown as MM);

result[key] =
propValues.length === 1
? propValues[0]
: mergeUnknowns<ReadonlyArray<unknown>, U, MF, M, MM>(
propValues,
utils,
updatedMeta
);
result[key] = mergeUnknowns<ReadonlyArray<unknown>, U, MF, M, MM>(
propValues,
utils,
updatedMeta
);
}

/* eslint-enable functional/no-loop-statement, functional/no-conditional-statement */
Expand Down
17 changes: 7 additions & 10 deletions dist/node/index.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,6 @@ function deepmergeCustom(options, rootMetaData) {
* The customized deepmerge function.
*/
function customizedDeepmerge(...objects) {
if (objects.length === 0) {
return undefined;
}
if (objects.length === 1) {
return objects[0];
}
return mergeUnknowns(objects, utils, rootMetaData);
}
return customizedDeepmerge;
Expand Down Expand Up @@ -140,6 +134,12 @@ function getUtils(options, customizedDeepmerge) {
* @param values - The values.
*/
function mergeUnknowns(values, utils, meta) {
if (values.length === 0) {
return undefined;
}
if (values.length === 1) {
return utils.mergeFunctions.mergeOthers(values, utils, meta);
}
const type = getObjectType(values[0]);
// eslint-disable-next-line functional/no-conditional-statement -- add an early escape for better performance.
if (type !== 0 /* NOT */ && type !== 5 /* OTHER */) {
Expand Down Expand Up @@ -184,10 +184,7 @@ function mergeRecords(values, utils, meta) {
key,
parents: values,
});
result[key] =
propValues.length === 1
? propValues[0]
: mergeUnknowns(propValues, utils, updatedMeta);
result[key] = mergeUnknowns(propValues, utils, updatedMeta);
}
/* eslint-enable functional/no-loop-statement, functional/no-conditional-statement */
return result;
Expand Down
17 changes: 7 additions & 10 deletions dist/node/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,6 @@ function deepmergeCustom(options, rootMetaData) {
* The customized deepmerge function.
*/
function customizedDeepmerge(...objects) {
if (objects.length === 0) {
return undefined;
}
if (objects.length === 1) {
return objects[0];
}
return mergeUnknowns(objects, utils, rootMetaData);
}
return customizedDeepmerge;
Expand Down Expand Up @@ -136,6 +130,12 @@ function getUtils(options, customizedDeepmerge) {
* @param values - The values.
*/
function mergeUnknowns(values, utils, meta) {
if (values.length === 0) {
return undefined;
}
if (values.length === 1) {
return utils.mergeFunctions.mergeOthers(values, utils, meta);
}
const type = getObjectType(values[0]);
// eslint-disable-next-line functional/no-conditional-statement -- add an early escape for better performance.
if (type !== 0 /* NOT */ && type !== 5 /* OTHER */) {
Expand Down Expand Up @@ -180,10 +180,7 @@ function mergeRecords(values, utils, meta) {
key,
parents: values,
});
result[key] =
propValues.length === 1
? propValues[0]
: mergeUnknowns(propValues, utils, updatedMeta);
result[key] = mergeUnknowns(propValues, utils, updatedMeta);
}
/* eslint-enable functional/no-loop-statement, functional/no-conditional-statement */
return result;
Expand Down

0 comments on commit a3accd5

Please sign in to comment.