alamid-junction
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -135,2 +135,22 @@ "use strict"; | ||
/** | ||
* Removes all keys from the value store and sets all signals on undefined. | ||
* | ||
* @returns {Junction} | ||
*/ | ||
Junction.prototype.reset = function () { | ||
var signals = this._signals, | ||
key; | ||
this._values = {}; | ||
for (key in signals) { | ||
if (signals.hasOwnProperty(key)) { | ||
signals[key](undefined); | ||
} | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Removes the given key from the internal value store and sets the signal on undefined. | ||
@@ -137,0 +157,0 @@ * |
{ | ||
"name": "alamid-junction", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Provides convenient methods for setting and retrieving multiple signals", | ||
@@ -5,0 +5,0 @@ "main": "./lib/Junction.js", |
@@ -185,2 +185,29 @@ "use strict"; | ||
describe(".reset()", function () { | ||
beforeEach(function () { | ||
junction.set("greeting", "Ahoy!"); | ||
junction.set("age", 34); | ||
}); | ||
it("should remove all keys from the junction", function () { | ||
junction.reset(); | ||
expect(junction.get()).to.eql({}); | ||
}); | ||
it("should set the key's signal to undefined", function () { | ||
var greeting = junction.signal("greeting"), | ||
age = junction.signal("age"); | ||
expect(greeting()).to.equal(34); | ||
junction.reset(); | ||
expect(greeting()).to.equal(undefined); | ||
}); | ||
it("should be chainable", function () { | ||
expect(junction.reset()).to.equal(junction); | ||
}); | ||
}); | ||
describe(".remove(key)", function () { | ||
@@ -202,7 +229,7 @@ | ||
it("should set the key's signal to undefined", function () { | ||
var signal = junction.signal("greeting"); | ||
var greeting = junction.signal("greeting"); | ||
expect(signal()).to.equal("Ahoy!"); | ||
expect(greeting()).to.equal("Ahoy!"); | ||
junction.remove("greeting"); | ||
expect(signal()).to.equal(undefined); | ||
expect(greeting()).to.equal(undefined); | ||
}); | ||
@@ -209,0 +236,0 @@ |
17686
432