npm.io
0.1.0 • Published 11 years ago

scuttle-patch

Licence
ISC
Version
0.1.0
Deps
3
Vulns
0
Weekly
0
Stars
3

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"}

Keywords