Socket
Socket
Sign inDemoInstall

wolfy87-eventemitter

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wolfy87-eventemitter - npm Package Compare versions

Comparing version 4.2.11 to 4.3.0

UNLICENSE

9

bower.json
{
"name": "eventEmitter",
"description": "Event based JavaScript for the browser",
"version": "4.2.11",
"version": "4.3.0",
"main": [

@@ -12,8 +12,3 @@ "./EventEmitter.js"

},
"licenses": [
{
"type": "Unlicense",
"url": "http://unlicense.org/"
}
],
"license": "Unlicense",
"keywords": [

@@ -20,0 +15,0 @@ "events",

{
"name": "eventEmitter",
"repo": "Wolfy87/EventEmitter",
"repo": "Olical/EventEmitter",
"description": "Event based JavaScript for the browser.",
"version": "4.2.11",
"version": "4.3.0",
"scripts": ["EventEmitter.js"],

@@ -7,0 +7,0 @@ "main": "EventEmitter.js",

@@ -5,3 +5,3 @@ # API

You may also be interested in [the guide](https://github.com/Wolfy87/EventEmitter/blob/master/docs/guide.md) which highlights some key features of EventEmitter and how to use them. It is a broad overview of the script whereas this is concise information about each method in the API.
You may also be interested in [the guide](https://github.com/Olical/EventEmitter/blob/master/docs/guide.md) which highlights some key features of EventEmitter and how to use them. It is a broad overview of the script whereas this is concise information about each method in the API.

@@ -8,0 +8,0 @@ ## EventEmitter

# Guide
This guide should get you going with EventEmitter. Once finished you may wish to learn more about the script and use methods that are not shown here. At that point you should either browse [the API documentation](https://github.com/Wolfy87/EventEmitter/blob/master/docs/api.md) or have a look around [the source](https://github.com/Wolfy87/EventEmitter/blob/master/EventEmitter.js).
This guide should get you going with EventEmitter. Once finished you may wish to learn more about the script and use methods that are not shown here. At that point you should either browse [the API documentation](https://github.com/Olical/EventEmitter/blob/master/docs/api.md) or have a look around [the source](https://github.com/Olical/EventEmitter/blob/master/EventEmitter.js).

@@ -10,3 +10,3 @@ ## Getting a copy of the script

```bash
git submodule add git://github.com/Wolfy87/EventEmitter.git assets/js/EventEmitter
git submodule add git://github.com/Olical/EventEmitter.git assets/js/EventEmitter
```

@@ -18,3 +18,3 @@

You can get pre-built versions of EventEmitter from [the downloads page](https://github.com/Wolfy87/EventEmitter/downloads). I would recommend using the latest version. It's the latest for a reason.
You can get pre-built versions of EventEmitter from [the downloads page](https://github.com/Olical/EventEmitter/downloads). I would recommend using the latest version. It's the latest for a reason.

@@ -87,7 +87,7 @@ ### Installing the component with Bower

If you do not want to use a huge framework like that then you might want to use this script I wrote, [Heir](https://github.com/Wolfy87/Heir). It just makes prototypical inheritance nice and easy. So here is how you would inherit EventEmitter's methods with Heir.
If you do not want to use a huge framework like that then you might want to use this script I wrote, [Heir](https://github.com/Olical/Heir). It just makes prototypical inheritance nice and easy. So here is how you would inherit EventEmitter's methods with Heir.
```javascript
function Player(){}
Player.inherit(EventEmitter);
heir.inherit(Player, EventEmitter);
```

@@ -280,3 +280,3 @@

[Hebo](https://github.com/Hebo), from GitHub, [contributed three aliases](https://github.com/Wolfy87/EventEmitter/pull/35#issuecomment-9920932) to add, remove and emit. The aliases can be found in the [API documentation](https://github.com/Wolfy87/EventEmitter/blob/master/docs/api.md) but here is the mapping.
[Hebo](https://github.com/Hebo), from GitHub, [contributed three aliases](https://github.com/Olical/EventEmitter/pull/35#issuecomment-9920932) to add, remove and emit. The aliases can be found in the [API documentation](https://github.com/Olical/EventEmitter/blob/master/docs/api.md) but here is the mapping.

@@ -283,0 +283,0 @@ * `on` - `addListener`

@@ -361,3 +361,4 @@ /*!

proto.emitEvent = function emitEvent(evt, args) {
var listeners = this.getListenersAsObject(evt);
var listenersMap = this.getListenersAsObject(evt);
var listeners;
var listener;

@@ -368,5 +369,6 @@ var i;

for (key in listeners) {
if (listeners.hasOwnProperty(key)) {
i = listeners[key].length;
for (key in listenersMap) {
if (listenersMap.hasOwnProperty(key)) {
listeners = listenersMap[key].slice(0);
i = listeners.length;

@@ -376,3 +378,3 @@ while (i--) {

// The function is executed either with a basic call or an apply if there is an args array
listener = listeners[key][i];
listener = listeners[i];

@@ -379,0 +381,0 @@ if (listener.once === true) {

@@ -7,2 +7,2 @@ /*!

*/
(function(){"use strict";function t(){}function i(t,n){for(var e=t.length;e--;)if(t[e].listener===n)return e;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var e=t.prototype,r=this,s=r.EventEmitter;e.getListeners=function(n){var r,e,t=this._getEvents();if(n instanceof RegExp){r={};for(e in t)t.hasOwnProperty(e)&&n.test(e)&&(r[e]=t[e])}else r=t[n]||(t[n]=[]);return r},e.flattenListeners=function(t){var e,n=[];for(e=0;e<t.length;e+=1)n.push(t[e].listener);return n},e.getListenersAsObject=function(n){var e,t=this.getListeners(n);return t instanceof Array&&(e={},e[n]=t),e||t},e.addListener=function(r,e){var t,n=this.getListenersAsObject(r),s="object"==typeof e;for(t in n)n.hasOwnProperty(t)&&-1===i(n[t],e)&&n[t].push(s?e:{listener:e,once:!1});return this},e.on=n("addListener"),e.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},e.once=n("addOnceListener"),e.defineEvent=function(e){return this.getListeners(e),this},e.defineEvents=function(t){for(var e=0;e<t.length;e+=1)this.defineEvent(t[e]);return this},e.removeListener=function(r,s){var n,e,t=this.getListenersAsObject(r);for(e in t)t.hasOwnProperty(e)&&(n=i(t[e],s),-1!==n&&t[e].splice(n,1));return this},e.off=n("removeListener"),e.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},e.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},e.manipulateListeners=function(r,t,i){var e,n,s=r?this.removeListener:this.addListener,o=r?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(e=i.length;e--;)s.call(this,t,i[e]);else for(e in t)t.hasOwnProperty(e)&&(n=t[e])&&("function"==typeof n?s.call(this,e,n):o.call(this,e,n));return this},e.removeEvent=function(e){var t,r=typeof e,n=this._getEvents();if("string"===r)delete n[e];else if(e instanceof RegExp)for(t in n)n.hasOwnProperty(t)&&e.test(t)&&delete n[t];else delete this._events;return this},e.removeAllListeners=n("removeEvent"),e.emitEvent=function(r,o){var e,i,t,s,n=this.getListenersAsObject(r);for(t in n)if(n.hasOwnProperty(t))for(i=n[t].length;i--;)e=n[t][i],e.once===!0&&this.removeListener(r,e.listener),s=e.listener.apply(this,o||[]),s===this._getOnceReturnValue()&&this.removeListener(r,e.listener);return this},e.trigger=n("emitEvent"),e.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},e.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},e._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},e._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return r.EventEmitter=s,t},"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:r.EventEmitter=t}).call(this);
(function(){"use strict";function t(){}function i(t,n){for(var e=t.length;e--;)if(t[e].listener===n)return e;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var e=t.prototype,r=this,s=r.EventEmitter;e.getListeners=function(n){var r,e,t=this._getEvents();if(n instanceof RegExp){r={};for(e in t)t.hasOwnProperty(e)&&n.test(e)&&(r[e]=t[e])}else r=t[n]||(t[n]=[]);return r},e.flattenListeners=function(t){var e,n=[];for(e=0;e<t.length;e+=1)n.push(t[e].listener);return n},e.getListenersAsObject=function(n){var e,t=this.getListeners(n);return t instanceof Array&&(e={},e[n]=t),e||t},e.addListener=function(r,e){var t,n=this.getListenersAsObject(r),s="object"==typeof e;for(t in n)n.hasOwnProperty(t)&&-1===i(n[t],e)&&n[t].push(s?e:{listener:e,once:!1});return this},e.on=n("addListener"),e.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},e.once=n("addOnceListener"),e.defineEvent=function(e){return this.getListeners(e),this},e.defineEvents=function(t){for(var e=0;e<t.length;e+=1)this.defineEvent(t[e]);return this},e.removeListener=function(r,s){var n,e,t=this.getListenersAsObject(r);for(e in t)t.hasOwnProperty(e)&&(n=i(t[e],s),-1!==n&&t[e].splice(n,1));return this},e.off=n("removeListener"),e.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},e.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},e.manipulateListeners=function(r,t,i){var e,n,s=r?this.removeListener:this.addListener,o=r?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(e=i.length;e--;)s.call(this,t,i[e]);else for(e in t)t.hasOwnProperty(e)&&(n=t[e])&&("function"==typeof n?s.call(this,e,n):o.call(this,e,n));return this},e.removeEvent=function(e){var t,r=typeof e,n=this._getEvents();if("string"===r)delete n[e];else if(e instanceof RegExp)for(t in n)n.hasOwnProperty(t)&&e.test(t)&&delete n[t];else delete this._events;return this},e.removeAllListeners=n("removeEvent"),e.emitEvent=function(t,u){var n,e,r,i,o,s=this.getListenersAsObject(t);for(i in s)if(s.hasOwnProperty(i))for(n=s[i].slice(0),r=n.length;r--;)e=n[r],e.once===!0&&this.removeListener(t,e.listener),o=e.listener.apply(this,u||[]),o===this._getOnceReturnValue()&&this.removeListener(t,e.listener);return this},e.trigger=n("emitEvent"),e.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},e.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},e._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},e._getEvents=function(){return this._events||(this._events={})},t.noConflict=function(){return r.EventEmitter=s,t},"function"==typeof define&&define.amd?define(function(){return t}):"object"==typeof module&&module.exports?module.exports=t:r.EventEmitter=t}).call(this);
{
"name": "wolfy87-eventemitter",
"version": "4.2.11",
"version": "4.3.0",
"description": "Event based JavaScript for the browser",

@@ -12,3 +12,3 @@ "main": "EventEmitter.js",

"type": "git",
"url": "git://github.com/Wolfy87/EventEmitter.git"
"url": "git://github.com/Olical/EventEmitter.git"
},

@@ -29,3 +29,3 @@ "keywords": [

"bugs": {
"url": "https://github.com/Wolfy87/EventEmitter/issues"
"url": "https://github.com/Olical/EventEmitter/issues"
},

@@ -32,0 +32,0 @@ "devDependencies": {

@@ -47,6 +47,6 @@ # EventEmitter [![Gitter](https://badges.gitter.im/Join Chat.svg)][gitter]

# Full repository
git clone git://github.com/Wolfy87/EventEmitter.git
git clone git://github.com/Olical/EventEmitter.git
# Or submodule
git submodule add git://github.com/Wolfy87/EventEmitter.git assets/js/EventEmitter
git submodule add git://github.com/Olical/EventEmitter.git assets/js/EventEmitter
```

@@ -59,3 +59,3 @@

* [Bower][] (eventEmitter)
* [Component][] (Wolfy87/EventEmitter)
* [Component][] (Olical/EventEmitter)

@@ -73,3 +73,3 @@ ## Unlicense

[guide]: https://github.com/Wolfy87/EventEmitter/blob/master/docs/guide.md
[api]: https://github.com/Wolfy87/EventEmitter/blob/master/docs/api.md
[api]: https://github.com/Olical/EventEmitter/blob/master/docs/api.md
[simple]: http://jsfiddle.net/Wolfy87/qXQu9/

@@ -82,8 +82,8 @@ [regexp dom caster]: http://jsfiddle.net/Wolfy87/JqRvS/

[chai]: http://chaijs.com/
[issues]: https://github.com/Wolfy87/EventEmitter/issues
[example]: https://github.com/Wolfy87/EventEmitter/pull/46
[issues]: https://github.com/Olical/EventEmitter/issues
[example]: https://github.com/Olical/EventEmitter/pull/46
[nathggns]: https://github.com/nathggns
[http-server]: https://www.npmjs.org/package/http-server
[node.js]: http://nodejs.org/
[gitter]: https://gitter.im/Wolfy87/EventEmitter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[gitter]: https://gitter.im/Olical/EventEmitter?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge
[unlicense]: http://unlicense.org/

@@ -469,2 +469,19 @@ (function () {

test('can remove another listener from within a listener', function() {
var check = [];
var toRemove = function() { check.push('1'); };
ee.addListener('baz', toRemove);
ee.addListener('baz', function() {
check.push(2);
ee.removeListener('baz', toRemove);
});
ee.addListener('baz', function() { check.push(3); });
ee.emitEvent('baz');
ee.emitEvent('baz');
assert.strictEqual(flattenCheck(check), '1,2,2,3,3');
});
test('executes multiple listeners and removes those that return true', function() {

@@ -471,0 +488,0 @@ var check = [];

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc