You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

event-emitter-grouped

Package Overview
Dependencies
Maintainers
2
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

event-emitter-grouped - npm Package Compare versions

Comparing version

to
2.6.0

60

es2015/index.js
'use strict';
// Import
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();

@@ -11,14 +13,23 @@

// Import
var _require = require('events'),
EventEmitter = _require.EventEmitter;
var _require = require('events');
var _require2 = require('taskgroup'),
TaskGroup = _require2.TaskGroup;
var EventEmitter = _require.EventEmitter;
var ambi = require('ambi');
var unbounded = require('unbounded');
var _require2 = require('taskgroup');
// Fetch raw listeners across versions
// Node v10 defines this on the EventEmitter prototype
// Node v8 omits this
// Node version below 8 don't need this, as their `listeners` function is the same as this
// However, due to the inconsistencies, this is what we have
function rawListeners(eventName) {
var events = this._events[eventName];
if (events == null) return [];
if (typeof events === 'function') return [events];
return events;
}
var TaskGroup = _require2.TaskGroup;
var ambi = require('ambi');
/**

@@ -44,3 +55,3 @@ Events EventEmitter to allow you to execute events in serial or parallel.

return _possibleConstructorReturn(this, Object.getPrototypeOf(EventEmitterGrouped).apply(this, arguments));
return _possibleConstructorReturn(this, (EventEmitterGrouped.__proto__ || Object.getPrototypeOf(EventEmitterGrouped)).apply(this, arguments));
}

@@ -73,6 +84,3 @@

// Convert the listeners into objects that we can use
var listenerObjects = this.listeners(eventName).slice().map(function (listener) {
// Prepare
var listenerObject = {};
var listenerObjects = (this.rawListeners || rawListeners).call(this, eventName).slice().map(function (listener) {
// The `once` method will actually wrap around the original listener, which isn't what we want for the introspection

@@ -82,17 +90,11 @@ // So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect

// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544
if (listener.listener) {
// this is a `once` thing
listenerObject.actual = listener.listener;
listenerObject.fire = [listener.bind(me), listener.listener];
} else {
listenerObject.actual = listener;
listenerObject.fire = listener.bind(me);
}
var method = listener.listener ? unbounded.binder.call(unbounded.define(listener, listener.listener), me) : unbounded.binder.call(listener, me);
var length = method.unbounded.length;
var priority = method.unbounded.priority || 0;
var name = method.unbounded.name;
var description = 'Listener for [' + eventName + '] with name [' + name + '], length [' + length + '], priority [' + priority + ']';
var result = { method: method, length: length, priority: priority, name: name, description: description
// Defaults
listenerObject.priority = listenerObject.actual.priority || 0;
listenerObject.name = listenerObject.name || 'Untitled listener for [' + eventName + '] with priority [' + listenerObject.priority + ']';
// Return the new listenerObject
return listenerObject;
// Return
};return result;
});

@@ -108,5 +110,5 @@

// Bind to the task
tasks.addTask(listenerObject.name, function (complete) {
tasks.addTask(listenerObject.description, function (complete) {
// Fire the listener, treating the callback as optional
ambi.apply(undefined, [listenerObject.fire].concat(args, [complete]));
ambi.apply(undefined, [listenerObject.method].concat(args, [complete]));
});

@@ -113,0 +115,0 @@ });

# History
## v2.6.0 2018 July 13
- More detailed and accurate task names for listeners
- Better listener argument length detection thanks to [bounded](https://github.com/bevry/bounded)
- Better listener argument length detection on `once` events on Node v10 and Node v8
- Updated base files using [boundation](https://github.com/bevry/boundation)
- Updated dependencies
## v2.5.0 2016 June 4
- Updated dependencies
- Converted from CoffeeScript to ESNext
- Removed `attach` and `inheritInto`, they were not used by anybody
- Export EventEmitterGrouped directly, alias as static property for backwards compatibility
- Updated dependencies

@@ -9,0 +16,0 @@ ## v2.4.3 2014 June 24

@@ -1,3 +0,3 @@

// 2016 March 8
// https://github.com/bevry/editions
'use strict'
module.exports = require('editions').requirePackage(__dirname, require)

@@ -8,3 +8,3 @@ <!-- LICENSEFILE/ -->

<ul><li>Copyright &copy; 2013+ <a href="http://bevry.me">Bevry Pty Ltd</a></li>
<li>Copyright &copy; 2011-2012 <a href="https://balupton.com">Benjamin Lupton</a></li></ul>
<li>Copyright &copy; 2011-2012 <a href="http://balupton.com">Benjamin Lupton</a></li></ul>

@@ -11,0 +11,0 @@ and licensed under:

{
"title": "Event Emitter Grouped",
"name": "event-emitter-grouped",
"version": "2.5.0",
"version": "2.6.0",
"description": "Emit events in serial or parallel with support for synchronous and asynchronous listeners",
"homepage": "https://github.com/bevry/event-emitter-grouped",
"homepage": "ssh://git@github.com/bevry/event-emitter-grouped",
"license": "MIT",
"keywords": [
"event",
"events",
"emitter",
"eventemitter",
"async",
"sync",
"parallel",
"serial",
"flow",
"completion",
"callback"
],
"badges": {

@@ -16,13 +29,14 @@ "list": [

"---",
"slackin",
"patreon",
"gratipay",
"opencollective",
"flattr",
"paypal",
"bitcoin",
"wishlist"
"wishlist",
"---",
"slackin"
],
"config": {
"patreonUsername": "bevry",
"gratipayUsername": "bevry",
"opencollectiveUsername": "bevry",
"flattrUsername": "balupton",

@@ -35,32 +49,19 @@ "paypalURL": "https://bevry.me/paypal",

},
"keywords": [
"event",
"events",
"emitter",
"eventemitter",
"async",
"sync",
"parallel",
"serial",
"flow",
"completion",
"callback"
],
"author": "2013+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me), 2011-2012 Benjamin Lupton <b@lupton.cc> (https://balupton.com)",
"author": "2013+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me), 2011-2012 Benjamin Lupton <b@lupton.cc> (http://balupton.com)",
"maintainers": [
"Benjamin Lupton <b@lupton.cc> (https://balupton.com)"
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)"
],
"contributors": [
"Benjamin Lupton <b@lupton.cc> (https://balupton.com)",
"Benjamin Lupton <b@lupton.cc> (http://balupton.com)",
"Sean Fridman <mail@seanfridman.com> (http://seanfridman.com)"
],
"bugs": {
"url": "https://github.com/bevry/event-emitter-grouped/issues"
"url": "ssh://git@github.com/bevry/event-emitter-grouped/issues"
},
"repository": {
"type": "git",
"url": "http://github.com/bevry/event-emitter-grouped.git"
"url": "ssh://git@github.com/bevry/event-emitter-grouped.git"
},
"engines": {
"node": ">=0.12"
"node": ">=0.8"
},

@@ -70,3 +71,3 @@ "editions": [

"description": "Source + ESNext + Require",
"entry": "source/index.js",
"entry": "index.js",
"directory": "source",

@@ -88,3 +89,3 @@ "syntaxes": [

"description": "Babel Compiled + ES2015 + Require",
"entry": "es2015/index.js",
"entry": "index.js",
"directory": "es2015",

@@ -100,35 +101,41 @@ "syntaxes": [

"browser": "es2015/index.js",
"scripts": {
"setup": "npm install",
"clean": "rm -Rf ./docs ./es2015",
"compile": "npm run compile:es2015",
"compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015",
"meta": "npm run meta:docs && npm run meta:projectz",
"meta:docs": "documentation build -f html -o ./docs -g --shallow ./source/**.js",
"meta:projectz": "projectz compile",
"prepare": "npm run compile && npm run test && npm run meta",
"release": "npm run prepare && npm run release:publish && npm run release:tag && npm run release:push",
"release:publish": "npm publish",
"release:tag": "git tag v$npm_package_version -a",
"release:push": "git push origin master && git push origin --tags",
"pretest": "npm run test:eslint",
"test:eslint": "eslint ./source",
"test": "node --harmony -e \"require('editions').requirePackage(process.cwd(), require, 'test.js')\""
},
"dependencies": {
"ambi": "~2.5.0",
"editions": "^1.1.1",
"taskgroup": "^5.0.0"
"ambi": "^3.0.0",
"editions": "^1.3.4",
"taskgroup": "^5.0.0",
"unbounded": "^1.1.0"
},
"devDependencies": {
"assert-helpers": "^4.4.0",
"babel-cli": "^6.9.0",
"babel-preset-es2015": "^6.9.0",
"documentation": "^4.0.0-beta5",
"eslint": "^2.11.1",
"eslint-plugin-babel": "^3.2.0",
"joe": "^1.6.0",
"joe-reporter-console": "^1.2.1",
"projectz": "^1.1.5"
"assert-helpers": "^4.5.1",
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"documentation": "^8.0.0",
"eslint": "^5.1.0",
"eslint-plugin-babel": "^5.1.0",
"joe": "^2.0.2",
"joe-reporter-console": "^2.0.1",
"projectz": "^1.4.0",
"surge": "^0.20.1"
},
"scripts": {
"our:setup": "npm run our:setup:npm",
"our:setup:npm": "npm install",
"our:clean": "rm -Rf ./docs ./es2015 ./es5 ./out",
"our:compile": "npm run our:compile:es2015",
"our:compile:es2015": "babel ./source --out-dir ./es2015 --presets es2015",
"our:meta": "npm run our:meta:docs && npm run our:meta:projectz",
"our:meta:docs": "documentation build -f html -o ./docs -g --shallow ./source/**.js",
"our:meta:projectz": "projectz compile",
"our:verify": "npm run our:verify:eslint",
"our:verify:eslint": "eslint --fix ./source",
"our:deploy": "echo no need for this project",
"our:test": "npm run our:verify && npm test",
"our:release": "npm run our:release:prepare && npm run our:release:check-changelog && npm run our:release:check-dirty && npm run our:release:tag && npm run our:release:push",
"our:release:prepare": "npm run our:clean && npm run our:compile && npm run our:test && npm run our:meta",
"our:release:check-changelog": "cat ./HISTORY.md | grep v$npm_package_version || (echo add a changelog entry for v$npm_package_version && exit -1)",
"our:release:check-dirty": "git diff --exit-code",
"our:release:tag": "export MESSAGE=$(cat ./HISTORY.md | sed -n \"/## v$npm_package_version/,/##/p\" | sed 's/## //' | awk 'NR>1{print buf}{buf = $0}') && test \"$MESSAGE\" || (echo 'proper changelog entry not found' && exit -1) && git tag v$npm_package_version -am \"$MESSAGE\"",
"our:release:push": "git push origin master && git push origin --tags",
"test": "node --harmony ./test.js --joe-reporter=console"
}
}

@@ -16,5 +16,4 @@ <!-- TITLE/ -->

<br class="badge-separator" />
<span class="badge-slackin"><a href="https://slack.bevry.me" title="Join this project's slack community"><img src="https://slack.bevry.me/badge.svg" alt="Slack community badge" /></a></span>
<span class="badge-patreon"><a href="http://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>

@@ -24,2 +23,4 @@ <span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>

<span class="badge-wishlist"><a href="https://bevry.me/wishlist" title="Buy an item on our wishlist for us"><img src="https://img.shields.io/badge/wishlist-donate-yellow.svg" alt="Wishlist browse button" /></a></span>
<br class="badge-separator" />
<span class="badge-slackin"><a href="https://slack.bevry.me" title="Join this project's slack community"><img src="https://slack.bevry.me/badge.svg" alt="Slack community badge" /></a></span>

@@ -47,3 +48,3 @@ <!-- /BADGES -->

<li>Module: <code>require('event-emitter-grouped')</code></li>
<li>CDN URL: <code>//wzrd.in/bundle/event-emitter-grouped@2.5.0</code></li></ul>
<li>CDN URL: <code>//wzrd.in/bundle/event-emitter-grouped@2.6.0</code></li></ul>

@@ -154,3 +155,3 @@ <a href="http://enderjs.com" title="Ender is a full featured package manager for your browser"><h3>Ender</h3></a><ul>

<ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/event-emitter-grouped/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/event-emitter-grouped">view contributions</a></li></ul>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/event-emitter-grouped/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/event-emitter-grouped">view contributions</a></li></ul>

@@ -161,4 +162,4 @@ <h3>Sponsors</h3>

<span class="badge-patreon"><a href="http://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-gratipay"><a href="https://www.gratipay.com/bevry" title="Donate weekly to this project using Gratipay"><img src="https://img.shields.io/badge/gratipay-donate-yellow.svg" alt="Gratipay donate button" /></a></span>
<span class="badge-patreon"><a href="https://patreon.com/bevry" title="Donate to this project using Patreon"><img src="https://img.shields.io/badge/patreon-donate-yellow.svg" alt="Patreon donate button" /></a></span>
<span class="badge-opencollective"><a href="https://opencollective.com/bevry" title="Donate to this project using Open Collective"><img src="https://img.shields.io/badge/open%20collective-donate-yellow.svg" alt="Open Collective donate button" /></a></span>
<span class="badge-flattr"><a href="https://flattr.com/profile/balupton" title="Donate to this project using Flattr"><img src="https://img.shields.io/badge/flattr-donate-yellow.svg" alt="Flattr donate button" /></a></span>

@@ -173,3 +174,3 @@ <span class="badge-paypal"><a href="https://bevry.me/paypal" title="Donate to this project using Paypal"><img src="https://img.shields.io/badge/paypal-donate-yellow.svg" alt="PayPal donate button" /></a></span>

<ul><li><a href="https://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/event-emitter-grouped/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/event-emitter-grouped">view contributions</a></li>
<ul><li><a href="http://balupton.com">Benjamin Lupton</a> — <a href="https://github.com/bevry/event-emitter-grouped/commits?author=balupton" title="View the GitHub contributions of Benjamin Lupton on repository bevry/event-emitter-grouped">view contributions</a></li>
<li><a href="http://seanfridman.com">Sean Fridman</a> — <a href="https://github.com/bevry/event-emitter-grouped/commits?author=sfrdmn" title="View the GitHub contributions of Sean Fridman on repository bevry/event-emitter-grouped">view contributions</a></li></ul>

@@ -189,3 +190,3 @@

<ul><li>Copyright &copy; 2013+ <a href="http://bevry.me">Bevry Pty Ltd</a></li>
<li>Copyright &copy; 2011-2012 <a href="https://balupton.com">Benjamin Lupton</a></li></ul>
<li>Copyright &copy; 2011-2012 <a href="http://balupton.com">Benjamin Lupton</a></li></ul>

@@ -192,0 +193,0 @@ and licensed under:

@@ -0,6 +1,21 @@

'use strict'
// Import
const {EventEmitter} = require('events')
const {TaskGroup} = require('taskgroup')
const { EventEmitter } = require('events')
const { TaskGroup } = require('taskgroup')
const ambi = require('ambi')
const unbounded = require('unbounded')
// Fetch raw listeners across versions
// Node v10 defines this on the EventEmitter prototype
// Node v8 omits this
// Node version below 8 don't need this, as their `listeners` function is the same as this
// However, due to the inconsistencies, this is what we have
function rawListeners (eventName) {
const events = this._events[eventName]
if (events == null) return []
if (typeof events === 'function') return [events]
return events
}
/**

@@ -38,6 +53,3 @@ Events EventEmitter to allow you to execute events in serial or parallel.

// Convert the listeners into objects that we can use
const listenerObjects = this.listeners(eventName).slice().map((listener) => {
// Prepare
const listenerObject = {}
const listenerObjects = (this.rawListeners || rawListeners).call(this, eventName).slice().map((listener) => {
// The `once` method will actually wrap around the original listener, which isn't what we want for the introspection

@@ -47,17 +59,11 @@ // So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect

// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544
if ( listener.listener ) { // this is a `once` thing
listenerObject.actual = listener.listener
listenerObject.fire = [listener.bind(me), listener.listener]
}
else {
listenerObject.actual = listener
listenerObject.fire = listener.bind(me)
}
const method = listener.listener ? unbounded.binder.call(unbounded.define(listener, listener.listener), me) : unbounded.binder.call(listener, me)
const length = method.unbounded.length
const priority = method.unbounded.priority || 0
const name = method.unbounded.name
const description = `Listener for [${eventName}] with name [${name}], length [${length}], priority [${priority}]`
const result = { method, length, priority, name, description }
// Defaults
listenerObject.priority = listenerObject.actual.priority || 0
listenerObject.name = listenerObject.name || `Untitled listener for [${eventName}] with priority [${listenerObject.priority}]`
// Return the new listenerObject
return listenerObject
// Return
return result
})

@@ -71,5 +77,5 @@

// Bind to the task
tasks.addTask(listenerObject.name, function (complete) {
tasks.addTask(listenerObject.description, function (complete) {
// Fire the listener, treating the callback as optional
ambi(listenerObject.fire, ...args, complete)
ambi(listenerObject.method, ...args, complete)
})

@@ -107,3 +113,3 @@ })

emitParallel (...args) {
return this.getListenerGroup(...args).setConfig({concurrency: 0}).run()
return this.getListenerGroup(...args).setConfig({ concurrency: 0 }).run()
}

@@ -110,0 +116,0 @@ }