======
$ npm install jsync
var jsync = require('jsync');
var obj = jsync('data.json'); // also you can load *.js, *.cson and *.coffee files
// now object will keep in sync with json-file
var obj = jsync('data.js', 100); // file check every 100ms
// data.js
{
someVariable: this.prop
}
Context can only be the Object
context = { prop: 'value' };
var obj = jsync('data.js', context);
console.log(obj); // { someVariable: 'value' }
// data.js
[1,2,3,4]
function handler (err, arr) {
arr.splice(2);
}
var obj = jsync('data.js', handler);
console.log(obj); // [1,2]
var obj = jsync(file, interval, context, handler); // all arguments are optional except `file`
jsync.cancel(obj);
var obj = jsync.read('data.js', context);
jsync.trigger(obj, newContext);
var obj = jsync('data.js');
jsync.save(obj/*, fileName, callback */); // if fileName not set it will use 'data.js'
function will execute asynchronously if callback is set
$ cd /path/to/jsync/
$ npm test