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.8 to 1.0.0

ability.js

106

eventable.js
// Generated by CoffeeScript 1.9.0
(function() {
"use strict";
var create, defineProperty, extend, extendFilter, hasOwnProperty, injectMethods, isArray, isFunction, isNumber, isObject, isUndefined,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
'use strict';
var create, customAbility, defineProperty, getEventableClass, hasOwnProperty, isArray, isFunction, isNumber, isObject, isUndefined;
isFunction = require("util-ex/lib/is/type/function");
customAbility = require('custom-ability');
isObject = require("util-ex/lib/is/type/object");
isFunction = require('util-ex/lib/is/type/function');
isNumber = require("util-ex/lib/is/type/number");
isObject = require('util-ex/lib/is/type/object');
isUndefined = require("util-ex/lib/is/type/undefined");
isNumber = require('util-ex/lib/is/type/number');
isArray = require("util-ex/lib/is/type/array");
isUndefined = require('util-ex/lib/is/type/undefined');
extend = require("util-ex/lib/_extend");
isArray = require('util-ex/lib/is/type/array');
extendFilter = require("util-ex/lib/extend");
defineProperty = require('util-ex/lib/defineProperty');
injectMethods = require("util-ex/lib/injectMethods");
defineProperty = require("util-ex/lib/defineProperty");
hasOwnProperty = Object.prototype.hasOwnProperty;

@@ -29,5 +24,5 @@

module.exports = function(aClass, aOptions) {
var Eventable, filter, vExcludes, vIncludes;
Eventable = (function() {
getEventableClass = function(aClass) {
var Eventable;
return Eventable = (function() {
var Event, methods;

@@ -37,2 +32,6 @@

if (aClass == null) {
aClass = Eventable;
}
defineProperty(Eventable, 'methods', methods = {

@@ -42,7 +41,7 @@ on: function(type, listener) {

if (!isFunction(listener)) {
throw TypeError(listener + " is not a function");
throw TypeError(listener + ' is not a function');
}
if (!this.hasOwnProperty("_events")) {
if (!this.hasOwnProperty('_events')) {
data = create(null);
defineProperty(this, "_events", data);
defineProperty(this, '_events', data);
} else {

@@ -78,3 +77,3 @@ data = this._events;

if (!isFunction(listener)) {
throw TypeError(listener + " is not a function");
throw TypeError(listener + ' is not a function');
}

@@ -146,3 +145,3 @@ fired = false;

if (!er) {
er = new Error('Uncaught, unspecified "error" event.');
er = new Error("Uncaught, unspecified 'error' event.");
}

@@ -156,3 +155,3 @@ er.domainEmitter = this;

} else {
throw Error('Uncaught, unspecified "error" event.');
throw Error("Uncaught, unspecified 'error' event.");
}

@@ -214,4 +213,4 @@ return;

}
if (!this.hasOwnProperty("_maxListeners")) {
defineProperty(this, "_maxListeners", n);
if (!this.hasOwnProperty('_maxListeners')) {
defineProperty(this, '_maxListeners', n);
} else {

@@ -249,5 +248,5 @@ this._maxListeners = n;

if (!isFunction(listener)) {
throw TypeError(listener + " is not a function");
throw TypeError(listener + ' is not a function');
}
if (!this.hasOwnProperty("_events")) {
if (!this.hasOwnProperty('_events')) {
return this;

@@ -263,3 +262,3 @@ }

if (data.removeListener) {
this.emit("removeListener", type, listener);
this.emit('removeListener', type, listener);
}

@@ -287,3 +286,3 @@ } else if (isObject(listeners)) {

if (data.removeListener) {
this.emit("removeListener", type, listener);
this.emit('removeListener', type, listener);
}

@@ -356,51 +355,6 @@ }

})();
if (aClass == null) {
aClass = Eventable;
} else if (!aClass.prototype.emit) {
if ((aOptions == null) || !(aOptions.include || aOptions.exclude)) {
extend(aClass, Eventable);
extend(aClass.prototype, Eventable.prototype);
} else {
vIncludes = aOptions.include;
if (vIncludes) {
if (!isArray(vIncludes)) {
vIncludes = [vIncludes];
}
} else {
vIncludes = [];
}
vIncludes.push('emit');
vExcludes = aOptions.exclude;
if (vExcludes) {
if (!isArray(vExcludes)) {
vExcludes = [vExcludes];
}
} else {
vExcludes = [];
}
filter = function(k) {
var result;
result = vIncludes.length && !vExcludes.length;
if (result) {
result = __indexOf.call(vIncludes, k) >= 0;
} else {
result = !(__indexOf.call(vExcludes, k) >= 0);
}
return result;
};
extendFilter(aClass, Eventable, filter);
extendFilter(aClass.prototype, Eventable.prototype, filter);
}
if (aOptions != null) {
if (aOptions.methods instanceof Object) {
injectMethods(aClass.prototype, aOptions.methods);
}
if (aOptions.classMethods instanceof Object) {
injectMethods(aClass, aOptions.classMethods);
}
}
}
return aClass;
};
module.exports = customAbility(getEventableClass, 'emit', true);
}).call(this);
{
"name": "events-ex",
"version": "0.9.8",
"version": "1.0.0",
"description": "Browser-friendly enhanced events most compatible with standard node.js, it's powerful eventable ability.",

@@ -24,2 +24,3 @@ "contributors": [

"keywords": [
"ability",
"event",

@@ -38,2 +39,3 @@ "events",

"dependencies": {
"custom-ability": "~1.1.1",
"es5-ext": "~0.10.5",

@@ -51,5 +53,8 @@ "util-ex": "^0.2.8"

"pre-commit": {
"run": ["prepublish", "test"]
"run": [
"prepublish",
"test"
]
},
"license": "MIT"
}

@@ -111,6 +111,7 @@ ### 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)

* `options`*(object)*
* `include`*(array|string)*: only these emitter methods will be added to the class
* `exclude`*(array|string)*: theses emitter methods would not be added to the class
* `methods`*(object)*: hooked methods to the class
* `class`: the class to be injected the ability.
* `options` *(object)*: optional options
* `include` *(array|string)*: only these emitter methods will be added to the class
* `exclude` *(array|string)*: theses emitter methods would not be added to the class
* `methods` *(object)*: hooked methods to the class
* key: the method name to hook.

@@ -120,3 +121,3 @@ * value: the new method function

* `this.self` is the original `this` object.
* `classMethods`*(object)*: hooked class methods to the class
* `classMethods` *(object)*: hooked class methods to the class

@@ -123,0 +124,0 @@ **Note**: the `emit` is always added to the class.

@@ -71,2 +71,3 @@ 'use strict';

'removeAllListeners',
'emit',
'once',

@@ -73,0 +74,0 @@ 'on',

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