@remy/merge
Advanced tools
+28
| # What? | ||
| Another merge library, but I had a need to support merging objects who also had array properties (where as lodash's merge doesn't merge arrays, only objects). | ||
| Features: | ||
| - Deep merge | ||
| - Object merging | ||
| - Array merge | ||
| - Priority from right to left | ||
| # Install | ||
| ``` | ||
| npm install --save @remy/merge | ||
| ``` | ||
| # Usage | ||
| ``` | ||
| const result = merge(a, b); | ||
| ``` | ||
| Both `a` and `b` are untouched (i.e. this method doesn't mutate). | ||
| If a the same key appears as a primitive in `a` and `b`, then the value from `b` is in the result. | ||
| If the same key appears as an array or as an object, the result is the merged result. |
+2
-5
@@ -13,8 +13,5 @@ var clone = require('./clone'); | ||
| * @param {Object} target [description] | ||
| * @return {Object} [description] | ||
| */ | ||
| function merge(source, target, result) { | ||
| if (result === undefined) { | ||
| result = clone(source); | ||
| } | ||
| function merge(source, target) { | ||
| var result = clone(source); | ||
@@ -21,0 +18,0 @@ // merge missing values from the target to the source |
+15
-3
| { | ||
| "name": "@remy/merge", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "Merge - like most tools, except also supports arrays", | ||
| "main": "merge.js", | ||
| "scripts": { | ||
| "test": "echo \"Error: no test specified\" && exit 1" | ||
| "test": "node __tests__/*.test.js" | ||
| }, | ||
| "files": [ | ||
| "clone.js", | ||
| "merge.js" | ||
| ], | ||
| "keywords": [], | ||
| "author": "Remy Sharp (https://remysharp.com)", | ||
| "license": "MIT" | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/remy/merge.git" | ||
| }, | ||
| "bugs": { | ||
| "url": "https://github.com/remy/merge/issues" | ||
| }, | ||
| "homepage": "https://github.com/remy/merge#readme" | ||
| } |
| var merge = require('../'); | ||
| const a = { | ||
| env: { | ||
| browser: true, | ||
| es6: true, | ||
| commonjs: true, | ||
| }, | ||
| extends: ['eslint:recommended'], | ||
| parser: 'babel-eslint', | ||
| parserOptions: { | ||
| ecmaVersion: 8, | ||
| ecmaFeatures: { | ||
| jsx: true, | ||
| }, | ||
| sourceType: 'module', | ||
| }, | ||
| plugins: ['react', 'node'], | ||
| rules: { | ||
| 'react/prop-types': 0, | ||
| 'react/jsx-uses-vars': [2], | ||
| }, | ||
| }; | ||
| const b = { | ||
| plugins: [true], | ||
| rules: { a: 1 }, | ||
| }; | ||
| console.log(merge(a, b).rules); |
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
3155
10.01%1
-50%0
-100%1
-50%29
Infinity%0
-100%71
-29.7%