Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Commit

Permalink
Merge branch 'release/4.2.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
Olical committed Oct 26, 2013
2 parents c47ab92 + d83f7dd commit f7442a1
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 7 deletions.
16 changes: 13 additions & 3 deletions EventEmitter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* EventEmitter v4.2.4 - git.io/ee
* EventEmitter v4.2.5 - git.io/ee
* Oliver Caldwell
* MIT license
* @preserve
Expand All @@ -17,9 +17,9 @@
function EventEmitter() {}

// Shortcuts to improve speed and size

// Easy access to the prototype
var proto = EventEmitter.prototype;
var exports = this;
var originalGlobalValue = exports.EventEmitter;

/**
* Finds the index of the listener for the event in it's storage array.
Expand Down Expand Up @@ -447,6 +447,16 @@
return this._events || (this._events = {});
};

/**
* Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
*
* @return {Function} Non conflicting EventEmitter class.
*/
EventEmitter.noConflict = function noConflict() {
exports.EventEmitter = originalGlobalValue;
return EventEmitter;
};

// Expose the class either via AMD, CommonJS or the global object
if (typeof define === 'function' && define.amd) {
define(function () {
Expand Down
4 changes: 2 additions & 2 deletions EventEmitter.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "eventEmitter",
"description": "Event based JavaScript for the browser",
"version": "4.2.4",
"version": "4.2.5",
"main": [
"./EventEmitter.js"
],
Expand All @@ -18,5 +18,12 @@
"keywords": [
"events",
"structure"
],
"ignore": [
"docs",
"tests",
"tools",
".gitignore",
"package.json"
]
}
6 changes: 6 additions & 0 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,9 @@ You may also be interested in [the guide](https://github.com/Wolfy87/EventEmitte

* **param** (*) _value_ - The new value to check for when executing listeners.
* **return** (Object) - Current instance of EventEmitter for chaining.

## noConflict

<p>Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.</p>

* **return** (Function) - Non conflicting EventEmitter class.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wolfy87-eventemitter",
"version": "4.2.4",
"version": "4.2.5",
"description": "Event based JavaScript for the browser",
"main": "EventEmitter.js",
"directories": {
Expand Down
29 changes: 29 additions & 0 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@
assert.strictEqual(listeners.bar[0].listener(), 'bar');
assert.strictEqual(listeners.baz[0].listener(), 'baz');
});

test('does not return matched sub-strings', function () {
var check = function () {};

ee.addListener('foo', function () {});
ee.addListener('fooBar', check);

var listeners = ee.getListeners('fooBar');
assert.strictEqual(listeners.length, 1);
assert.strictEqual(listeners[0].listener, check);
});
});

suite('flattenListeners', function () {
Expand Down Expand Up @@ -766,6 +777,24 @@
});
});

suite('noConflict', function () {
var _EventEmitter = EventEmitter;

teardown(function () {
EventEmitter = _EventEmitter;
});

test('reverts the global `EventEmitter` to its previous value', function () {
EventEmitter.noConflict();

assert.isUndefined(EventEmitter);
});

test('returns `EventEmitter`', function () {
assert.strictEqual(EventEmitter.noConflict(), _EventEmitter);
});
});

// Execute the tests.
mocha.run();
}.call(this));

0 comments on commit f7442a1

Please sign in to comment.