glob-events
Advanced tools
Comparing version 1.5.0 to 1.6.0
# Changes | ||
## 1.6.0 | ||
- Expose `emitError` | ||
## 1.5.0 | ||
@@ -4,0 +8,0 @@ |
@@ -192,3 +192,3 @@ /* | ||
invoke: function (i, scope) { | ||
var err, o = i.next(), emitter; | ||
var err, o = i.next(); | ||
if (!o) { | ||
@@ -211,12 +211,7 @@ if (scope.event === 'error') { | ||
try { | ||
emitter = this._internalEmitter; | ||
emitter.invoke(emitter.iterator('error'), { | ||
event : 'error', | ||
args : [e], | ||
cause : { | ||
event : scope.event, | ||
fn : o.fn, | ||
scope : o.scope || scope, | ||
args : scope.args || [] | ||
} | ||
this.emitError(e, { | ||
event : scope.event, | ||
fn : o.fn, | ||
scope : o.scope || scope, | ||
args : scope.args || [] | ||
}); | ||
@@ -238,2 +233,11 @@ } catch (ee) { | ||
emitError: function (err, cause) { | ||
var emitter = this._internalEmitter; | ||
emitter.invoke(emitter.iterator('error'), { | ||
event : 'error', | ||
args : [err], | ||
cause : cause | ||
}); | ||
}, | ||
isInternalEvent: function (event) { | ||
@@ -240,0 +244,0 @@ if (typeof event !== 'string') { |
{ | ||
"name" : "glob-events", | ||
"version" : "1.5.0", | ||
"version" : "1.6.0", | ||
"description" : "Event emitter with glob support on event names", | ||
@@ -5,0 +5,0 @@ "keywords" : ["event", "emitter", "glob", "listener"], |
@@ -57,7 +57,7 @@ # glob-events.js | ||
with the optional arguments. Matching rules are applied on the event name as | ||
descibed in the [glob-tree match expressions][]. | ||
described in the [glob-tree match expressions][]. | ||
- `addListener(event, fn)` / `on(event, fn)`: Registers a listener for an event | ||
- `once(event, fn)`: Registers a listener for an event that is automatically | ||
removed on the first invocation | ||
- `removeListener(event, fn)`: Unregisteres a listener for an event | ||
- `removeListener(event, fn)`: Unregisters a listener for an event | ||
- `removeAllListeners([event])`: Unregisters all listeners, or all listeners | ||
@@ -81,6 +81,14 @@ for the given event. Matching rules are not applied. | ||
the given `scope` with the arguments from `scope.args`. This function is | ||
internally used by `emit`. | ||
internally used by `emit`. If a listener throws, `emitError` is used to emit | ||
an error event. | ||
- `isInternalEvent(event)`: Returns `true` if the given event is an internal | ||
event. These are the "error" event, the add and remove events and the | ||
configured internal events. | ||
- `emitError(error, cause)`: Emits an `"error"` event with the given error as | ||
the only argument. If `cause` is given, it is accessible in error listeners | ||
via `this.cause`. A cause object should have these entries: | ||
- `event`: The event that caused the exception | ||
- `fn`: The function that threw the exception | ||
- `scope`: The scope the function was executed with | ||
- `args`: The arguments that where passed to the function | ||
@@ -87,0 +95,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16689
227
152