From 202bfe8385f45fd689dcf34b283c6aa53213ddb1 Mon Sep 17 00:00:00 2001 From: Feross Aboukhadijeh Date: Thu, 5 Jun 2014 23:40:13 -0700 Subject: [PATCH] add server.listen(port, onlistening) shorthand --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 390dc2f..35fed7c 100644 --- a/index.js +++ b/index.js @@ -519,10 +519,14 @@ function Server (opts) { } } -Server.prototype.listen = function (port) { +Server.prototype.listen = function (port, onlistening) { var self = this var tasks = [] + if (onlistening) { + self.once('listening', onlistening) + } + self._httpServer && tasks.push(function (cb) { self._httpServer.listen(port, cb) })