alamid-junction
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -118,2 +118,21 @@ "use strict"; | ||
/** | ||
* Resets all keys to the given value. If no value is given, all keys will have the value undefined. | ||
* | ||
* @param {*=} value | ||
* @returns {Junction} | ||
*/ | ||
Junction.prototype.reset = function (value) { | ||
var obj = this._signals, | ||
key; | ||
for (key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
this.setter(key, value); | ||
} | ||
} | ||
return this; | ||
}; | ||
/** | ||
* Returns the signal instance to the given key. | ||
@@ -120,0 +139,0 @@ * |
{ | ||
"name": "alamid-junction", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Provides convenient methods for setting and retrieving multiple signals", | ||
@@ -5,0 +5,0 @@ "main": "./lib/Junction.js", |
@@ -185,2 +185,46 @@ "use strict"; | ||
describe(".reset()", function () { | ||
beforeEach(function () { | ||
junction.set("greeting", "Ahoy!"); | ||
junction.set("age", 34); | ||
}); | ||
it("should set all keys to the given value", function () { | ||
junction.reset(); | ||
expect(junction.get()).to.eql({ | ||
greeting: undefined, | ||
age: undefined | ||
}); | ||
}); | ||
it("should call the internal setter function", function () { | ||
junction.setter = sinon.spy(); | ||
junction.reset(); | ||
expect(junction.setter).to.have.been.called; | ||
}); | ||
}); | ||
describe(".reset(value)", function () { | ||
beforeEach(function () { | ||
junction.set("greeting", "Ahoy!"); | ||
junction.set("age", 34); | ||
}); | ||
it("should set all keys to the given value", function () { | ||
junction.reset(true); | ||
expect(junction.get()).to.eql({ | ||
greeting: true, | ||
age: true | ||
}); | ||
}); | ||
}); | ||
describe(".signal(key)", function () { | ||
@@ -187,0 +231,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
16869
405