scuttlebutt
Advanced tools
Comparing version 5.5.17 to 5.5.18
11
model.js
@@ -52,2 +52,3 @@ var Scuttlebutt = require('./index') | ||
//ignore if we already have a more recent value | ||
if('undefined' !== typeof this.store[key] | ||
@@ -60,2 +61,3 @@ && this.store[key][1] > update[1]) | ||
this.store[key] = update | ||
this.emit.apply(this, ['update'].concat(update)) | ||
@@ -79,6 +81,9 @@ this.emit('change', key, update[0][1]) | ||
m.toJSON = function () { | ||
var o = {} | ||
for (var k in this.store) | ||
o[k] = this.get(k) | ||
var o = {}, notNull = false | ||
for (var k in this.store) { | ||
var v = this.get(k) | ||
if(v != null) | ||
o[k] = this.get(k) | ||
} | ||
return o | ||
} |
@@ -5,3 +5,3 @@ { | ||
"description": "replicate data via scuttlebutt protocol", | ||
"version": "5.5.17", | ||
"version": "5.5.18", | ||
"homepage": "https://github.com/dominictarr/scuttlebutt", | ||
@@ -8,0 +8,0 @@ "repository": { |
@@ -11,9 +11,12 @@ require('tape')('model', function (t) { | ||
a.on('change', mac(function (key, value) { | ||
t.deepEqual({}, a.toJSON()) | ||
a.once('change', mac(function (key, value) { | ||
t.ok(expected[key] !== undefined) | ||
t.equal(value, expected[key]) | ||
t.deepEqual(a.toJSON(), expected) | ||
next() | ||
}).atLeast(1)) | ||
a.on('change:key', mac(function (value) { | ||
a.once('change:key', mac(function (value) { | ||
t.equal(value, expected.key) | ||
@@ -23,3 +26,2 @@ next() | ||
a.set('key', expected.key) | ||
@@ -29,5 +31,14 @@ var n = 2 | ||
if(--n) return | ||
a.set('key', null) | ||
t.equal(a.get('key'), null) | ||
t.deepEqual(a.toJSON(), {}) | ||
t.end() | ||
} | ||
a.set('key', expected.key) | ||
}) | ||
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
99342
1027