New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

mergify

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mergify

Merge objects deeply

latest
Source
npmnpm
Version
1.0.3
Version published
Maintainers
1
Created
Source

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)
);

Keywords

object

FAQs

Package last updated on 19 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts