glob-events
Advanced tools
Comparing version 1.2.1 to 1.3.0
# Changes | ||
## 1.3.0 | ||
- Expose `emitter` in scope | ||
- Fix `removeMatchingListeners` to not remove "removeListener" too early | ||
## 1.2.1 | ||
@@ -4,0 +9,0 @@ |
@@ -24,3 +24,3 @@ /* | ||
function toScope(args) { | ||
function toScope(args, emitter) { | ||
var event = args[0]; | ||
@@ -41,2 +41,5 @@ var scope = typeof event === 'string' ? { event : event } : event; | ||
} | ||
if (arguments.length > 1) { | ||
scope.emitter = emitter; | ||
} | ||
return scope; | ||
@@ -71,3 +74,3 @@ } | ||
emit: function () { | ||
var s = toScope(arguments); | ||
var s = toScope(arguments, this); | ||
this.invoke(this.iterator(s.event, s), s); | ||
@@ -157,2 +160,5 @@ }, | ||
}, i.name, o.orig || o.fn); | ||
} | ||
i = this._store.iterator(event); | ||
while ((o = i.next()) !== undefined) { | ||
this._store.remove(i.name, o); | ||
@@ -159,0 +165,0 @@ } |
{ | ||
"name" : "glob-events", | ||
"version" : "1.2.1", | ||
"version" : "1.3.0", | ||
"description" : "Event emitter with glob support on event names", | ||
@@ -13,6 +13,7 @@ "keywords" : ["event", "emitter", "glob", "listener"], | ||
"scripts" : { | ||
"start" : "mochify --watch", | ||
"watch" : "mochify --watch", | ||
"lint" : "jslint --edition=latest --color \"**/*.js\"", | ||
"wd" : "mochify --wd", | ||
"test" : "npm run lint && mocha && mochify --cover" | ||
"pretest" : "npm run lint", | ||
"test" : "mocha && mochify --cover" | ||
}, | ||
@@ -19,0 +20,0 @@ "repository" : { |
@@ -42,4 +42,5 @@ # glob-events.js | ||
`"removeListener"`. | ||
- `toScope(args)`: Converts the given arguments array into a scope object that | ||
can be used with `invoke`. | ||
- `toScope(args[, emitter])`: Converts the given arguments array into a scope | ||
object that can be used with `invoke`. If an `emitter` is given, it is added | ||
to the scope object. | ||
@@ -72,3 +73,3 @@ The constructor `opts` are passed to the [glob-store][] constructor. | ||
entries that where added with `once`. | ||
- `scope`: The scopr to use when invoking the function. | ||
- `scope`: The scope to use when invoking the function. | ||
- `invoke(iterator, scope)`: Invokes the functions returned by an iterator on | ||
@@ -92,4 +93,8 @@ the given `scope` with the arguments from `scope.args`. This function is | ||
`emit` as the event (see Options), that object is used as the scope object. | ||
In addition, the arguments array is exposed via `this.args`. | ||
The scope object always has these properties: | ||
- `event`: The event that was emitted | ||
- `args`: The arguments that where passed after the event name. | ||
- `emitter`: The event emitter instance | ||
It is also possible to bind individual listeners to specific scope objects: | ||
@@ -96,0 +101,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
14631
209
135