Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "diffsync", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Real time collaborative editing for JSON objects", | ||
@@ -10,4 +10,5 @@ "main": "index.js", | ||
"dependencies": { | ||
"jsondiffpatch": "^0.1.31", | ||
"underscore": "^1.8.3" | ||
"amp-bind": "^1.0.1", | ||
"amp-is-empty": "^1.0.2", | ||
"jsondiffpatch": "^0.1.31" | ||
}, | ||
@@ -14,0 +15,0 @@ "devDependencies": { |
@@ -1,2 +0,3 @@ | ||
var _ = require('underscore'), | ||
var isEmpty = require('amp-is-empty'), | ||
bind = require('amp-bind'), | ||
EventEmitter = require('events').EventEmitter, | ||
@@ -30,3 +31,10 @@ jsondiffpatch = require('jsondiffpatch').create({ | ||
_.bindAll(this, '_onConnected', 'syncWithServer', 'applyServerEdit', 'applyServerEdits', 'schedule'); | ||
// bind functions | ||
var methodsToBind = ['_onConnected', 'syncWithServer', 'applyServerEdit', 'applyServerEdits', 'schedule'], | ||
method; | ||
for(var index in methodsToBind){ | ||
method = methodsToBind[index]; | ||
this[method] = bind(this[method], this); | ||
} | ||
}; | ||
@@ -108,3 +116,3 @@ | ||
// 2) add the difference to the local edits stack if the diff is not empty | ||
if(!_.isEmpty(diff)){ | ||
if(!isEmpty(diff)){ | ||
this.doc.edits.push(this.createDiffMessage(diff, basedOnLocalVersion)); | ||
@@ -220,3 +228,3 @@ this.doc.localVersion++; | ||
if(!_.isEmpty(editMessage.diff)){ | ||
if(!isEmpty(editMessage.diff)){ | ||
// versions match | ||
@@ -223,0 +231,0 @@ // 3) patch the shadow |
@@ -1,2 +0,3 @@ | ||
var _ = require('underscore'), | ||
var isEmpty = require('amp-is-empty'), | ||
bind = require('amp-bind'), | ||
jsondiffpatch = require('jsondiffpatch').create({ | ||
@@ -17,3 +18,4 @@ objectHash: function(obj) { return obj.id || obj._id || JSON.stringify(obj); } | ||
_.bindAll(this, 'trackConnection'); | ||
// bind functions | ||
this.trackConnection = bind(this.trackConnection, this); | ||
@@ -135,3 +137,3 @@ this.transport.on('connection', this.trackConnection); | ||
// 3.a) increase the version number for the shadow if diff not empty | ||
if(!_.isEmpty(edit.diff)){ | ||
if(!isEmpty(edit.diff)){ | ||
clientDoc.shadow.localVersion++; | ||
@@ -173,3 +175,3 @@ } | ||
// add the difference to the server's edit stack | ||
if(!_.isEmpty(diff)){ | ||
if(!isEmpty(diff)){ | ||
clientDoc.edits.push({ | ||
@@ -176,0 +178,0 @@ serverVersion: basedOnServerVersion, |
39853
967
3
+ Addedamp-bind@^1.0.1
+ Addedamp-is-empty@^1.0.2
+ Addedamp-bind@1.0.1(transitive)
+ Addedamp-has@1.0.1(transitive)
+ Addedamp-index-of@1.1.0(transitive)
+ Addedamp-is-arguments@1.0.1(transitive)
+ Addedamp-is-array@1.0.1(transitive)
+ Addedamp-is-empty@1.0.2(transitive)
+ Addedamp-is-function@1.0.1(transitive)
+ Addedamp-is-nan@1.0.1(transitive)
+ Addedamp-is-number@1.0.1(transitive)
+ Addedamp-is-object@1.0.1(transitive)
+ Addedamp-is-string@1.0.1(transitive)
+ Addedamp-keys@1.0.1(transitive)
- Removedunderscore@^1.8.3
- Removedunderscore@1.13.7(transitive)