Gathering detailed insights and metrics for deepmerge-ts
Gathering detailed insights and metrics for deepmerge-ts
Gathering detailed insights and metrics for deepmerge-ts
Gathering detailed insights and metrics for deepmerge-ts
Deeply merge 2 or more objects respecting type information.
npm install deepmerge-ts
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
242 Stars
770 Commits
10 Forks
2 Watching
1 Branches
6 Contributors
Updated on 27 Nov 2024
Minified
Minified + Gzipped
TypeScript (100%)
Cumulative downloads
Total Downloads
Last day
6.7%
222,030
Compared to previous day
Last week
6.2%
1,167,693
Compared to previous week
Last month
9.7%
4,745,569
Compared to previous month
Last year
100.1%
41,649,135
Compared to previous year
64
Any donations would be much appreciated. 😄
deepmerge-ts
is available as part of the Tidelift Subscription.
Tidelift is working with the maintainers of deepmerge-ts
and a growing network of open source maintainers to ensure
your open source software supply chain meets enterprise standards now and into the future.
Learn more.
1# Install with npm 2npm install deepmerge-ts 3 4# Install with pnpm 5pnpm add deepmerge-ts 6 7# Install with yarn 8yarn add deepmerge-ts 9 10# Install with bun 11bun add deepmerge-ts
1# Install in a node project 2npx jsr add @rebeccastevens/deepmerge 3 4# Install in a deno project 5deno add jsr:@rebeccastevens/deepmerge 6 7# Install in a bun project 8bunx jsr add @rebeccastevens/deepmerge
1import { deepmerge } from "deepmerge-ts"; 2 3const x = { 4 record: { 5 prop1: "value1", 6 prop2: "value2", 7 }, 8 array: [1, 2, 3], 9 set: new Set([1, 2, 3]), 10 map: new Map([ 11 ["key1", "value1"], 12 ["key2", "value2"], 13 ]), 14}; 15 16const y = { 17 record: { 18 prop1: "changed", 19 prop3: "value3", 20 }, 21 array: [2, 3, 4], 22 set: new Set([2, 3, 4]), 23 map: new Map([ 24 ["key2", "changed"], 25 ["key3", "value3"], 26 ]), 27}; 28 29const z = { 30 record: { 31 prop1: undefined, 32 prop3: undefined, 33 prop2: undefined, 34 prop4: undefined, 35 }, 36 array: undefined, 37 set: undefined, 38 map: undefined, 39}; 40 41const merged = deepmerge(x, y, z); 42 43console.log(merged); 44 45// Prettierfied output: 46// 47// Object { 48// "record": Object { 49// "prop1": "changed", 50// "prop2": "value2", 51// "prop3": "value3", 52// "prop4": undefined, 53// }, 54// "array": Array [1, 2, 3, 2, 3, 4], 55// "set": Set { 1, 2, 3, 4 }, 56// "map": Map { 57// "key1" => "value1", 58// "key2" => "changed", 59// "key3" => "value3", 60// }, 61// }
You can try out this example at codesandbox.io.
You can use deepmergeInto
if you want to update a target object with the merge result instead of creating a new
object.
This function is best used with objects that are all of the same type.
Note: If the target object's type differs from the input objects, we'll assert that the target's type has changed
(this is not done automatically with deepmergeIntoCustom
).
We provide a customizer function for each of our main deepmerge functions: deepmergeCustom
and deepmergeIntoCustom
.
You can use these to customize the details of how values should be merged together.
See deepmerge custom docs for more details.
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.
With classic merging, each input is merged with the next input until all inputs are merged.
This strategy has large performance issues when lots of items need to be merged.
With our smart merging, we look ahead to see what can be merged and only merge those things.
In addition to performance improvements, this strategy merges multiple inputs at once; allowing for benefits such as taking averages of the inputs.
See API docs.
The latest stable version of the package.
Stable Version
1
8.1/10
Summary
Prototype Pollution in deepmerge-ts
Affected Versions
< 4.0.2
Patched Versions
4.0.2
Reason
no binaries found in the repo
Reason
25 commit(s) and 4 issue activity found in the last 90 days -- score normalized to 10
Reason
security policy file detected
Details
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
6 existing vulnerabilities detected
Details
Reason
Found 0/29 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-25
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Moredeepmerge
A library for deep (recursive) merging of Javascript objects
@fastify/deepmerge
Merges the enumerable properties of two or more objects deeply.
ts-deepmerge
A TypeScript deep merge function.
@corex/deepmerge
A zero dependency object merger with typescript support and built in common merge utilities.