Skip to content

phazelift/merge-plus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

merge-plus

A highly flexible, more robust, non-destructive deep object merge

  • accepts multiple arguments of any type
  • automatically extracts objects from array(s) of objects
  • due to dynamic type checking of arguments, only applies objects
  • non-destructive

Now you can go pretty weird without messing up!

var merge= require( 'merge-plus' );

// as expected:
var test= merge( {hello: '?'}, { hello: {world: '!'}} );
// { hello: { world: '!' } }

// can mix multiple arrays of objects and objects
var test= merge( [{a:1}, {x: {deep: {deeper: '?'}}}], {mixed: true}, [{c:3}, {x: {deep: {deeper: ':)'}}}] );
console.log( test );
// { a: 1, x: { deep: { deeper: ':)' } }, mixed: true, c: 3 }

// ignores non-object type arguments
var test= merge( 'merge-plus!', [new Date, [null, [{a:1}, {b: 2}, {c:{deep: { deeper: true}}}], 42, [{d:[{huh: '?'}]}], {e: 1}, [], /hello regexp/, {f: 4}]] )
console.log( test );
//	{ a: 1,
//	  b: 2,
//	  c: { deep: { deeper: true } },
//	  d: [ { huh: '?' } ],
//	  e: 1,
//	  f: 4 }

###license

MIT

About

A highly flexible and more robust deep object merge

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published