deepmerge-ts
Advanced tools
Comparing version 1.1.0 to 1.1.1
# Changelog | ||
All notable changes to this project will be documented in this file. Dates are displayed in UTC. | ||
## [1.1.1](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.1.0...v1.1.1) (2021-09-16) | ||
### Bug Fixes | ||
* add legacy type information ([#6](https://github.com/RebeccaStevens/deepmerge-ts/issues/6)) ([c7e1019](https://github.com/RebeccaStevens/deepmerge-ts/commit/c7e1019f86818fe95b9f6291f2a09f077337a7f9)) | ||
* only use merge enumerable properties ([#8](https://github.com/RebeccaStevens/deepmerge-ts/issues/8)) ([0967070](https://github.com/RebeccaStevens/deepmerge-ts/commit/0967070d30427bb33f0c78793d61a9411dde3b49)) | ||
# [1.1.0](https://github.com/RebeccaStevens/deepmerge-ts/compare/v1.0.1...v1.1.0) (2021-09-13) | ||
@@ -25,3 +33,1 @@ | ||
* add basic functionality ([8e3ba66](https://github.com/RebeccaStevens/deepmerge-ts/commit/8e3ba66973d6e35cc421149a00a45b7c55c1de45)) | ||
# Changelog |
{ | ||
"name": "deepmerge-ts", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Deeply merge 2 or more objects respecting type information.", | ||
@@ -9,3 +9,13 @@ "keywords": [ | ||
"deep merge", | ||
"recursive merge" | ||
"deep-merge", | ||
"inferred types", | ||
"inferred-types", | ||
"recursive merge", | ||
"recursive-merge", | ||
"ts", | ||
"ts merge", | ||
"ts-merge", | ||
"typescript", | ||
"typescript merge", | ||
"typescript-merge" | ||
], | ||
@@ -32,3 +42,15 @@ "homepage": "https://github.com/RebeccaStevens/deepmerge-ts#readme", | ||
"module": "lib/index.mjs", | ||
"types": "types/current/index.d.ts", | ||
"types": "types/legacy/v4_0.d.ts", | ||
"typesVersions": { | ||
"<4.1": { | ||
"*": [ | ||
"types/legacy/v4_0.d.ts" | ||
] | ||
}, | ||
">=4.1": { | ||
"*": [ | ||
"types/current/index.d.ts" | ||
] | ||
} | ||
}, | ||
"files": [ | ||
@@ -44,2 +66,4 @@ "lib/", | ||
"prebuild": "rimraf lib types/current", | ||
"prebenchmark": "yarn build && yarn link", | ||
"benchmark": "cd benchmark && yarn benchmark; cd ..", | ||
"build": "rollup -c", | ||
@@ -116,10 +140,2 @@ "check-format": "prettier --list-different \"./**/*.{md,ts,yml}\"", | ||
}, | ||
"peerDependencies": { | ||
"typescript": ">=4.1.0" | ||
}, | ||
"peerDependenciesMeta": { | ||
"typescript": { | ||
"optional": true | ||
} | ||
}, | ||
"engines": { | ||
@@ -126,0 +142,0 @@ "node": ">=12.4.0" |
@@ -16,2 +16,4 @@ <div align="center"> | ||
![classic merge animation](./assets/header.png) | ||
</div> | ||
@@ -33,2 +35,3 @@ | ||
- Smart merging - High performance. | ||
- Merged output has correct typing. | ||
@@ -99,74 +102,24 @@ - Record merging support. | ||
## API | ||
## Performance | ||
### deepmerge(x, y, ...) | ||
We use smart merging instead of the classic merging strategy which some alternative libraries use. This vastly improves performance, both in execution time and memory usage. | ||
Merges the given inputs together using the default configuration. | ||
### Classic Merge (not what we do) | ||
#### deepmerge(...inputs) | ||
With classic merging, each input is merged with the next input until all inputs are merged. | ||
Merges the array of inputs together using the default configuration. | ||
This strategy has large performance issues when lots of items need to be merged. | ||
Note: If `inputs` isn't typed as a tuple then we cannot determine the output type. The output type will simply be `unknown`. | ||
![classic merge animation](./assets/classic-merge.gif) | ||
### deepmergeCustom(options) | ||
### Smart Merge (what we do) | ||
Generate a customized deepmerge function using the given options. The returned function works just like `deepmerge` except it uses the customized configuration. | ||
With our smart merging, we look ahead to see what can be merged and only merge those things. | ||
#### options | ||
In addition to performance improvements, this strategy merges multiple inputs at once; allowing for benefits such as taking averages of the inputs. | ||
The following options can be used to customize the deepmerge function.\ | ||
All these options are optional. | ||
![smart merge animation](./assets/smart-merge.gif) | ||
##### `mergeRecords` | ||
## API | ||
Type: `false | (values: Record<any, unknown>[], utils: DeepMergeMergeFunctionUtils) => unknown` | ||
If false, records won't be merged. If set to a function, that function will be used to merge records. | ||
Note: Records are "vanilla" objects (e.g. `{ foo: "hello", bar: "world" }`). | ||
##### `mergeArrays` | ||
Type: `false | (values: unknown[][], utils: DeepMergeMergeFunctionUtils) => unknown` | ||
If false, arrays won't be merged. If set to a function, that function will be used to merge arrays. | ||
##### `mergeMaps` | ||
Type: `false | (values: Map<unknown, unknown>[], utils: DeepMergeMergeFunctionUtils) => unknown` | ||
If false, maps won't be merged. If set to a function, that function will be used to merge maps. | ||
##### `mergeSets` | ||
Type: `false | (values: Set<unknown>[], utils: DeepMergeMergeFunctionUtils) => unknown` | ||
If false, sets won't be merged. If set to a function, that function will be used to merge sets. | ||
##### `mergeOthers` | ||
Type: `(values: Set<unknown>[], utils: DeepMergeMergeFunctionUtils) => unknown` | ||
If set to a function, that function will be used to merge everything else. | ||
Note: This includes merging mixed types, such as merging a map with an array. | ||
#### DeepMergeMergeFunctionUtils | ||
This is a set of utility functions that are made available to your custom merge functions. | ||
##### `mergeFunctions` | ||
These are all the merge function being used to perform the deepmerge.\ | ||
These will be the custom merge functions you gave, or the default merge functions for options you didn't customize. | ||
##### `defaultMergeFunctions` | ||
These are all the merge functions that the default, non-customize deepmerge function uses. | ||
##### `deepmerge` | ||
This is your top level customized deepmerge function. | ||
Note: Be careful when calling this as it is really easy to end up in an infinite loop. | ||
[See API docs](./docs/API.md). |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1
770
40129
1
123
1