Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/brooksn/merge-to-source
- Owner: brooksn
- Created: 2015-02-08T08:58:32.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-08T09:01:29.000Z (almost 10 years ago)
- Last Synced: 2024-12-18T14:19:28.758Z (about 1 month ago)
- Language: JavaScript
- Size: 129 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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 ```