Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Module for sync local object variable with *.js or *.coffee file
CoffeeScript
tag: v0.0.3

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
LICENSE
README.md
jsync.coffee
jsync.js
package.json
tests.coffee
tests.js

README.md

jSync - Module for sync local object variable with *.js or *.coffee file

Installation

$ npm install jsync

Simple usage

var jsync = require('jsync');
var obj = jsync('data.json'); // also you can load *.js and *.coffee files

// now object will keep in sync with json-file

Set interval

var obj = jsync('data.js', 100); // file check every 100ms

Set context for eval

// data.js
{
    someVariable: this.prop
}
context = { prop: 'value' };
var obj = jsync('data.js', false, context);
console.log(obj); // { someVariable: 'value' }

Set handler

// data.js
[1,2,3,4]
function handler (arr) {
    return arr.slice(2);
}
var obj = jsync('data.js', false, false, handler);
console.log(obj); // [3,4]

Unwatch

jsync.unwatch(obj);

Simple read without sync

var obj = jsync.read('data.js', context);

Manual sync with or without new context

jsync.trigger(obj, newContext);
Something went wrong with that request. Please try again.