Skip to content

Commit 765e59d

Browse files
committed
Merge branch 'master' of github.com:trailsjs/trails
2 parents 242b446 + 9cb4a51 commit 765e59d

File tree

6 files changed

+25
-9
lines changed

6 files changed

+25
-9
lines changed

.eslintignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
node_modules
21
coverage

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ information on how our projects are organized and how to get started.
131131

132132
<img src="http://i.imgur.com/dCjNisP.png">
133133

134-
[trails-image]: http://i.imgur.com/zfT2NEv.png
134+
[trails-image]: http://i.imgur.com/0iVVRxi.png
135135
[trails-url]: http://trailsjs.io
136136
[npm-image]: https://img.shields.io/npm/v/trails.svg?style=flat-square
137137
[npm-url]: https://npmjs.org/package/trails

archetype/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
],
77
"main": "index.js",
88
"dependencies": {
9-
"trailpack-core": "^1.0.0",
10-
"trailpack-repl": "^1.0.8",
11-
"trailpack-router": "^1.0.2",
12-
"trails": "^1.0.4",
9+
"trailpack-core": "^1.0.1",
10+
"trailpack-repl": "^1.1.0",
11+
"trailpack-router": "^1.0.8",
12+
"trails": "^1.1.0",
1313
"trails-controller": "^1.0.0-beta-2",
1414
"trails-model": "^1.0.0-beta-2",
1515
"trails-policy": "^1.0.1",

index.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,15 @@ module.exports = class TrailsApp extends events.EventEmitter {
164164
* Extend the once emiter reader for accept multi valid events
165165
*/
166166
onceAny (events, handler) {
167+
const self = this
168+
167169
if (!events)
168170
return
169-
if (!(events instanceof Array))
171+
if (!Array.isArray(events))
170172
events = [events]
171173

172-
const cb = (e) => {
173-
this.removeListener(e, cb)
174+
function cb (e) {
175+
self.removeListener(e, cb)
174176
handler.apply(this, Array.prototype.slice.call(arguments, 0))
175177
}
176178

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"coverage": "istanbul cover _mocha",
2525
"ci": "cd .. && ci"
2626
},
27+
"pre-commit": [
28+
"test"
29+
],
2730
"repository": {
2831
"type": "git",
2932
"url": "git+https://github.com/trailsjs/trails.git"
@@ -67,6 +70,7 @@
6770
"eslint-config-trails": "^1.0",
6871
"istanbul": "^0.4.2",
6972
"mocha": "^2.3.4",
73+
"pre-commit": "^1.1.3",
7074
"smokesignals": "^1.2.0",
7175
"trailpack": "^1.0.1",
7276
"winston": "^2.1.1"

test/index.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,17 @@ describe('Trails', () => {
214214

215215
return eventPromise
216216
})
217+
it('should pass event parameters to callbacks added using `onceAny`', done => {
218+
const sent = { test: true }
219+
220+
app.onceAny('test', received => {
221+
assert.equal(received, sent)
222+
223+
return done()
224+
})
225+
226+
app.emit('test', sent)
227+
})
217228
})
218229
})
219230
})

0 commit comments

Comments
 (0)