diff --git a/docs/guide.md b/docs/guide.md index 0c443a5..415e271 100644 --- a/docs/guide.md +++ b/docs/guide.md @@ -13,7 +13,7 @@ `X-Response-Time` header field the middleware would look like the following: ```js -function *responseTime(next){ +function *responseTime(next) { var start = new Date; yield next; var ms = new Date - start; @@ -88,7 +88,7 @@ app.use(function *response(){ and returns the middleware itself: ```js -function logger(format){ +function logger(format) { format = format || ':method ":url"'; return function *(next){ @@ -111,7 +111,7 @@ app.use(logger(':method :url')); Naming middleware is optional, however it's useful for debugging purposes to assign a name. ```js -function logger(format){ +function logger(format) { return function *logger(next){ } @@ -123,7 +123,7 @@ function logger(format){ Sometimes you want to "compose" multiple middleware into a single middleware for easy re-use or exporting. To do so, you may chain them together with `.call(this, next)`s, then return another function that yields the chain. ```js -function *random(next){ +function *random(next) { if ('/random' == this.path) { this.body = Math.floor(Math.random()*10); } else { @@ -139,7 +139,7 @@ function *backwords(next) { } } -function *pi(next){ +function *pi(next) { if ('/pi' == this.path) { this.body = String(Math.PI); } else { diff --git a/lib/application.js b/lib/application.js index 80ce7f4..fbf3e87 100644 --- a/lib/application.js +++ b/lib/application.js @@ -162,7 +162,7 @@ app.onerror = function(err){ * Response middleware. */ -function *respond(next){ +function *respond(next) { if (this.app.poweredBy) this.set('X-Powered-By', 'koa'); yield *next; @@ -217,4 +217,4 @@ function *respond(next){ this.length = Buffer.byteLength(body); if (head) return res.end(); res.end(body); -} \ No newline at end of file +} diff --git a/lib/request.js b/lib/request.js index ec1c7a2..98a6b85 100644 --- a/lib/request.js +++ b/lib/request.js @@ -486,7 +486,7 @@ module.exports = { * @api public */ - acceptsLanguages: function() { + acceptsLanguages: function(){ return this.accept.languages.apply(this.accept, arguments); }, diff --git a/lib/response.js b/lib/response.js index c5a314d..c3df5e9 100644 --- a/lib/response.js +++ b/lib/response.js @@ -257,7 +257,7 @@ module.exports = { * @api public */ - set type(type){ + set type(type) { if (!~type.indexOf('/')) { type = mime.lookup(type); var cs = mime.charsets.lookup(type); diff --git a/test/application.js b/test/application.js index 4e0a297..4b0890d 100644 --- a/test/application.js +++ b/test/application.js @@ -33,7 +33,7 @@ describe('app', function(){ this.status = 204; // throw if .writeHead or .end is called this.res.writeHead = - this.res.end = function () { + this.res.end = function(){ throw new Error('response sent'); }; }) @@ -125,7 +125,7 @@ describe('app.respond', function(){ this.respond = false; var res = this.res; - setImmediate(function () { + setImmediate(function(){ res.setHeader('Content-Type', 'text/plain'); res.end('lol'); }) @@ -229,14 +229,14 @@ describe('app.respond', function(){ res.setHeader("Content-Type", "text/html") res.status = 200; res.write('Hello'); - setTimeout(function () { + setTimeout(function(){ res.end("Goodbye") }, 0); }); var errorCaught = false; - app.on('error', function (err) { + app.on('error', function(err){ errorCaught = err; }); @@ -260,7 +260,7 @@ describe('app.respond', function(){ res.setHeader("Content-Type", "text/html") res.status = 200; res.write('Hello'); - setTimeout(function () { + setTimeout(function(){ res.end("Goodbye") }, 0); }); @@ -306,7 +306,7 @@ describe('app.respond', function(){ .get('/') .expect(204) .expect('') - .end(function (err, res) { + .end(function(err, res){ if (err) return done(err); res.header.should.not.have.property('content-type'); @@ -329,7 +329,7 @@ describe('app.respond', function(){ .get('/') .expect(205) .expect('') - .end(function (err, res) { + .end(function(err, res){ if (err) return done(err); res.header.should.not.have.property('content-type'); @@ -352,7 +352,7 @@ describe('app.respond', function(){ .get('/') .expect(304) .expect('') - .end(function (err, res) { + .end(function(err, res){ if (err) return done(err); res.header.should.not.have.property('content-type'); @@ -629,4 +629,4 @@ describe('app.response', function(){ .get('/') .expect(204, done); }) -}) \ No newline at end of file +}) diff --git a/test/response/redirect.js b/test/response/redirect.js index f1f3d5c..f93489d 100644 --- a/test/response/redirect.js +++ b/test/response/redirect.js @@ -99,4 +99,4 @@ function escape(html) { .replace(/"/g, '"') .replace(//g, '>'); -} \ No newline at end of file +} diff --git a/test/response/status.js b/test/response/status.js index c01aa51..695f684 100644 --- a/test/response/status.js +++ b/test/response/status.js @@ -65,4 +65,4 @@ describe('res.status=', function(){ describe('when 304', function(){ strip(304); }) -}) \ No newline at end of file +})