No description, website, or topics provided.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test
.agignore
.editorconfig
.gitignore
.travis.yml
README.md
deepest-merge.js
package.json

README.md

deepestMerge

Build Status

Deepely merges multiple objects together.

If the two keys are functions, composes a wrapper function which calls each function in line (right most first), passing in the final composed object as the context.

If the two keys are arrays, concatenates them together.

It the two keys are objects, recursively calls itself on those objects.

Else, the right most key "wins" and the key to the "left" is overwritten.

Installation

npm install deepest-merge

Example

> var deepestMerge = require('deepest-merge');
> var test1 = false;
> var test2 = false;
> var src = {a: function(){
    test1 = true;
  }};
> var src2 = {a: function(){
    test2 = true;
  }};
> var merged = deepestMerge(src, src2);
> merged.a();
> test1
true
> test2
true

deepestMerge(arguments) → {object}

Merge two objects together recursively, merging any nested objects as well including arrays and functions.

If two key names match and the values aren't functions or arrays, the "latest" key wins (right imporant). If the values are functions or arrays, the values are merged -- either wrapped in a function which calls both functions in a row supplying the final object as the context, or concatenated together with Array.concat

Parameters:
Name Type Argument Description
arguments object <repeatable>

Objects you'd like to merge together

Source:
Returns:

merged object

Type
object

generated with docme