mediator-js
Advanced tools
Comparing version 0.9.2 to 0.9.3
@@ -24,3 +24,3 @@ /*jslint bitwise: true, nomen: true, plusplus: true, white: true */ | ||
// AMD | ||
define('Mediator', [], function() { | ||
define('mediator-js', [], function() { | ||
root.Mediator = factory(); | ||
@@ -179,5 +179,3 @@ return root.Mediator(); | ||
removeSubscriber: function(identifier){ | ||
var x = 0, | ||
y; | ||
y = this._subscribers.length; | ||
var x = this._subscribers.length - 1; | ||
@@ -191,3 +189,3 @@ // If we don't pass in an id, we're clearing all | ||
// Going backwards makes splicing a whole lot easier. | ||
for(x, y; y > x; y--) { | ||
for(x; x >= 0; x--) { | ||
if(this._subscribers[x].fn === identifier || this._subscribers[x].id === identifier){ | ||
@@ -194,0 +192,0 @@ this._subscribers[x].channel = null; |
{ | ||
"name": "mediator-js", | ||
"version": "0.9.2", | ||
"version": "0.9.3", | ||
"description": "Flexible event management. Implementation of the mediator pattern.", | ||
@@ -9,3 +9,4 @@ "author": "Jack Lawson <jlawson@olivinelabs.com>", | ||
"scripts": { | ||
"test": "mocha && MEDIATOR_JS_COV=1 mocha -R html-cov > coverage.html" | ||
"test": "mocha", | ||
"test_with_coverage": "mocha && MEDIATOR_JS_COV=1 mocha -R html-cov > coverage.html" | ||
}, | ||
@@ -12,0 +13,0 @@ "respository": { |
Mediator.js | ||
=========== | ||
Version 0.9.2 | ||
[![Build Status](https://travis-ci.org/ajacksified/Mediator.js.png)](https://travis-ci.org/ajacksified/Mediator.js) | ||
__Breaking changes since version 0.7.0:__ see changelog below | ||
Version 0.9.3 | ||
@@ -59,2 +59,5 @@ For more information, please see | ||
__Note__: if using AMD / Almond module loading, use the NPM package name: | ||
`require("mediator-js").Mediator` | ||
```html | ||
@@ -212,4 +215,5 @@ <script src="/js/Mediator.min.js"></script> | ||
__Version 0.9.2__ | ||
* Updated AMD `define` syntax | ||
__Version 0.9.3__ | ||
* Make AMD name match npm package name (`mediator-js`). Used `Mediator.js` | ||
previously. | ||
@@ -216,0 +220,0 @@ __Version 0.9.1__ |
@@ -186,13 +186,16 @@ var Mediator = require("../index").Mediator, | ||
spy2 = sinon.spy(), | ||
sub = channel.addSubscriber(spy); | ||
channel.addSubscriber(spy2); | ||
spy3 = sinon.spy(); | ||
channel.addSubscriber(spy); | ||
var sub2 = channel.addSubscriber(spy2); | ||
expect(channel._subscribers.length).to.equal(2); | ||
channel.removeSubscriber(sub.id); | ||
expect(channel._subscribers.length).to.equal(1); | ||
expect(channel._subscribers[0].fn).to.equal(spy2); | ||
channel.addSubscriber(spy3); | ||
expect(channel._subscribers.length).to.equal(3); | ||
channel.removeSubscriber(sub2.id); | ||
expect(channel._subscribers.length).to.equal(2); | ||
expect(channel._subscribers[0].fn).to.equal(spy); | ||
expect(channel._subscribers[1].fn).to.equal(spy3); | ||
}); | ||
it("should do nothing if an valid fn is given", function(){ | ||
@@ -199,0 +202,0 @@ var spy = sinon.spy(), |
Sorry, the diff of this file is not supported yet
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
123915
2755
279