Comparing version 3.3.0 to 3.3.1
42
doc.js
@@ -27,3 +27,3 @@ var inherits = require('util').inherits | ||
set breathing to 0 to kill something. | ||
if a node has rows that have been garbage collected on the server, | ||
@@ -37,3 +37,3 @@ it will be obvious from the value of breathing. | ||
server updates the node, but only increments _breathing for some rows. | ||
clearly, the nodes that do not have an upto date _breathing are either | ||
@@ -43,3 +43,3 @@ dead, or where created by the node while it was offline. | ||
would breathing need to be a vector clock? | ||
if the disconneded node is still updating the rows, | ||
@@ -61,3 +61,3 @@ maybe it shouldn't be deleted, that is, undeleted. | ||
//that is, to the node. | ||
//it's used to identify a node | ||
//it's used to identify a node | ||
// this.id = id || '#' + Math.round(Math.random()*1000) | ||
@@ -102,3 +102,3 @@ this.rows = {} | ||
Doc.prototype.timeUpdated = function (row, key) { | ||
var h = this.hist[row.id] | ||
var h = this.hist[row.id] | ||
if(!h) return | ||
@@ -144,3 +144,3 @@ return h[key][2] | ||
// if(!row.validate(changes)) return | ||
for(var key in changes) { | ||
@@ -152,18 +152,18 @@ var value = changes[key] | ||
changed[key] = changes[key] | ||
emit = true | ||
emit = true | ||
} | ||
} | ||
// probably, there may be mulitple sets that listen to the same key, | ||
// probably, there may be mulitple sets that listen to the same key, | ||
// but activate on different values... | ||
// | ||
// hang on, in the mean time, I will probably only be managing n < 10 sets. | ||
// at once, | ||
// hang on, in the mean time, I will probably only be managing n < 10 sets. | ||
// at once, | ||
merge(row.state, changed) | ||
for(var k in changed) | ||
this.sets.emit(k, row, changed) | ||
this.sets.emit(k, row, changed) | ||
if(!emit) return | ||
if(row._new) { | ||
@@ -196,7 +196,15 @@ this.emit('add', row) | ||
function _set(self, key, val, type) { | ||
var id = key + ':' + val | ||
if(self.sets[id]) return self.sets[id] | ||
return self.sets[key + ':' + val] = new type(self, key, val) | ||
var id = typeof key === 'string' && key + ':' + val | ||
if(id && self.sets[id]) { | ||
return self.sets[id] | ||
} | ||
var set = new type(self, key, val) | ||
if (id) { | ||
self.sets[id] = set | ||
} | ||
return set | ||
} | ||
Doc.prototype.createSet = function (key, val) { | ||
@@ -217,3 +225,3 @@ return _set(this, key, val, Set) | ||
//retrive a reference to a row. | ||
//if the row is not created yet, create | ||
//if the row is not created yet, create | ||
Doc.prototype.get = function (id) { | ||
@@ -220,0 +228,0 @@ return this.rows[id] = this.rows[id] || this._add(new Row(id), 'local') |
@@ -5,3 +5,3 @@ { | ||
"description": "Commutative Replicated Data Types for easy distributed/collaborative apps", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"homepage": "http://github.com/dominictarr/crdt", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -102,2 +102,5 @@ #CRDT - Commutative Replicated Data Types | ||
A filter function should just be a more expressive filter and | ||
shouldn't be a stateful function | ||
### Doc#createSeq (key, value) | ||
@@ -104,0 +107,0 @@ |
@@ -109,2 +109,17 @@ var crdt = require('..') | ||
exports['set caching'] = function (t) { | ||
var doc = new crdt.Doc() | ||
var set1 = doc.createSet("foo", "bar") | ||
var set2 = doc.createSet("foo", "bar") | ||
a.equal(set1, set2) | ||
var set3 = doc.createSet(function () { }) | ||
var set4 = doc.createSet(function () { }) | ||
a.notEqual(set3, set4) | ||
t.end() | ||
} | ||
function log(set) { | ||
@@ -111,0 +126,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1053374
11992
261