0.1.0 • Published 9 years ago

scuttle-patch v0.1.0

Weekly downloads
5
License
ISC
Repository
github
Last release
9 years ago

scuttle-patch

A JSON-Patch backed scuttlebutt that supports replicating arbitrary JSON objects.

build status

Installation

This module is installed via npm:

$ npm install scuttle-patch

Example Usage

var ScuttlePatch = require('scuttle-patch');

var model = new ScuttlePatch();
model.on('change', function(updatedDoc) {
  console.log(JSON.stringify(updatedDoc));
});

model.update({a: 10, b: true, c:[2, 1]});
model.update({a: 10, c: [1, 2]});

model.patch([{op: 'add', path: '/d', value: 'Hello'}]);

console.log(model.toJSON());

//should output:
// {"a": 10, "c": [1, 2], "d": "Hello"}