New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

eventemitter-ex

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eventemitter-ex - npm Package Compare versions

Comparing version 1.5.0 to 1.6.0

.idea/.name

87

EventEmitterEx.js

@@ -70,3 +70,3 @@ 'use strict';

if (typeof ee.onAllExcept === 'function') {
if (isFunction(ee.onAllExcept)) {
// This is an EventEmitterEx

@@ -113,23 +113,36 @@ except.push(function (/* arguments */) {

this.on('end', function (/* arguments */) {
var result;
try {
var endArgs = arguments;
result = mapArgs.map(function (f) {
var res = f.apply(eex, endArgs);
return Array.isArray(res) ? res : [res];
});
// FIXME: wait for all promises to resolve/reject before emitting end/error
// flatten the array
Promise.all(concat.apply([], result)).then(
function (res) {
res.unshift('end');
eex.emit.apply(eex, res);
},
function (err) {
eex.emit('error', err);
});
} catch (err) {
eex.emit('error', err);
return;
var result = [], firstError, len = mapArgs.length, lenLoop = len;
var endArgs = arguments;
for (var i = 0; i < lenLoop; i++) {
new Promise(invokeFunc.bind(null, mapArgs[i]))
.then(onResolved.bind(null, i), onRejected);
}
function invokeFunc (func, resolve) {
resolve(func.apply(eex, endArgs));
}
function onResolved (idx, value) {
result[idx] = Array.isArray(value) ? value : [value];
maybeFinish();
}
function onRejected (reason) {
if (! isError(firstError)) {
firstError = reason;
}
maybeFinish();
}
function maybeFinish () {
len--;
if (! len) {
if (isError(firstError)) {
eex.emit('error', firstError);
} else {
// flatten the array
eex.emit.apply(eex, concat.apply(['end'], result));
}
}
}
});

@@ -164,7 +177,9 @@

if (err === null) {
if (isError(err)) {
if (! firstError) {
firstError = slice(arguments, 1);
}
result[position] = [];
} else {
result[position] = slice(arguments, 2);
} else {
if (! firstError) firstError = slice(arguments, 1);
result[position] = [];
}

@@ -215,5 +230,7 @@ len--;

function errorListener (position, err) {
function errorListener (position/* arguments */) {
checkUsage(position);
firstError = firstError || err;
if (! firstError) {
firstError = slice(arguments, 1);
}
result[position] = [];

@@ -227,3 +244,4 @@ maybeNext();

if (firstError) {
eex.emit('error', firstError);
firstError.unshift('error');
eex.emit.apply(eex, firstError);
} else {

@@ -259,3 +277,3 @@ // flatten the array

EventEmitterEx.listenerCount = function listenerCount (eex, type) {
return (typeof eex.listenerCountOnAll === 'function' ? eex.listenerCountOnAll(type) : 0) +
return (isFunction(eex.listenerCountOnAll) ? eex.listenerCountOnAll(type) : 0) +
EE.listenerCount(eex, type);

@@ -308,5 +326,14 @@ };

function isFunction (f) {
return typeof f === 'function';
}
function assertIsFunction (f) {
if (typeof f !== 'function')
if (! isFunction(f)) {
throw new TypeError('Argument must be a function. Got ' + typeof f);
}
}
function isError (e) {
return e !== null && typeof e !== 'undefined';
}
{
"name": "eventemitter-ex",
"version": "1.5.0",
"version": "1.6.0",
"description": "EventEmitter extensions",

@@ -9,3 +9,3 @@ "main": "EventEmitterEx.js",

"test": "jshint --exclude-path=.gitignore . && mocha test",
"coveralls": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
"coveralls": "istanbul cover _mocha --report lcovonly && cat ./coverage/lcov.info | coveralls"
},

@@ -12,0 +12,0 @@ "repository": {

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