This package has been deprecated

Author message:

This package has a known vulnerability, and won't be maintained, use lodash/mergeWith instead

mergify

1.0.3 • Public • Published

Mergify

npm version build status coverage status

const merge = require('mergify');
 
class D { constructor(o) { Object.assign(this, o); } }
 
merge(
    {a: {x: 1}, b: [2, 4], c: ['x'], d: new D({x: 5}), e: new Set([1, 3])}, 
    {a: {y: 1}, b: {1: 3}, c: ['y'], d: new D({y: 5}), e: new Set([2, 3])}
) 
 
// { a: {x: 1, y: 1}, b: [ 2, 3 ], c: ['x', 'y'], d: new D({y: 5}), e: new Set([1, 3, 2]) }
  • merges plain objects deeply
  • handles Sets and Maps (native ones or immutablesjs, with duck-typing)
  • concatenates arrays
  • works well with configurations, like webpack ones

Similar to lodash's mergeWith, but with some nuances (search for 'lodash')

const {mergeWith} = require('lodash');
const merge = (...o) => o.reduce((a, b) => 
    mergeWith(a, b, (a, b) => Array.isArray(a) && Array.isArray(b) ? [...a, ...b] : undefined)
);

Package Sidebar

Install

npm i mergify

Weekly Downloads

4

Version

1.0.3

License

ISC

Unpacked Size

3.19 kB

Total Files

3

Last publish

Collaborators

  • caub