Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

events-ex

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

events-ex - npm Package Compare versions

Comparing version 0.9.6 to 0.9.7

14

eventable.js

@@ -383,10 +383,10 @@ // Generated by CoffeeScript 1.9.0

}
}
if (aOptions != null) {
if (aOptions.methods instanceof Object) {
injectMethods(aClass.prototype, aOptions.methods);
if (aOptions != null) {
if (aOptions.methods instanceof Object) {
injectMethods(aClass.prototype, aOptions.methods);
}
if (aOptions.classMethods instanceof Object) {
injectMethods(aClass, aOptions.classMethods);
}
}
if (aOptions.classMethods instanceof Object) {
injectMethods(aClass, aOptions.classMethods);
}
}

@@ -393,0 +393,0 @@ return aClass;

{
"name": "events-ex",
"version": "0.9.6",
"version": "0.9.7",
"description": "Browser-friendly enhanced events most compatible with standard node.js, it's powerful eventable ability.",

@@ -38,3 +38,3 @@ "contributors": [

"es5-ext": "~0.10.5",
"util-ex": "^0.2.6"
"util-ex": "^0.2.8"
},

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

@@ -7,20 +7,29 @@ ### events-ex [![Build Status](https://img.shields.io/travis/snowyu/events-ex.js/master.png)](http://travis-ci.org/snowyu/events-ex.js) [![npm](https://img.shields.io/npm/v/events-ex.svg)](https://npmjs.org/package/events-ex) [![downloads](https://img.shields.io/npm/dm/events-ex.svg)](https://npmjs.org/package/events-ex) [![license](https://img.shields.io/npm/l/events-ex.svg)](https://npmjs.org/package/events-ex)

### Difference with event-emitter and events
### Features
+ powerful eventable ability
- domain is not supported yet(TODO)
+ **`broken change`**: The event object bubbling Supports
+ the event object as listener's "this" object.
+ return the result property of event object to emitter.
+ prevent the rest of listener from be excuted if set the stopped property of event object to true
* **`broken change`**: the `emit` return the result of listeners's callback function instead of the successful state.
* **`broken change`**: the `this` object of listeners' callback function is the `Event` Object instead of the emitter object.
* the emitter object is put into the `target` property of the `Event` Object.
+ add the defaultMaxListeners class property to keep compatible.
+ add the setMaxListeners method to keep compatible.
+ add `error`, `newListener` and `removeListener` events to keep compatible.
+ add listeners() method to keep compatible.
+ add listenerCount() class method to keep compatible.
* rewrite the core architecture
* keep most compatible with [node events](nodejs.org/api/events.html) and [event-emitter](https://github.com/medikoo/event-emitter)
+ more powerful event-able ability
* hookable event system
### Differences
* Difference with [node events](nodejs.org/api/events.html)
- domain is not supported yet(TODO)
+ **`broken change`**: The event object bubbling Supports
+ the event object as listener's "this" object.
+ return the result property of event object to emitter.
+ prevent the rest of listener from be excuted if set the stopped property of event object to true
* **`broken change`**: the `emit` return the result of listeners's callback function instead of the successful state.
* **`broken change`**: the `this` object of listeners' callback function is the `Event` Object instead of the emitter object.
* the emitter object is put into the `target` property of the `Event` Object.
* Difference with [event-emitter](https://github.com/medikoo/event-emitter)
+ **`broken change`**: The event object bubbling Supports(see above)
+ add the defaultMaxListeners class property to keep compatible with node events.
+ add the setMaxListeners method to keep compatible with node events.
+ add `error`, `newListener` and `removeListener` events to keep compatible with node events.
+ add listeners() method to keep compatible with node events.
+ add listenerCount() class method to keep compatible with node events.
### Installation

@@ -38,2 +47,3 @@

```coffee
# advanced usage see API topic.
eventable = require('events-ex/eventable')

@@ -97,3 +107,3 @@

```
### Additional utilities
### API

@@ -121,5 +131,8 @@ #### eventable(class[, options]) _(events-ex/eventable)_

exec: -> console.log "my original exec"
class MyClass
# only 'on', 'off', 'emit' added to the class
eventable MyClass, include: ['on', 'off', 'emit']
# add the eventable ability to OtherClass and inject the exec method of OtherClass.
eventable OtherClass, methods:

@@ -126,0 +139,0 @@ exec: ->

@@ -88,2 +88,16 @@ 'use strict';

});
it('should not inject methods twice', function(){
var My = function(){};
var newExec = 0;
var oldExec = 0;
My.prototype.exec = function(){
oldExec++;
};
eventable(My, {methods: {exec: function(){newExec++;this['super']();}}});
eventable(My, {methods: {exec: function(){newExec++;this['super']();}}});
var my = new My;
my.exec();
assert.equal(oldExec, 1, 'should execute the original func once');
assert.equal(newExec, 1, 'should execute the new func once');
});

@@ -90,0 +104,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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