event-emitter-grouped
Advanced tools
Comparing version 2.7.1 to 2.8.0-next.1573612981.4820c69336cc55c8a917d7950af4a4c62328a4c0
@@ -1,13 +0,21 @@ | ||
'use strict'; | ||
'use strict'; // Import | ||
// Import | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
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; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
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); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var _require = require('events'), | ||
@@ -19,5 +27,3 @@ EventEmitter = _require.EventEmitter; | ||
var unbounded = require('unbounded'); | ||
// Fetch raw listeners across versions | ||
var unbounded = require('unbounded'); // Fetch raw listeners across versions | ||
// Node v10 defines this on the EventEmitter prototype | ||
@@ -27,9 +33,10 @@ // Node v8 omits 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 events = this._events[eventName]; | ||
if (events == null) return []; | ||
if (typeof events === 'function') return [events]; | ||
return events; | ||
} | ||
/** | ||
@@ -49,115 +56,118 @@ Events EventEmitter to allow you to execute events in serial or parallel. | ||
var EventEmitterGrouped = function (_EventEmitter) { | ||
_inherits(EventEmitterGrouped, _EventEmitter); | ||
function EventEmitterGrouped() { | ||
_classCallCheck(this, EventEmitterGrouped); | ||
var EventEmitterGrouped = | ||
/*#__PURE__*/ | ||
function (_EventEmitter) { | ||
_inherits(EventEmitterGrouped, _EventEmitter); | ||
return _possibleConstructorReturn(this, (EventEmitterGrouped.__proto__ || Object.getPrototypeOf(EventEmitterGrouped)).apply(this, arguments)); | ||
} | ||
function EventEmitterGrouped() { | ||
_classCallCheck(this, EventEmitterGrouped); | ||
_createClass(EventEmitterGrouped, [{ | ||
key: 'getListenerGroup', | ||
return _possibleConstructorReturn(this, _getPrototypeOf(EventEmitterGrouped).apply(this, arguments)); | ||
} | ||
_createClass(EventEmitterGrouped, [{ | ||
key: "getListenerGroup", | ||
/** | ||
Get a TaskGroup for a particular event. | ||
For each listener, treat them as Tasks within a TaskGroup, and return the TaskGroup. | ||
@param {string} eventName | ||
@param {...*} args - the arguments to forward to each task, with the last one being a completion callback with signature `error, results` | ||
@returns {TaskGroup} | ||
@access public | ||
*/ | ||
value: function getListenerGroup(eventName) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
/** | ||
Get a TaskGroup for a particular event. | ||
For each listener, treat them as Tasks within a TaskGroup, and return the TaskGroup. | ||
@param {string} eventName | ||
@param {...*} args - the arguments to forward to each task, with the last one being a completion callback with signature `error, results` | ||
@returns {TaskGroup} | ||
@access public | ||
*/ | ||
value: function getListenerGroup(eventName) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
// Get listeners | ||
var next = args.pop(); | ||
var me = this; | ||
// Get listeners | ||
var next = args.pop(); | ||
var me = this; // Prepare tasks | ||
// Prepare tasks | ||
var tasks = new TaskGroup('EventEmitterGrouped for ' + eventName).done(next); | ||
var tasks = new TaskGroup("EventEmitterGrouped for ".concat(eventName)).done(next); // Convert the listeners into objects that we can use | ||
// Convert the listeners into objects that we can use | ||
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 | ||
// So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect | ||
// https://github.com/bevry/docpad/issues/462 | ||
// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544 | ||
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 | ||
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 | ||
// So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect | ||
// https://github.com/bevry/docpad/issues/462 | ||
// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544 | ||
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 [".concat(eventName, "] with name [").concat(name, "], length [").concat(length, "], priority [").concat(priority, "]"); | ||
var result = { | ||
method: method, | ||
length: length, | ||
priority: priority, | ||
name: name, | ||
description: description | ||
}; // Return | ||
// Return | ||
};return result; | ||
}); | ||
return result; | ||
}); // Sort the listeners by highest priority first | ||
// Sort the listeners by highest priority first | ||
listenerObjects.sort(function (a, b) { | ||
return b.priority - a.priority; | ||
}); | ||
listenerObjects.sort(function (a, b) { | ||
return b.priority - a.priority; | ||
}); // Add the tasks for the listeners | ||
// Add the tasks for the listeners | ||
listenerObjects.forEach(function (_ref) { | ||
var description = _ref.description, | ||
method = _ref.method; | ||
listenerObjects.forEach(function (_ref) { | ||
var description = _ref.description, | ||
method = _ref.method; | ||
// Bind to the task | ||
tasks.addTask(description, { | ||
method: method, | ||
args: args, | ||
ambi: true | ||
}); | ||
}); // Return | ||
// Bind to the task | ||
tasks.addTask(description, { method: method, args: args, ambi: true }); | ||
}); | ||
return tasks; | ||
} | ||
/** | ||
Refer to EventEmitter#removeListener | ||
https://nodejs.org/dist/latest/docs/api/events.html#events_emitter_removelistener_eventname_listener | ||
@returns {*} whatever removeListener returns | ||
@access public | ||
*/ | ||
// Return | ||
return tasks; | ||
} | ||
}, { | ||
key: "off", | ||
value: function off() { | ||
return this.removeListener.apply(this, arguments); | ||
} | ||
/** | ||
Runs the listener group for the event in serial mode (one at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
/** | ||
Refer to EventEmitter#removeListener | ||
https://nodejs.org/dist/latest/docs/api/events.html#events_emitter_removelistener_eventname_listener | ||
@returns {*} whatever removeListener returns | ||
@access public | ||
*/ | ||
}, { | ||
key: "emitSerial", | ||
value: function emitSerial() { | ||
return this.getListenerGroup.apply(this, arguments).run(); | ||
} | ||
/** | ||
Runs the listener group for the event in parallel mode (multiple at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
}, { | ||
key: 'off', | ||
value: function off() { | ||
return this.removeListener.apply(this, arguments); | ||
} | ||
}, { | ||
key: "emitParallel", | ||
value: function emitParallel() { | ||
return this.getListenerGroup.apply(this, arguments).setConfig({ | ||
concurrency: 0 | ||
}).run(); | ||
} | ||
}]); | ||
/** | ||
Runs the listener group for the event in serial mode (one at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
return EventEmitterGrouped; | ||
}(EventEmitter); // Export | ||
}, { | ||
key: 'emitSerial', | ||
value: function emitSerial() { | ||
return this.getListenerGroup.apply(this, arguments).run(); | ||
} | ||
/** | ||
Runs the listener group for the event in parallel mode (multiple at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
EventEmitterGrouped.EventEmitterGrouped = EventEmitterGrouped; // backwards compatability | ||
}, { | ||
key: 'emitParallel', | ||
value: function emitParallel() { | ||
return this.getListenerGroup.apply(this, arguments).setConfig({ concurrency: 0 }).run(); | ||
} | ||
}]); | ||
return EventEmitterGrouped; | ||
}(EventEmitter); | ||
// Export | ||
EventEmitterGrouped.EventEmitterGrouped = EventEmitterGrouped; // backwards compatability | ||
module.exports = EventEmitterGrouped; |
@@ -1,13 +0,21 @@ | ||
'use strict'; | ||
'use strict'; // Import | ||
// Import | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
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; }; }(); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
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); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } | ||
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } | ||
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } | ||
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } | ||
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } | ||
var _require = require('events'), | ||
@@ -19,5 +27,3 @@ EventEmitter = _require.EventEmitter; | ||
var unbounded = require('unbounded'); | ||
// Fetch raw listeners across versions | ||
var unbounded = require('unbounded'); // Fetch raw listeners across versions | ||
// Node v10 defines this on the EventEmitter prototype | ||
@@ -27,9 +33,10 @@ // Node v8 omits 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 events = this._events[eventName]; | ||
if (events == null) return []; | ||
if (typeof events === 'function') return [events]; | ||
return events; | ||
} | ||
/** | ||
@@ -49,115 +56,118 @@ Events EventEmitter to allow you to execute events in serial or parallel. | ||
var EventEmitterGrouped = function (_EventEmitter) { | ||
_inherits(EventEmitterGrouped, _EventEmitter); | ||
function EventEmitterGrouped() { | ||
_classCallCheck(this, EventEmitterGrouped); | ||
var EventEmitterGrouped = | ||
/*#__PURE__*/ | ||
function (_EventEmitter) { | ||
_inherits(EventEmitterGrouped, _EventEmitter); | ||
return _possibleConstructorReturn(this, (EventEmitterGrouped.__proto__ || Object.getPrototypeOf(EventEmitterGrouped)).apply(this, arguments)); | ||
} | ||
function EventEmitterGrouped() { | ||
_classCallCheck(this, EventEmitterGrouped); | ||
_createClass(EventEmitterGrouped, [{ | ||
key: 'getListenerGroup', | ||
return _possibleConstructorReturn(this, _getPrototypeOf(EventEmitterGrouped).apply(this, arguments)); | ||
} | ||
_createClass(EventEmitterGrouped, [{ | ||
key: "getListenerGroup", | ||
/** | ||
Get a TaskGroup for a particular event. | ||
For each listener, treat them as Tasks within a TaskGroup, and return the TaskGroup. | ||
@param {string} eventName | ||
@param {...*} args - the arguments to forward to each task, with the last one being a completion callback with signature `error, results` | ||
@returns {TaskGroup} | ||
@access public | ||
*/ | ||
value: function getListenerGroup(eventName) { | ||
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
/** | ||
Get a TaskGroup for a particular event. | ||
For each listener, treat them as Tasks within a TaskGroup, and return the TaskGroup. | ||
@param {string} eventName | ||
@param {...*} args - the arguments to forward to each task, with the last one being a completion callback with signature `error, results` | ||
@returns {TaskGroup} | ||
@access public | ||
*/ | ||
value: function getListenerGroup(eventName) { | ||
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { | ||
args[_key - 1] = arguments[_key]; | ||
} | ||
// Get listeners | ||
var next = args.pop(); | ||
var me = this; | ||
// Get listeners | ||
var next = args.pop(); | ||
var me = this; // Prepare tasks | ||
// Prepare tasks | ||
var tasks = new TaskGroup('EventEmitterGrouped for ' + eventName).done(next); | ||
var tasks = new TaskGroup("EventEmitterGrouped for ".concat(eventName)).done(next); // Convert the listeners into objects that we can use | ||
// Convert the listeners into objects that we can use | ||
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 | ||
// So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect | ||
// https://github.com/bevry/docpad/issues/462 | ||
// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544 | ||
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 | ||
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 | ||
// So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect | ||
// https://github.com/bevry/docpad/issues/462 | ||
// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544 | ||
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 [".concat(eventName, "] with name [").concat(name, "], length [").concat(length, "], priority [").concat(priority, "]"); | ||
var result = { | ||
method: method, | ||
length: length, | ||
priority: priority, | ||
name: name, | ||
description: description | ||
}; // Return | ||
// Return | ||
};return result; | ||
}); | ||
return result; | ||
}); // Sort the listeners by highest priority first | ||
// Sort the listeners by highest priority first | ||
listenerObjects.sort(function (a, b) { | ||
return b.priority - a.priority; | ||
}); | ||
listenerObjects.sort(function (a, b) { | ||
return b.priority - a.priority; | ||
}); // Add the tasks for the listeners | ||
// Add the tasks for the listeners | ||
listenerObjects.forEach(function (_ref) { | ||
var description = _ref.description, | ||
method = _ref.method; | ||
listenerObjects.forEach(function (_ref) { | ||
var description = _ref.description, | ||
method = _ref.method; | ||
// Bind to the task | ||
tasks.addTask(description, { | ||
method: method, | ||
args: args, | ||
ambi: true | ||
}); | ||
}); // Return | ||
// Bind to the task | ||
tasks.addTask(description, { method: method, args: args, ambi: true }); | ||
}); | ||
return tasks; | ||
} | ||
/** | ||
Refer to EventEmitter#removeListener | ||
https://nodejs.org/dist/latest/docs/api/events.html#events_emitter_removelistener_eventname_listener | ||
@returns {*} whatever removeListener returns | ||
@access public | ||
*/ | ||
// Return | ||
return tasks; | ||
} | ||
}, { | ||
key: "off", | ||
value: function off() { | ||
return this.removeListener.apply(this, arguments); | ||
} | ||
/** | ||
Runs the listener group for the event in serial mode (one at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
/** | ||
Refer to EventEmitter#removeListener | ||
https://nodejs.org/dist/latest/docs/api/events.html#events_emitter_removelistener_eventname_listener | ||
@returns {*} whatever removeListener returns | ||
@access public | ||
*/ | ||
}, { | ||
key: "emitSerial", | ||
value: function emitSerial() { | ||
return this.getListenerGroup.apply(this, arguments).run(); | ||
} | ||
/** | ||
Runs the listener group for the event in parallel mode (multiple at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
}, { | ||
key: 'off', | ||
value: function off() { | ||
return this.removeListener.apply(this, arguments); | ||
} | ||
}, { | ||
key: "emitParallel", | ||
value: function emitParallel() { | ||
return this.getListenerGroup.apply(this, arguments).setConfig({ | ||
concurrency: 0 | ||
}).run(); | ||
} | ||
}]); | ||
/** | ||
Runs the listener group for the event in serial mode (one at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
return EventEmitterGrouped; | ||
}(EventEmitter); // Export | ||
}, { | ||
key: 'emitSerial', | ||
value: function emitSerial() { | ||
return this.getListenerGroup.apply(this, arguments).run(); | ||
} | ||
/** | ||
Runs the listener group for the event in parallel mode (multiple at a time) | ||
@param {...*} args - forwarded to {@link EventEmitterGrouped#getListenerGroup} | ||
@returns {TaskGroup} | ||
*/ | ||
EventEmitterGrouped.EventEmitterGrouped = EventEmitterGrouped; // backwards compatability | ||
}, { | ||
key: 'emitParallel', | ||
value: function emitParallel() { | ||
return this.getListenerGroup.apply(this, arguments).setConfig({ concurrency: 0 }).run(); | ||
} | ||
}]); | ||
return EventEmitterGrouped; | ||
}(EventEmitter); | ||
// Export | ||
EventEmitterGrouped.EventEmitterGrouped = EventEmitterGrouped; // backwards compatability | ||
module.exports = EventEmitterGrouped; |
# History | ||
## v2.8.0 2019 November 13 | ||
- Updated dependencies, [base files](https://github.com/bevry/base), and [editions](https://editions.bevry.me) using [boundation](https://github.com/bevry/boundation) | ||
## v2.7.1 2018 September 3 | ||
- Updated base files and [editions](https://github.com/bevry/editions) using [boundation](https://github.com/bevry/boundation) | ||
- Updated base files and [editions](https://github.com/bevry/editions) using [boundation](https://github.com/bevry/boundation) | ||
## v2.7.0 2018 August 19 | ||
- Updated base files and [editions](https://github.com/bevry/editions) using [boundation](https://github.com/bevry/boundation) | ||
- Updated base files and [editions](https://github.com/bevry/editions) using [boundation](https://github.com/bevry/boundation) | ||
## v2.6.1 2018 July 13 | ||
- Delegated ambi invocation to taskgroup, where it rightfully belongs | ||
- Updated dependencies | ||
- Delegated ambi invocation to taskgroup, where it rightfully belongs | ||
- Updated dependencies | ||
## 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 | ||
- More detailed and accurate task names for listeners | ||
- Better listener argument length detection thanks to [unbounded](https://github.com/bevry/unbounded) | ||
- 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 | ||
- 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 | ||
- 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 | ||
## v2.4.3 2014 June 24 | ||
- Fixed publish | ||
- Fixed publish | ||
## v2.4.2 2014 June 24 | ||
- Fixed publish | ||
- Fixed publish | ||
## v2.4.1 2014 June 16 | ||
- Removed `events-browser` implied dependency, as browserify shim now works | ||
- Removed `events-browser` implied dependency, as browserify shim now works | ||
## v2.4.0 2014 June 16 | ||
- Updated dependencies | ||
- Updated dependencies | ||
## v2.3.3 2014 January 30 | ||
- Possible fix for priorities on events bound by once | ||
- TaskGroup and Tasks are now named by default | ||
- Possible fix for priorities on events bound by once | ||
- TaskGroup and Tasks are now named by default | ||
## v2.3.2 2013 November 6 | ||
- Dropped component.io and bower support, just use ender or browserify | ||
- Updated dependencies | ||
- Dropped component.io and bower support, just use ender or browserify | ||
- Updated dependencies | ||
## v2.3.1 2013 October 27 | ||
- Re-packaged | ||
- Re-packaged | ||
## v2.3.0 2013 July 12 | ||
- Split out from [bal-util](https://github.com/balupton/bal-util) | ||
- Added support for splat arguments | ||
- Split out from [bal-util](https://github.com/balupton/bal-util) | ||
- Added support for splat arguments |
@@ -19,3 +19,3 @@ <!-- LICENSEFILE/ --> | ||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
The above copyright notice and this permission notice (including the next paragraph) shall be included in all copies or substantial portions of the Software. | ||
@@ -22,0 +22,0 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
112
package.json
{ | ||
"title": "Event Emitter Grouped", | ||
"name": "event-emitter-grouped", | ||
"version": "2.7.1", | ||
"version": "2.8.0-next.1573612981.4820c69336cc55c8a917d7950af4a4c62328a4c0", | ||
"description": "Emit events in serial or parallel with support for synchronous and asynchronous listeners", | ||
@@ -30,17 +30,23 @@ "homepage": "https://github.com/bevry/event-emitter-grouped", | ||
"patreon", | ||
"flattr", | ||
"liberapay", | ||
"buymeacoffee", | ||
"opencollective", | ||
"flattr", | ||
"crypto", | ||
"paypal", | ||
"bitcoin", | ||
"wishlist" | ||
], | ||
"config": { | ||
"buymeacoffeeUsername": "balupton", | ||
"cryptoURL": "https://bevry.me/crypto", | ||
"flattrUsername": "balupton", | ||
"liberapayUsername": "bevry", | ||
"opencollectiveUsername": "bevry", | ||
"patreonUsername": "bevry", | ||
"opencollectiveUsername": "bevry", | ||
"flattrUsername": "balupton", | ||
"paypalURL": "https://bevry.me/paypal", | ||
"bitcoinURL": "https://bevry.me/bitcoin", | ||
"wishlistURL": "https://bevry.me/wishlist" | ||
"wishlistURL": "https://bevry.me/wishlist", | ||
"travisTLD": "com" | ||
} | ||
}, | ||
"funding": "https://bevry.me/fund", | ||
"author": "2013+ Bevry Pty Ltd <us@bevry.me> (http://bevry.me), 2011-2012 Benjamin Lupton <b@lupton.cc> (http://balupton.com)", | ||
@@ -69,3 +75,3 @@ "maintainers": [ | ||
"entry": "index.js", | ||
"syntaxes": [ | ||
"tags": [ | ||
"javascript", | ||
@@ -76,3 +82,3 @@ "esnext", | ||
"engines": { | ||
"node": ">=6", | ||
"node": "6 || 8 || 10 || 12 || 13", | ||
"browsers": false | ||
@@ -85,3 +91,3 @@ } | ||
"entry": "index.js", | ||
"syntaxes": [ | ||
"tags": [ | ||
"javascript", | ||
@@ -96,6 +102,6 @@ "require" | ||
{ | ||
"description": "esnext compiled for node.js >=0.8 with require for modules", | ||
"description": "esnext compiled for node.js 0.8 with require for modules", | ||
"directory": "edition-node-0.8", | ||
"entry": "index.js", | ||
"syntaxes": [ | ||
"tags": [ | ||
"javascript", | ||
@@ -105,3 +111,3 @@ "require" | ||
"engines": { | ||
"node": "0.8 || 0.10 || 0.12 || 4 || 6 || 8 || 10", | ||
"node": "0.8 || 0.10 || 0.12 || 4 || 6 || 8 || 10 || 12 || 13", | ||
"browsers": false | ||
@@ -114,21 +120,27 @@ } | ||
"dependencies": { | ||
"editions": "^2.0.2", | ||
"taskgroup": "^5.0.0", | ||
"unbounded": "^1.1.0" | ||
"editions": "^2.2.0", | ||
"taskgroup": "5.5.0", | ||
"unbounded": "^1.2.0" | ||
}, | ||
"devDependencies": { | ||
"assert-helpers": "^4.5.1", | ||
"babel-cli": "^6.26.0", | ||
"babel-preset-env": "^1.7.0", | ||
"babel-preset-es2015": "^6.24.1", | ||
"documentation": "^8.1.2", | ||
"eslint": "^5.5.0", | ||
"eslint-plugin-babel": "^5.1.0", | ||
"joe": "^2.0.2", | ||
"joe-reporter-console": "^2.0.2", | ||
"projectz": "^1.4.0", | ||
"surge": "^0.20.1" | ||
"@babel/cli": "^7.7.0", | ||
"@babel/core": "^7.7.2", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.6.2", | ||
"@babel/preset-env": "^7.7.1", | ||
"assert-helpers": "4.10.0", | ||
"eslint": "^6.6.0", | ||
"eslint-config-bevry": "^1.2.1", | ||
"eslint-config-prettier": "^6.5.0", | ||
"eslint-plugin-babel": "^5.3.0", | ||
"eslint-plugin-prettier": "^3.1.1", | ||
"jsdoc": "^3.6.3", | ||
"kava": "^3.2.0", | ||
"minami": "^1.2.3", | ||
"prettier": "^1.19.1", | ||
"projectz": "^1.9.0", | ||
"surge": "^0.21.3", | ||
"valid-directory": "^1.0.0" | ||
}, | ||
"scripts": { | ||
"our:clean": "rm -Rf ./docs ./edition:* ./es2015 ./es5 ./out", | ||
"our:clean": "rm -Rf ./docs ./edition* ./es2015 ./es5 ./out ./.next", | ||
"our:compile": "npm run our:compile:edition-browsers && npm run our:compile:edition-node-0.8", | ||
@@ -139,3 +151,4 @@ "our:compile:edition-browsers": "env BABEL_ENV=edition-browsers babel --out-dir ./edition-browsers ./source", | ||
"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:docs": "npm run our:meta:docs:jsdoc", | ||
"our:meta:docs:jsdoc": "rm -Rf ./docs && jsdoc --recurse --pedantic --access all --destination ./docs --package ./package.json --readme ./README.md --template ./node_modules/minami ./source && mv ./docs/$npm_package_name/$npm_package_version/* ./docs/ && rm -Rf ./docs/$npm_package_name/$npm_package_version", | ||
"our:meta:projectz": "projectz compile", | ||
@@ -148,33 +161,52 @@ "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: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:setup": "npm run our:setup:npm", | ||
"our:setup:npm": "npm install", | ||
"our:setup": "npm run our:setup:install", | ||
"our:setup:install": "npm install", | ||
"our:test": "npm run our:verify && npm test", | ||
"our:verify": "npm run our:verify:eslint", | ||
"our:verify:eslint": "eslint --fix ./source", | ||
"test": "node --harmony ./test.js --joe-reporter=console" | ||
"our:verify": "npm run our:verify:directory && npm run our:verify:eslint && npm run our:verify:prettier", | ||
"our:verify:directory": "npx valid-directory", | ||
"our:verify:eslint": "eslint --fix --ignore-pattern '**/*.d.ts' --ignore-pattern '**/vendor/' --ignore-pattern '**/node_modules/' --ext .mjs,.js,.jsx,.ts,.tsx ./source", | ||
"our:verify:prettier": "prettier --write ./source/**", | ||
"test": "node ./test.js" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"bevry" | ||
] | ||
}, | ||
"prettier": { | ||
"semi": false, | ||
"singleQuote": true | ||
}, | ||
"babel": { | ||
"env": { | ||
"edition-browsers": { | ||
"sourceType": "script", | ||
"presets": [ | ||
[ | ||
"env", | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"browsers": "defaults" | ||
} | ||
"targets": "defaults", | ||
"modules": "commonjs" | ||
} | ||
] | ||
], | ||
"plugins": [ | ||
"@babel/proposal-object-rest-spread" | ||
] | ||
}, | ||
"edition-node-0.8": { | ||
"sourceType": "script", | ||
"presets": [ | ||
[ | ||
"env", | ||
"@babel/preset-env", | ||
{ | ||
"targets": { | ||
"node": "0.8" | ||
} | ||
}, | ||
"modules": "commonjs" | ||
} | ||
] | ||
], | ||
"plugins": [ | ||
"@babel/proposal-object-rest-spread" | ||
] | ||
@@ -181,0 +213,0 @@ } |
@@ -10,3 +10,3 @@ <!-- TITLE/ --> | ||
<span class="badge-travisci"><a href="http://travis-ci.org/bevry/event-emitter-grouped" title="Check this project's build status on TravisCI"><img src="https://img.shields.io/travis/bevry/event-emitter-grouped/master.svg" alt="Travis CI Build Status" /></a></span> | ||
<span class="badge-travisci"><a href="http://travis-ci.com/bevry/event-emitter-grouped" title="Check this project's build status on TravisCI"><img src="https://img.shields.io/travis/com/bevry/event-emitter-grouped/master.svg" alt="Travis CI Build Status" /></a></span> | ||
<span class="badge-npmversion"><a href="https://npmjs.org/package/event-emitter-grouped" title="View this project on NPM"><img src="https://img.shields.io/npm/v/event-emitter-grouped.svg" alt="NPM version" /></a></span> | ||
@@ -18,6 +18,8 @@ <span class="badge-npmdownloads"><a href="https://npmjs.org/package/event-emitter-grouped" title="View this project on NPM"><img src="https://img.shields.io/npm/dm/event-emitter-grouped.svg" alt="NPM downloads" /></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-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> | ||
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span> | ||
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee 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> | ||
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span> | ||
<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-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin 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> | ||
@@ -39,24 +41,37 @@ | ||
<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>NPM</h3></a><ul> | ||
<a href="https://npmjs.com" title="npm is a package manager for javascript"><h3>npm</h3></a> | ||
<ul> | ||
<li>Install: <code>npm install --save event-emitter-grouped</code></li> | ||
<li>Module: <code>require('event-emitter-grouped')</code></li></ul> | ||
<li>Require: <code>require('event-emitter-grouped')</code></li> | ||
</ul> | ||
<a href="http://browserify.org" title="Browserify lets you require('modules') in the browser by bundling up all of your dependencies"><h3>Browserify</h3></a><ul> | ||
<li>Install: <code>npm install --save event-emitter-grouped</code></li> | ||
<li>Module: <code>require('event-emitter-grouped')</code></li> | ||
<li>CDN URL: <code>//wzrd.in/bundle/event-emitter-grouped@2.7.1</code></li></ul> | ||
<a href="https://jspm.io" title="Native ES Modules CDN"><h3>jspm</h3></a> | ||
<a href="http://enderjs.com" title="Ender is a full featured package manager for your browser"><h3>Ender</h3></a><ul> | ||
<li>Install: <code>ender add event-emitter-grouped</code></li> | ||
<li>Module: <code>require('event-emitter-grouped')</code></li></ul> | ||
``` html | ||
<script type="module"> | ||
import * as pkg from '//dev.jspm.io/event-emitter-grouped' | ||
</script> | ||
``` | ||
<h3><a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3> | ||
<h3><a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a></h3> | ||
<p>This package is published with the following editions:</p> | ||
<ul><li><code>event-emitter-grouped</code> aliases <code>event-emitter-grouped/index.js</code> which uses <a href="https://github.com/bevry/editions" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li> | ||
<ul><li><code>event-emitter-grouped</code> aliases <code>event-emitter-grouped/index.js</code> which uses <a href="https://editions.bevry.me" title="Editions are the best way to produce and consume packages you care about.">Editions</a> to automatically select the correct edition for the consumers environment</li> | ||
<li><code>event-emitter-grouped/source/index.js</code> is esnext source code with require for modules</li> | ||
<li><code>event-emitter-grouped/edition-browsers/index.js</code> is esnext compiled for browsers with require for modules</li> | ||
<li><code>event-emitter-grouped/edition-node-0.8/index.js</code> is esnext compiled for node.js >=0.8 with require for modules</li></ul> | ||
<li><code>event-emitter-grouped/edition-node-0.8/index.js</code> is esnext compiled for node.js 0.8 with require for modules</li></ul> | ||
<h3><a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a></h3> | ||
This project provides its type information via inline <a href="http://usejsdoc.org" title="JSDoc is an API documentation generator for JavaScript, similar to Javadoc or phpDocumentor">JSDoc Comments</a>. To make use of this in <a href="https://www.typescriptlang.org/" title="TypeScript is a typed superset of JavaScript that compiles to plain JavaScript. ">TypeScript</a>, set your <code>maxNodeModuleJsDepth</code> compiler option to `5` or thereabouts. You can accomlish this via your `tsconfig.json` file like so: | ||
``` json | ||
{ | ||
"compilerOptions": { | ||
"maxNodeModuleJsDepth": 5 | ||
} | ||
} | ||
``` | ||
<!-- /INSTALL --> | ||
@@ -159,6 +174,8 @@ | ||
<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-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> | ||
<span class="badge-liberapay"><a href="https://liberapay.com/bevry" title="Donate to this project using Liberapay"><img src="https://img.shields.io/badge/liberapay-donate-yellow.svg" alt="Liberapay donate button" /></a></span> | ||
<span class="badge-buymeacoffee"><a href="https://buymeacoffee.com/balupton" title="Donate to this project using Buy Me A Coffee"><img src="https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg" alt="Buy Me A Coffee 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> | ||
<span class="badge-crypto"><a href="https://bevry.me/crypto" title="Donate to this project using Cryptocurrency"><img src="https://img.shields.io/badge/crypto-donate-yellow.svg" alt="crypto donate button" /></a></span> | ||
<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-bitcoin"><a href="https://bevry.me/bitcoin" title="Donate once-off to this project using Bitcoin"><img src="https://img.shields.io/badge/bitcoin-donate-yellow.svg" alt="Bitcoin 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> | ||
@@ -165,0 +182,0 @@ |
@@ -13,3 +13,3 @@ 'use strict' | ||
// However, due to the inconsistencies, this is what we have | ||
function rawListeners (eventName) { | ||
function rawListeners(eventName) { | ||
const events = this._events[eventName] | ||
@@ -35,3 +35,2 @@ if (events == null) return [] | ||
class EventEmitterGrouped extends EventEmitter { | ||
/** | ||
@@ -45,3 +44,3 @@ Get a TaskGroup for a particular event. | ||
*/ | ||
getListenerGroup (eventName, ...args) { | ||
getListenerGroup(eventName, ...args) { | ||
// Get listeners | ||
@@ -52,20 +51,30 @@ const next = args.pop() | ||
// Prepare tasks | ||
const tasks = new TaskGroup(`EventEmitterGrouped for ${eventName}`).done(next) | ||
const tasks = new TaskGroup(`EventEmitterGrouped for ${eventName}`).done( | ||
next | ||
) | ||
// Convert the listeners into objects that we can use | ||
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 | ||
// So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect | ||
// https://github.com/bevry/docpad/issues/462 | ||
// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544 | ||
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 } | ||
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 | ||
// So we must pass fireWithOptionalCallback an array of the method to fire, and the method to introspect | ||
// https://github.com/bevry/docpad/issues/462 | ||
// https://github.com/joyent/node/commit/d1b4dcd6acb1d1c66e423f7992dc6eec8a35c544 | ||
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 } | ||
// Return | ||
return result | ||
}) | ||
// Return | ||
return result | ||
}) | ||
@@ -76,3 +85,3 @@ // Sort the listeners by highest priority first | ||
// Add the tasks for the listeners | ||
listenerObjects.forEach(function ({ description, method }) { | ||
listenerObjects.forEach(function({ description, method }) { | ||
// Bind to the task | ||
@@ -92,3 +101,3 @@ tasks.addTask(description, { method, args, ambi: true }) | ||
*/ | ||
off (...args) { | ||
off(...args) { | ||
return this.removeListener(...args) | ||
@@ -102,3 +111,3 @@ } | ||
*/ | ||
emitSerial (...args) { | ||
emitSerial(...args) { | ||
return this.getListenerGroup(...args).run() | ||
@@ -112,4 +121,6 @@ } | ||
*/ | ||
emitParallel (...args) { | ||
return this.getListenerGroup(...args).setConfig({ concurrency: 0 }).run() | ||
emitParallel(...args) { | ||
return this.getListenerGroup(...args) | ||
.setConfig({ concurrency: 0 }) | ||
.run() | ||
} | ||
@@ -119,3 +130,3 @@ } | ||
// Export | ||
EventEmitterGrouped.EventEmitterGrouped = EventEmitterGrouped // backwards compatability | ||
EventEmitterGrouped.EventEmitterGrouped = EventEmitterGrouped // backwards compatability | ||
module.exports = EventEmitterGrouped |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
40009
10
380
205
0
17
1
Updatededitions@^2.2.0
Updatedtaskgroup@5.5.0
Updatedunbounded@^1.2.0