glob-events
Advanced tools
Comparing version 0.3.0 to 0.4.0
# Changes | ||
## 0.4.0 | ||
- Pass on given event object as scope | ||
- Expose event name on scope | ||
- Expose args on scope | ||
- Expose given options on scope | ||
## 0.3.0 | ||
@@ -4,0 +11,0 @@ |
@@ -39,22 +39,28 @@ /* | ||
emit: function (event) { | ||
var opts; | ||
var opts, scope; | ||
if (typeof event === 'object') { | ||
scope = event; | ||
opts = options(event); | ||
event = event.event; | ||
} else { | ||
scope = { event : event }; | ||
} | ||
if (typeof event !== 'string') { | ||
if (typeof scope.event !== 'string') { | ||
throw new TypeError(E_EVENT); | ||
} | ||
var i = this._store.iterator(event, opts), fn, l = arguments.length, a, j; | ||
var i = this._store.iterator(scope.event, opts), | ||
l = arguments.length, | ||
fn; | ||
if (l > 1) { | ||
a = []; | ||
var a = [], j; | ||
for (j = 1; j < l; j++) { | ||
a[j - 1] = arguments[j]; | ||
} | ||
scope.args = a; | ||
while ((fn = i.next()) !== undefined) { | ||
fn.apply(null, a); | ||
fn.apply(scope, a); | ||
} | ||
} else { | ||
scope.args = []; | ||
while ((fn = i.next()) !== undefined) { | ||
fn(); | ||
fn.call(scope); | ||
} | ||
@@ -61,0 +67,0 @@ } |
{ | ||
"name" : "glob-events", | ||
"version" : "0.3.0", | ||
"version" : "0.4.0", | ||
"description" : "Event emitter with glob support on event names", | ||
@@ -13,6 +13,6 @@ "keywords" : ["event", "emitter", "glob", "listener"], | ||
"scripts" : { | ||
"start" : "mochify --watch --node --cover", | ||
"start" : "mochify --watch --node", | ||
"lint" : "jslint --color './**/*.js'", | ||
"test-wd" : "mochify --wd", | ||
"test" : "npm run lint && mocha -R spec && mochify --cover" | ||
"test" : "npm run lint && mocha && mochify --cover" | ||
}, | ||
@@ -27,5 +27,5 @@ "repository" : { | ||
"devDependencies" : { | ||
"mocha" : ">=1.17 <2", | ||
"jslint" : "~0.3.1", | ||
"mochify" : "~0.7.0", | ||
"mocha" : "^1.17", | ||
"jslint" : "~0.3.3", | ||
"mochify" : "~0.8.2", | ||
"bench" : "~0.3.5" | ||
@@ -32,0 +32,0 @@ }, |
7823
113