{"_id":"@fastify/deepmerge","_rev":"3737080","name":"@fastify/deepmerge","description":"Merges the enumerable properties of two or more objects deeply.","dist-tags":{"latest":"2.0.2"},"maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"time":{"modified":"2025-02-13T06:16:45.000Z","created":"2022-06-30T11:02:34.189Z","2.0.2":"2025-01-31T15:45:51.486Z","2.0.1":"2024-12-23T06:12:21.723Z","2.0.0":"2024-06-23T16:07:51.893Z","1.3.0":"2022-12-04T23:49:36.764Z","1.2.0":"2022-11-27T13:11:48.726Z","1.1.0":"2022-07-07T11:23:52.115Z","1.0.0":"2022-06-30T11:02:34.189Z"},"users":{},"author":{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"versions":{"2.0.2":{"name":"@fastify/deepmerge","version":"2.0.2","description":"Merges the enumerable properties of two or more objects deeply.","main":"index.js","type":"commonjs","types":"types/index.d.ts","scripts":{"lint":"eslint","lint:fix":"eslint --fix","test":"npm run test:unit && npm run test:typescript","test:unit":"c8 tape test/*.js","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"author":{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Manuel Spigolon","email":"behemoth89@gmail.com"},{"name":"James Sumners","url":"https://james.sumners.info"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"MIT","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"homepage":"https://github.com/fastify/deepmerge#readme","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"devDependencies":{"eslint":"^9.17.0","neostandard":"^0.12.0","tape":"^5.7.5","c8":"^10.1.3","tsd":"^0.31.1"},"keywords":["merge","deep","recursive","object","immutable"],"_id":"@fastify/deepmerge@2.0.2","gitHead":"8b4210b95e1f8fb6992a221547f3d20054d13a29","_nodeVersion":"22.13.1","_npmVersion":"10.9.2","dist":{"shasum":"5dcbda2acb266e309b8a1ca92fa48b2125e65fc0","size":5157,"noattachment":false,"key":"/@fastify/deepmerge/-/@fastify/deepmerge-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/deepmerge/download/@fastify/deepmerge-2.0.2.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/deepmerge_2.0.2_1738338351296_0.4720690806899819"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-01-31T15:45:51.486Z","publish_time":1738338351486,"_source_registry_name":"default","_cnpm_publish_time":1738338351486},"2.0.1":{"name":"@fastify/deepmerge","version":"2.0.1","description":"Merges the enumerable properties of two or more objects deeply.","main":"index.js","type":"commonjs","types":"types/index.d.ts","scripts":{"lint":"eslint","lint:fix":"eslint --fix","test":"npm run test:unit && npm run test:typescript","test:unit":"tap","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"author":{"name":"Aras Abbasi","email":"aras.abbasi@gmail.com"},"contributors":[{"name":"Matteo Collina","email":"hello@matteocollina.com"},{"name":"Manuel Spigolon","email":"behemoth89@gmail.com"},{"name":"James Sumners","url":"https://james.sumners.info"},{"name":"Frazer Smith","email":"frazer.dev@icloud.com","url":"https://github.com/fdawgs"}],"license":"MIT","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"homepage":"https://github.com/fastify/deepmerge#readme","funding":[{"type":"github","url":"https://github.com/sponsors/fastify"},{"type":"opencollective","url":"https://opencollective.com/fastify"}],"devDependencies":{"eslint":"^9.17.0","neostandard":"^0.12.0","tap":"^21.0.0","tape":"^5.7.5","tsd":"^0.31.1"},"keywords":["merge","deep","recursive","object"],"_id":"@fastify/deepmerge@2.0.1","gitHead":"58050b9d3c73fab2a8cbfd7d44b9045d09f5a29d","_nodeVersion":"22.12.0","_npmVersion":"10.2.4","dist":{"shasum":"68150cd7ab709b63a718aac8335561779b910032","size":5081,"noattachment":false,"key":"/@fastify/deepmerge/-/@fastify/deepmerge-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/deepmerge/download/@fastify/deepmerge-2.0.1.tgz"},"_npmUser":{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},"directories":{},"maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/deepmerge_2.0.1_1734934341562_0.14444905898136562"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-12-23T06:12:21.723Z","publish_time":1734934341723,"_source_registry_name":"default","_cnpm_publish_time":1734934341723},"2.0.0":{"name":"@fastify/deepmerge","version":"2.0.0","description":"Merges the enumerable properties of two or more objects deeply.","main":"index.js","type":"commonjs","types":"types/index.d.ts","scripts":{"lint":"standard","lint:fix":"standard --fix","test":"npm run test:unit && npm run test:typescript","test:unit":"tap","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"author":"","license":"MIT","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"homepage":"https://github.com/fastify/deepmerge#readme","devDependencies":{"standard":"^17.1.0","tap":"^18.7.1","tape":"^5.7.5","tsd":"^0.30.7"},"keywords":["merge","deep","recursive","object"],"_id":"@fastify/deepmerge@2.0.0","gitHead":"a37e7ab2f193221f59103293e1a11427090c7816","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"shasum":"794e98a4eefd6e1edde852e924e25f47b0fed7d8","size":4752,"noattachment":false,"key":"/@fastify/deepmerge/-/@fastify/deepmerge-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/deepmerge/download/@fastify/deepmerge-2.0.0.tgz"},"_npmUser":{"name":"jsumners","email":"james.sumners@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/deepmerge_2.0.0_1719158871740_0.08085078048003069"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2024-06-23T16:07:51.893Z","publish_time":1719158871893,"_source_registry_name":"default","maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_cnpm_publish_time":1719158871893},"1.3.0":{"name":"@fastify/deepmerge","version":"1.3.0","description":"Merges the enumerable properties of two or more objects deeply.","main":"index.js","types":"types/index.d.ts","scripts":{"lint":"standard","lint:fix":"standard --fix","test":"npm run test:unit && npm run test:typescript","test:unit":"tap","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"author":"","license":"MIT","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"homepage":"https://github.com/fastify/deepmerge#readme","devDependencies":{"standard":"^17.0.0","tap":"^16.3.0","tape":"^5.6.1","tsd":"^0.24.1"},"keywords":["merge","deep","recursive","object"],"gitHead":"2983866428f0654bc29f232d0a034a6f80d4c0cb","_id":"@fastify/deepmerge@1.3.0","_nodeVersion":"16.17.0","_npmVersion":"9.1.2","dist":{"shasum":"8116858108f0c7d9fd460d05a7d637a13fe3239a","size":4733,"noattachment":false,"key":"/@fastify/deepmerge/-/@fastify/deepmerge-1.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/deepmerge/download/@fastify/deepmerge-1.3.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/deepmerge_1.3.0_1670197776595_0.04233355448632903"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-12-04T23:49:42.173Z","publish_time":1670197776764,"_cnpm_publish_time":1670197776764},"1.2.0":{"name":"@fastify/deepmerge","version":"1.2.0","description":"Merges the enumerable properties of two or more objects deeply.","main":"index.js","types":"types/index.d.ts","scripts":{"lint":"standard","lint:fix":"standard --fix","test":"npm run test:unit && npm run test:typescript","test:unit":"tap -J test/*.test.js test/**/*.test.js","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"author":"","license":"MIT","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"homepage":"https://github.com/fastify/deepmerge#readme","devDependencies":{"standard":"^17.0.0","tap":"^16.3.0","tape":"^5.6.1","tsd":"^0.24.1"},"keywords":["merge","deep","recursive","object"],"gitHead":"d93badc64487beb6213cc73075b922f79053581b","_id":"@fastify/deepmerge@1.2.0","_nodeVersion":"16.13.0","_npmVersion":"8.10.0","dist":{"shasum":"02e2c28b33799c0dca88cdf7831902f069e54faa","size":4713,"noattachment":false,"key":"/@fastify/deepmerge/-/@fastify/deepmerge-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/deepmerge/download/@fastify/deepmerge-1.2.0.tgz"},"_npmUser":{"name":"eomm","email":"behemoth89@gmail.com"},"directories":{},"maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/deepmerge_1.2.0_1669554708568_0.08300424262977701"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-11-27T13:11:58.713Z","publish_time":1669554708726,"_cnpm_publish_time":1669554708726},"1.1.0":{"name":"@fastify/deepmerge","version":"1.1.0","description":"Merges the enumerable properties of two or more objects deeply.","main":"index.js","types":"types/index.d.ts","scripts":{"lint":"standard","lint:fix":"standard --fix","test":"npm run test:unit && npm run test:typescript","test:unit":"tap -J test/*.test.js test/**/*.test.js","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"author":"","license":"MIT","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"homepage":"https://github.com/fastify/deepmerge#readme","devDependencies":{"standard":"^17.0.0","tap":"^16.3.0","tsd":"^0.22.0"},"keywords":["merge","deep","recursive","object"],"gitHead":"2066da1c3b076235a313f2b6c7b30348371d6441","_id":"@fastify/deepmerge@1.1.0","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"shasum":"91f0a5a27034ff76b7bece63a5906894940ace82","size":4410,"noattachment":false,"key":"/@fastify/deepmerge/-/@fastify/deepmerge-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/deepmerge/download/@fastify/deepmerge-1.1.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/deepmerge_1.1.0_1657193031990_0.12621056894400495"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-07-07T11:54:14.470Z","publish_time":1657193032115,"_cnpm_publish_time":1657193032115},"1.0.0":{"name":"@fastify/deepmerge","version":"1.0.0","description":"Merges the enumerable properties of two or more objects deeply.","main":"index.js","types":"types/index.d.ts","scripts":{"lint":"standard","lint:fix":"standard --fix","test":"npm run test:unit && npm run test:typescript","test:unit":"tap -J test/*.test.js test/**/*.test.js","test:typescript":"tsd"},"repository":{"type":"git","url":"git+https://github.com/fastify/deepmerge.git"},"author":"","license":"MIT","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"homepage":"https://github.com/fastify/deepmerge#readme","devDependencies":{"standard":"^17.0.0","tap":"^16.3.0","tsd":"^0.21.0"},"keywords":["merge","deep","recursive","object"],"gitHead":"bfed5b0d836de8f27dd12f8892cd98a66a075779","_id":"@fastify/deepmerge@1.0.0","_nodeVersion":"16.15.1","_npmVersion":"8.11.0","dist":{"shasum":"a0da35600bc761401780b5e748b1cc0a31560ce9","size":3643,"noattachment":false,"key":"/@fastify/deepmerge/-/@fastify/deepmerge-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@fastify/deepmerge/download/@fastify/deepmerge-1.0.0.tgz"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"directories":{},"maintainers":[{"name":"airhorns","email":"harry@harry.me"},{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"climba03003","email":"kaka@kakawebsitedemo.com"},{"name":"coopflow","email":"community@coopflow.com"},{"name":"delvedor","email":""},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"fox1t","email":""},{"name":"galvez","email":""},{"name":"gurgunday","email":""},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"kibertoad","email":"iselwin@gmail.com"},{"name":"matteo.collina","email":""},{"name":"metcoder95","email":""},{"name":"rafaelgss","email":"rafael.nunu@hotmail.com"},{"name":"simenb","email":"sbekkhus91@gmail.com"},{"name":"simoneb","email":"simone.busoli@gmail.com"},{"name":"starptech","email":"deusdustin@gmail.com"},{"name":"zekth","email":"vince.legoff@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/deepmerge_1.0.0_1656586954031_0.7180819481461587"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2022-06-30T17:01:25.276Z","publish_time":1656586954189,"_cnpm_publish_time":1656586954189}},"readme":"# @fastify/deepmerge\n\n[![CI](https://github.com/fastify/deepmerge/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/fastify/deepmerge/actions/workflows/ci.yml)\n[![NPM version](https://img.shields.io/npm/v/@fastify/deepmerge.svg?style=flat)](https://www.npmjs.com/package/@fastify/deepmerge)\n[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)\n\nMerges the enumerable properties of two or more objects deeply. Fastest implementation of deepmerge, see section 'Benchmarks'.\n\n### Install\n```\nnpm i @fastify/deepmerge\n```\n\n### Usage\n\nThe module exports a function, which provides a function to deepmerge Objects.\n\n`@fastify/deepmerge` does not mutate the input objects. It returns a new object, which is the result of the merge.\n\n```\ndeepmerge(options)\n```\n\n`options` is optional and can contain the following values:\n\n- `symbols` (`boolean`, optional) - should also merge object keys that are symbols, default is false\n- `all` (`boolean`, optional) - makes deepmerge accept and merge any number of passed objects, default is false\n- `mergeArray` (`function`, optional) - provide a function, which returns a function to add custom array merging function\n- `cloneProtoObject` (`function`, optional) - provide a function, which must return a clone of the object with the prototype of the object\n\n```js\nconst deepmerge = require('@fastify/deepmerge')()\nconst result = deepmerge({a: 'value'}, { b: 404 })\nconsole.log(result) // {a: 'value',  b: 404 }\n```\n\n```js\nconst deepmerge = require('@fastify/deepmerge')({ all: true })\nconst result = deepmerge({a: 'value'}, { b: 404 }, { a: 404 })\nconsole.log(result) // {a: 404,  b: 404 }\n```\n\n#### mergeArray\n\nThe default mode to merge Arrays is to concat the source-Array to the target-Array.\n\n```js\nconst target = [1, 2, 3]\nconst source = [4, 5, 6]\nconst deepmerge = require('@fastify/deepmerge')()\nconst result = deepmerge(target, source)\nconsole.log(result) // [1, 2, 3, 4, 5, 6]\n```\n\nTo overwrite the default behavior regarding merging Arrays, you can provide a function to the\n`mergeArray` option of the deepmerge-function. The function provided to `mergeArray`\ngets an options-parameter passed, which is an Object containing the following keys and values.\n\n```typescript\nclone: (value: any) => any;\nisMergeableObject: (value: any) => any;\ndeepmerge: DeepMergeFn;\ngetKeys: (value: object) => string[];\n```\n\nThe `mergeArray`-Function needs to return the actual Array merging function, which accepts two parameters of type\nArray, and returns a value.\n\nExample 1: Replace the target-Array with a clone of the source-Array.\n\n```js\nfunction replaceByClonedSource(options) {\n  const clone = options.clone\n  return function (target, source) {\n    return clone(source)\n  }\n}\n\nconst deepmerge = require('@fastify/deepmerge')({ mergeArray: replaceByClonedSource })\nconst result = deepmerge([1, 2, 3], [4, 5, 6])\nconsole.log(result) // [4, 5, 6]\n```\n\nExample 2: Merge each element of the source-Array with the element at the same index-position of the target-Array.\n\n```js\nfunction deepmergeArray(options) {\n  const deepmerge = options.deepmerge\n  const clone = options.clone\n  return function (target, source) {\n    let i = 0\n    const tl = target.length\n    const sl = source.length\n    const il = Math.max(target.length, source.length)\n    const result = new Array(il)\n    for (i = 0; i < il; ++i) {\n      if (i < sl) {\n        result[i] = deepmerge(target[i], source[i])\n      } else {\n        result[i] = clone(target[i])\n      }\n    }\n    return result\n  }\n}\n\n// default behavior\nconst deepmergeConcatArray = require('@fastify/deepmerge')()\nconst resultConcatArray = deepmergeConcatArray([{ a: [1, 2, 3 ]}], [{b: [4, 5, 6]}])\nconsole.log(resultConcatArray) // [ { a: [ 1, 2, 3 ]}, { b: [ 4, 5, 6 ] } ]\n\n// modified behavior\nconst deepmergeDeepmergeArray = require('@fastify/deepmerge')({ mergeArray: deepmergeArray })\nconst resultDeepmergedArray = deepmergeDeepmergeArray([{ a: [1, 2, 3 ]}], [{b: [4, 5, 6]}])\nconsole.log(resultDeepmergedArray) // [ { a: [ 1, 2, 3 ], b: [ 4, 5, 6 ] } ]\n```\n\n#### cloneProtoObject\n\nMerging objects with prototypes, such as Streams or Buffers, are not supported by default.\nYou can provide a custom function to let this module deal with the object that has a `prototype` _(JSON object excluded)_.\n\n```js\nfunction cloneByReference (source) {\n  return source\n}\n\nconst deepmergeByReference = require('@fastify/deepmerge')({\n  cloneProtoObject: cloneByReference\n})\n\nconst result = deepmergeByReference({}, { stream: process.stdout })\nconsole.log(result) // { stream: <ref *1> WriteStream }\n```\n\n## Benchmarks\n\nThe benchmarks are available in the benchmark folder.\n\n`npm run bench` - benchmark various use cases of deepmerge:\n```\n@fastify/deepmerge: merge regex with date x 1,256,523,040 ops/sec ±0.16% (92 runs sampled)\n@fastify/deepmerge: merge object with a primitive x 1,256,082,915 ops/sec ±0.25% (97 runs sampled)\n@fastify/deepmerge: merge two arrays containing strings x 25,392,605 ops/sec ±0.22% (97 runs sampled)\n@fastify/deepmerge: two merge arrays containing objects x 1,655,426 ops/sec ±0.65% (96 runs sampled)\n@fastify/deepmerge: merge two flat objects x 15,571,029 ops/sec ±0.45% (96 runs sampled)\n@fastify/deepmerge: merge nested objects x 7,601,328 ops/sec ±0.31% (96 runs sampled)\n```\n\n`npm run bench:compare` - comparison of @fastify/deepmerge with other popular deepmerge implementation:\n```\n@fastify/deepmerge x 605,343 ops/sec ±0.87% (96 runs sampled)\ndeepmerge x 20,312 ops/sec ±1.06% (92 runs sampled)\nmerge-deep x 83,167 ops/sec ±1.30% (94 runs sampled)\nts-deepmerge x 175,977 ops/sec ±0.57% (96 runs sampled)\ndeepmerge-ts x 174,973 ops/sec ±0.44% (93 runs sampled)\nlodash.merge x 89,213 ops/sec ±0.70% (98 runs sampled)\n```\n\n## License\n\nLicensed under [MIT](./LICENSE).\n","_attachments":{},"homepage":"https://github.com/fastify/deepmerge#readme","bugs":{"url":"https://github.com/fastify/deepmerge/issues"},"license":"MIT"}