@fastify/deepmerge
Advanced tools
+4
-4
@@ -22,3 +22,3 @@ 'use strict' | ||
| const result = new Array(il) | ||
| for (i = 0; i < il; ++i) { | ||
| for (i; i < il; ++i) { | ||
| result[i] = clone(value[i]) | ||
@@ -50,3 +50,3 @@ } | ||
| const result = new Array(tl + sl) | ||
| for (i = 0; i < tl; ++i) { | ||
| for (i; i < tl; ++i) { | ||
| result[i] = clone(target[i]) | ||
@@ -70,3 +70,3 @@ } | ||
| const getKeys = options && options.symbols | ||
| const getKeys = options?.symbols | ||
| ? getSymbolsAndKeys | ||
@@ -167,3 +167,3 @@ : Object.keys | ||
| return options && options.all | ||
| return options?.all | ||
| ? _deepmergeAll | ||
@@ -170,0 +170,0 @@ : _deepmerge |
+5
-4
| { | ||
| "name": "@fastify/deepmerge", | ||
| "version": "2.0.1", | ||
| "version": "2.0.2", | ||
| "description": "Merges the enumerable properties of two or more objects deeply.", | ||
@@ -12,3 +12,3 @@ "main": "index.js", | ||
| "test": "npm run test:unit && npm run test:typescript", | ||
| "test:unit": "tap", | ||
| "test:unit": "c8 tape test/*.js", | ||
| "test:typescript": "tsd" | ||
@@ -58,4 +58,4 @@ }, | ||
| "neostandard": "^0.12.0", | ||
| "tap": "^21.0.0", | ||
| "tape": "^5.7.5", | ||
| "c8": "^10.1.3", | ||
| "tsd": "^0.31.1" | ||
@@ -73,4 +73,5 @@ }, | ||
| "recursive", | ||
| "object" | ||
| "object", | ||
| "immutable" | ||
| ] | ||
| } |
+10
-8
@@ -18,2 +18,4 @@ # @fastify/deepmerge | ||
| `@fastify/deepmerge` does not mutate the input objects. It returns a new object, which is the result of the merge. | ||
| ``` | ||
@@ -23,6 +25,6 @@ deepmerge(options) | ||
| `options` is optional and can contain following values | ||
| `options` is optional and can contain the following values: | ||
| - `symbols` (`boolean`, optional) - should also merge object-keys which are symbols, default is false | ||
| - `all` (`boolean`, optional) - merges all parameters, default is false | ||
| - `symbols` (`boolean`, optional) - should also merge object keys that are symbols, default is false | ||
| - `all` (`boolean`, optional) - makes deepmerge accept and merge any number of passed objects, default is false | ||
| - `mergeArray` (`function`, optional) - provide a function, which returns a function to add custom array merging function | ||
@@ -55,3 +57,3 @@ - `cloneProtoObject` (`function`, optional) - provide a function, which must return a clone of the object with the prototype of the object | ||
| To overwrite the default behaviour regarding merging Arrays, you can provide a function to the | ||
| To overwrite the default behavior regarding merging Arrays, you can provide a function to the | ||
| `mergeArray` option of the deepmerge-function. The function provided to `mergeArray` | ||
@@ -108,3 +110,3 @@ gets an options-parameter passed, which is an Object containing the following keys and values. | ||
| // default behaviour | ||
| // default behavior | ||
| const deepmergeConcatArray = require('@fastify/deepmerge')() | ||
@@ -114,3 +116,3 @@ const resultConcatArray = deepmergeConcatArray([{ a: [1, 2, 3 ]}], [{b: [4, 5, 6]}]) | ||
| // modified behaviour | ||
| // modified behavior | ||
| const deepmergeDeepmergeArray = require('@fastify/deepmerge')({ mergeArray: deepmergeArray }) | ||
@@ -141,7 +143,7 @@ const resultDeepmergedArray = deepmergeDeepmergeArray([{ a: [1, 2, 3 ]}], [{b: [4, 5, 6]}]) | ||
| The benchmarks are available in the benchmark-folder. | ||
| The benchmarks are available in the benchmark folder. | ||
| `npm run bench` - benchmark various use cases of deepmerge: | ||
| ``` | ||
| @@fastify/deepmerge: merge regex with date x 1,256,523,040 ops/sec ±0.16% (92 runs sampled) | ||
| @fastify/deepmerge: merge regex with date x 1,256,523,040 ops/sec ±0.16% (92 runs sampled) | ||
| @fastify/deepmerge: merge object with a primitive x 1,256,082,915 ops/sec ±0.25% (97 runs sampled) | ||
@@ -148,0 +150,0 @@ @fastify/deepmerge: merge two arrays containing strings x 25,392,605 ops/sec ±0.22% (97 runs sampled) |
+1
-1
@@ -75,3 +75,3 @@ type DeepMergeFn = <T1, T2>(target: T1, source: T2) => DeepMerge<T1, T2> | ||
| declare namespace deepmerge { | ||
| export { Options } | ||
| export { Options, DeepMergeFn, DeepMergeAllFn } | ||
| export const deepmerge: DeepmergeConstructor | ||
@@ -78,0 +78,0 @@ export { deepmerge as default } |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
15663
1.21%163
1.24%0
-100%