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

@boost/event

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@boost/event - npm Package Compare versions

Comparing version 2.2.1 to 2.3.0

dts/BailEvent.d.ts

12

CHANGELOG.md

@@ -6,2 +6,14 @@ # Change Log

## 2.3.0 - 2021-01-16
#### 🚀 Updates
- Migrate to Packemon for package building. (#135) ([1a0e9d8](https://github.com/milesj/boost/commit/1a0e9d8)), closes [#135](https://github.com/milesj/boost/issues/135)
**Note:** Version bump only for package @boost/event
### 2.2.1 - 2020-11-29

@@ -8,0 +20,0 @@

166

esm/index.js

@@ -1,9 +0,7 @@

import { createScopedError, createInternalDebugger } from '@boost/internal';
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
import { createInternalDebugger, createScopedError } from '@boost/internal';
var WILDCARD_SCOPE = '*';
var EVENT_NAME_PATTERN = /^[a-z]{1}[\x2D\.0-9a-z]*[a-z]{1}$/;
var debug = createInternalDebugger('event');
var errors = {

@@ -15,8 +13,3 @@ LISTENER_INVALID: 'Invalid event listener for "{0}", must be a function.',

var debug = createInternalDebugger('event');
var WILDCARD_SCOPE = '*';
var EVENT_NAME_PATTERN = /^[a-z]{1}[\x2D\.0-9a-z]*[a-z]{1}$/;
var BaseEvent = /*#__PURE__*/function () {
var BaseEvent = function () {
function BaseEvent(name) {

@@ -27,11 +20,7 @@ this.listeners = new Map();

if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
debug('New %S created: %s', this.constructor.name, name);
}
}
/**
* Remove all listeners from the event.
*/
var _proto = BaseEvent.prototype;

@@ -47,7 +36,3 @@

return this;
}
/**
* Return a set of listeners for a specific event scope.
*/
;
};

@@ -62,15 +47,7 @@ _proto.getListeners = function getListeners(scope) {

return this.listeners.get(key);
}
/**
* Return a list of all scopes with listeners.
*/
;
};
_proto.getScopes = function getScopes() {
return Array.from(this.listeners.keys());
}
/**
* Register a listener to the event.
*/
;
};

@@ -80,3 +57,3 @@ _proto.listen = function listen(listener, scope) {

if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
debug('Registering "%s" listener', this.name);

@@ -89,7 +66,3 @@ }

};
}
/**
* Register a listener to the event that only triggers once.
*/
;
};

@@ -108,10 +81,6 @@ _proto.once = function once(listener, scope) {

return this.listen(handler, scope);
}
/**
* Remove a listener from the event.
*/
;
};
_proto.unlisten = function unlisten(listener, scope) {
if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
debug('Unregistering "%s" listener', this.name);

@@ -122,10 +91,6 @@ }

return this;
}
/**
* Validate the listener is a function.
*/
;
};
_proto.validateListener = function validateListener(listener) {
if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
if (typeof listener !== 'function') {

@@ -137,7 +102,3 @@ throw new EventError('LISTENER_INVALID', [this.name]);

return listener;
}
/**
* Validate the name/scope match a defined pattern.
*/
;
};

@@ -149,3 +110,3 @@ _proto.validateName = function validateName(name, type) {

if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
if (!name.match(EVENT_NAME_PATTERN)) {

@@ -157,7 +118,3 @@ throw new EventError('NAME_INVALID', [type, name]);

return name;
}
/**
* Emit the event by executing all scoped listeners with the defined arguments.
*/
;
};

@@ -167,3 +124,3 @@ return BaseEvent;

var BailEvent = /*#__PURE__*/function (_BaseEvent) {
var BailEvent = function (_BaseEvent) {
_inheritsLoose(BailEvent, _BaseEvent);

@@ -175,11 +132,6 @@

var _proto = BailEvent.prototype;
var _proto2 = BailEvent.prototype;
/**
* Synchronously execute listeners with the defined arguments.
* If a listener returns `false`, the loop with be aborted early,
* and the emitter will return `true` (for bailed).
*/
_proto.emit = function emit(args, scope) {
if ("production" !== process.env.NODE_ENV) {
_proto2.emit = function emit(args, scope) {
if (process.env.NODE_ENV !== "production") {
debug('Emitting "%s%s" as bail', this.name, scope ? ":" + scope : '');

@@ -196,38 +148,13 @@ }

var Event = /*#__PURE__*/function (_BaseEvent) {
_inheritsLoose(Event, _BaseEvent);
var ConcurrentEvent = function (_BaseEvent2) {
_inheritsLoose(ConcurrentEvent, _BaseEvent2);
function Event() {
return _BaseEvent.apply(this, arguments) || this;
}
var _proto = Event.prototype;
/**
* Synchronously execute listeners with the defined arguments.
*/
_proto.emit = function emit(args, scope) {
Array.from(this.getListeners(scope)).forEach(function (listener) {
listener.apply(void 0, args);
});
};
return Event;
}(BaseEvent);
var ConcurrentEvent = /*#__PURE__*/function (_BaseEvent) {
_inheritsLoose(ConcurrentEvent, _BaseEvent);
function ConcurrentEvent() {
return _BaseEvent.apply(this, arguments) || this;
return _BaseEvent2.apply(this, arguments) || this;
}
var _proto = ConcurrentEvent.prototype;
var _proto3 = ConcurrentEvent.prototype;
/**
* Asynchronously execute listeners for with the defined arguments.
* Will return a promise with an array of each listener result.
*/
_proto.emit = function emit(args, scope) {
if ("production" !== process.env.NODE_ENV) {
_proto3.emit = function emit(args, scope) {
if (process.env.NODE_ENV !== "production") {
debug('Emitting "%s%s" as concurrent', this.name, scope ? ":" + scope : '');

@@ -244,17 +171,31 @@ }

var WaterfallEvent = /*#__PURE__*/function (_BaseEvent) {
_inheritsLoose(WaterfallEvent, _BaseEvent);
var Event = function (_BaseEvent3) {
_inheritsLoose(Event, _BaseEvent3);
function Event() {
return _BaseEvent3.apply(this, arguments) || this;
}
var _proto4 = Event.prototype;
_proto4.emit = function emit(args, scope) {
Array.from(this.getListeners(scope)).forEach(function (listener) {
listener.apply(void 0, args);
});
};
return Event;
}(BaseEvent);
var WaterfallEvent = function (_BaseEvent4) {
_inheritsLoose(WaterfallEvent, _BaseEvent4);
function WaterfallEvent() {
return _BaseEvent.apply(this, arguments) || this;
return _BaseEvent4.apply(this, arguments) || this;
}
var _proto = WaterfallEvent.prototype;
var _proto5 = WaterfallEvent.prototype;
/**
* Synchronously execute listeners with the defined argument value.
* The return value of each listener will be passed as an argument to the next listener.
*/
_proto.emit = function emit(arg, scope) {
if ("production" !== process.env.NODE_ENV) {
_proto5.emit = function emit(arg, scope) {
if (process.env.NODE_ENV !== "production") {
debug('Emitting "%s%s" as waterfall', this.name, scope ? ":" + scope : '');

@@ -272,1 +213,2 @@ }

export { BailEvent, BaseEvent, ConcurrentEvent, EVENT_NAME_PATTERN, Event, EventError, WILDCARD_SCOPE, WaterfallEvent };
//# sourceMappingURL=index.js.map
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
Object.defineProperty(exports, '__esModule', {
value: true
});
var internal = require('@boost/internal');
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
var WILDCARD_SCOPE = '*';
var EVENT_NAME_PATTERN = /^[a-z]{1}[\x2D\.0-9a-z]*[a-z]{1}$/;
var debug = internal.createInternalDebugger('event');
var errors = {

@@ -19,8 +20,3 @@ LISTENER_INVALID: 'Invalid event listener for "{0}", must be a function.',

var debug = internal.createInternalDebugger('event');
var WILDCARD_SCOPE = '*';
var EVENT_NAME_PATTERN = /^[a-z]{1}[\x2D\.0-9a-z]*[a-z]{1}$/;
var BaseEvent = /*#__PURE__*/function () {
var BaseEvent = function () {
function BaseEvent(name) {

@@ -31,11 +27,7 @@ this.listeners = new Map();

if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
debug('New %S created: %s', this.constructor.name, name);
}
}
/**
* Remove all listeners from the event.
*/
var _proto = BaseEvent.prototype;

@@ -51,7 +43,3 @@

return this;
}
/**
* Return a set of listeners for a specific event scope.
*/
;
};

@@ -66,15 +54,7 @@ _proto.getListeners = function getListeners(scope) {

return this.listeners.get(key);
}
/**
* Return a list of all scopes with listeners.
*/
;
};
_proto.getScopes = function getScopes() {
return Array.from(this.listeners.keys());
}
/**
* Register a listener to the event.
*/
;
};

@@ -84,3 +64,3 @@ _proto.listen = function listen(listener, scope) {

if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
debug('Registering "%s" listener', this.name);

@@ -93,7 +73,3 @@ }

};
}
/**
* Register a listener to the event that only triggers once.
*/
;
};

@@ -112,10 +88,6 @@ _proto.once = function once(listener, scope) {

return this.listen(handler, scope);
}
/**
* Remove a listener from the event.
*/
;
};
_proto.unlisten = function unlisten(listener, scope) {
if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
debug('Unregistering "%s" listener', this.name);

@@ -126,10 +98,6 @@ }

return this;
}
/**
* Validate the listener is a function.
*/
;
};
_proto.validateListener = function validateListener(listener) {
if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
if (typeof listener !== 'function') {

@@ -141,7 +109,3 @@ throw new EventError('LISTENER_INVALID', [this.name]);

return listener;
}
/**
* Validate the name/scope match a defined pattern.
*/
;
};

@@ -153,3 +117,3 @@ _proto.validateName = function validateName(name, type) {

if ("production" !== process.env.NODE_ENV) {
if (process.env.NODE_ENV !== "production") {
if (!name.match(EVENT_NAME_PATTERN)) {

@@ -161,7 +125,3 @@ throw new EventError('NAME_INVALID', [type, name]);

return name;
}
/**
* Emit the event by executing all scoped listeners with the defined arguments.
*/
;
};

@@ -171,3 +131,3 @@ return BaseEvent;

var BailEvent = /*#__PURE__*/function (_BaseEvent) {
var BailEvent = function (_BaseEvent) {
_inheritsLoose(BailEvent, _BaseEvent);

@@ -179,11 +139,6 @@

var _proto = BailEvent.prototype;
var _proto2 = BailEvent.prototype;
/**
* Synchronously execute listeners with the defined arguments.
* If a listener returns `false`, the loop with be aborted early,
* and the emitter will return `true` (for bailed).
*/
_proto.emit = function emit(args, scope) {
if ("production" !== process.env.NODE_ENV) {
_proto2.emit = function emit(args, scope) {
if (process.env.NODE_ENV !== "production") {
debug('Emitting "%s%s" as bail', this.name, scope ? ":" + scope : '');

@@ -200,38 +155,13 @@ }

var Event = /*#__PURE__*/function (_BaseEvent) {
_inheritsLoose(Event, _BaseEvent);
var ConcurrentEvent = function (_BaseEvent2) {
_inheritsLoose(ConcurrentEvent, _BaseEvent2);
function Event() {
return _BaseEvent.apply(this, arguments) || this;
}
var _proto = Event.prototype;
/**
* Synchronously execute listeners with the defined arguments.
*/
_proto.emit = function emit(args, scope) {
Array.from(this.getListeners(scope)).forEach(function (listener) {
listener.apply(void 0, args);
});
};
return Event;
}(BaseEvent);
var ConcurrentEvent = /*#__PURE__*/function (_BaseEvent) {
_inheritsLoose(ConcurrentEvent, _BaseEvent);
function ConcurrentEvent() {
return _BaseEvent.apply(this, arguments) || this;
return _BaseEvent2.apply(this, arguments) || this;
}
var _proto = ConcurrentEvent.prototype;
var _proto3 = ConcurrentEvent.prototype;
/**
* Asynchronously execute listeners for with the defined arguments.
* Will return a promise with an array of each listener result.
*/
_proto.emit = function emit(args, scope) {
if ("production" !== process.env.NODE_ENV) {
_proto3.emit = function emit(args, scope) {
if (process.env.NODE_ENV !== "production") {
debug('Emitting "%s%s" as concurrent', this.name, scope ? ":" + scope : '');

@@ -248,17 +178,31 @@ }

var WaterfallEvent = /*#__PURE__*/function (_BaseEvent) {
_inheritsLoose(WaterfallEvent, _BaseEvent);
var Event = function (_BaseEvent3) {
_inheritsLoose(Event, _BaseEvent3);
function Event() {
return _BaseEvent3.apply(this, arguments) || this;
}
var _proto4 = Event.prototype;
_proto4.emit = function emit(args, scope) {
Array.from(this.getListeners(scope)).forEach(function (listener) {
listener.apply(void 0, args);
});
};
return Event;
}(BaseEvent);
var WaterfallEvent = function (_BaseEvent4) {
_inheritsLoose(WaterfallEvent, _BaseEvent4);
function WaterfallEvent() {
return _BaseEvent.apply(this, arguments) || this;
return _BaseEvent4.apply(this, arguments) || this;
}
var _proto = WaterfallEvent.prototype;
var _proto5 = WaterfallEvent.prototype;
/**
* Synchronously execute listeners with the defined argument value.
* The return value of each listener will be passed as an argument to the next listener.
*/
_proto.emit = function emit(arg, scope) {
if ("production" !== process.env.NODE_ENV) {
_proto5.emit = function emit(arg, scope) {
if (process.env.NODE_ENV !== "production") {
debug('Emitting "%s%s" as waterfall', this.name, scope ? ":" + scope : '');

@@ -283,1 +227,2 @@ }

exports.WaterfallEvent = WaterfallEvent;
//# sourceMappingURL=index.js.map
{
"name": "@boost/event",
"version": "2.2.1",
"version": "2.3.0",
"release": "1594765247526",

@@ -14,7 +14,12 @@ "description": "An event system with multiple emitter patterns.",

"module": "./esm/index.js",
"types": "./lib/index.d.ts",
"types": "./dts/index.d.ts",
"engines": {
"node": ">=10.17.0"
"node": ">=10.3.0"
},
"repository": "https://github.com/milesj/boost/tree/master/packages/event",
"repository": {
"type": "git",
"url": "git@github.com:milesj/boost.git",
"directory": "packages/event"
},
"author": "Miles Johnson",
"license": "MIT",

@@ -25,3 +30,3 @@ "publishConfig": {

"dependencies": {
"@boost/internal": "^2.1.2"
"@boost/internal": "^2.2.0"
},

@@ -32,3 +37,9 @@ "funding": {

},
"gitHead": "5f7e4dd672542eef29f55ec17300600e5fcd6a92"
"packemon": {
"platform": [
"browser",
"node"
]
},
"gitHead": "e2c452ee0c15aa7db91d1945e23ac6951028e672"
}
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