Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/brooksn/merge-to-source

Merge an object's changes back to its source.
https://github.com/brooksn/merge-to-source

Last synced: 2 days ago
JSON representation

Merge an object's changes back to its source.

Awesome Lists containing this project

README

        

merge-to-source
===============
Merge an object's changes back to its source.

Usage
-----
Basic usage:

```
var merge = require('merge-to-source');
var pets = { name: 'Spot', age: 3 };
var branch = merge(source);
pets.location = 'Earth';
branch.age = 4;
merge(branch, pets);
//pets: { name: 'Spot', age: 4, location: 'Earth' }
```

Clone an object and store its initial state:

```
var source = { name: 'Spot', age: 3 };
var branch = merge(source);
//make some changes
merge(branch, source);
```

Bring your own object and store its initial state:

```
var source = { name: 'Spot', age: 3 };
var branch = { name: 'Spot', age: 3 };
merge(branch, true);
//make some changes
merge(branch, source);
```

Install
-------
``` npm install merge-to-source --save ```