Use shorthand functions

closes #519
This commit is contained in:
Robert Sköld 2015-10-12 08:51:31 +02:00 committed by Jonathan Ong
parent a27781abb5
commit e900f0a44a
3 changed files with 22 additions and 22 deletions

View file

@ -24,7 +24,7 @@ const proto = module.exports = {
* @api public * @api public
*/ */
inspect: function(){ inspect() {
return this.toJSON(); return this.toJSON();
}, },
@ -40,7 +40,7 @@ const proto = module.exports = {
* @api public * @api public
*/ */
toJSON: function(){ toJSON() {
return { return {
request: this.request.toJSON(), request: this.request.toJSON(),
response: this.response.toJSON(), response: this.response.toJSON(),
@ -87,7 +87,7 @@ const proto = module.exports = {
* @api public * @api public
*/ */
throw: function(){ throw() {
throw createError.apply(null, arguments); throw createError.apply(null, arguments);
}, },
@ -98,7 +98,7 @@ const proto = module.exports = {
* @api private * @api private
*/ */
onerror: function(err){ onerror(err) {
// don't do anything if there is no error. // don't do anything if there is no error.
// this allows you to pass `this.onerror` // this allows you to pass `this.onerror`
// to node-style callbacks. // to node-style callbacks.

View file

@ -461,7 +461,7 @@ module.exports = {
* @api public * @api public
*/ */
accepts: function(){ accepts() {
return this.accept.types.apply(this.accept, arguments); return this.accept.types.apply(this.accept, arguments);
}, },
@ -478,7 +478,7 @@ module.exports = {
* @api public * @api public
*/ */
acceptsEncodings: function(){ acceptsEncodings() {
return this.accept.encodings.apply(this.accept, arguments); return this.accept.encodings.apply(this.accept, arguments);
}, },
@ -495,7 +495,7 @@ module.exports = {
* @api public * @api public
*/ */
acceptsCharsets: function(){ acceptsCharsets() {
return this.accept.charsets.apply(this.accept, arguments); return this.accept.charsets.apply(this.accept, arguments);
}, },
@ -512,7 +512,7 @@ module.exports = {
* @api public * @api public
*/ */
acceptsLanguages: function(){ acceptsLanguages() {
return this.accept.languages.apply(this.accept, arguments); return this.accept.languages.apply(this.accept, arguments);
}, },
@ -542,7 +542,7 @@ module.exports = {
* @api public * @api public
*/ */
is: function(types){ is(types) {
if (!types) return typeis(this.req); if (!types) return typeis(this.req);
if (!Array.isArray(types)) types = [].slice.call(arguments); if (!Array.isArray(types)) types = [].slice.call(arguments);
return typeis(this.req, types); return typeis(this.req, types);
@ -584,7 +584,7 @@ module.exports = {
* @api public * @api public
*/ */
get: function(field){ get(field) {
const req = this.req; const req = this.req;
switch (field = field.toLowerCase()) { switch (field = field.toLowerCase()) {
case 'referer': case 'referer':
@ -602,7 +602,7 @@ module.exports = {
* @api public * @api public
*/ */
inspect: function(){ inspect() {
if (!this.req) return; if (!this.req) return;
return this.toJSON(); return this.toJSON();
}, },
@ -614,7 +614,7 @@ module.exports = {
* @api public * @api public
*/ */
toJSON: function(){ toJSON() {
return { return {
method: this.method, method: this.method,
url: this.url, url: this.url,

View file

@ -228,7 +228,7 @@ module.exports = {
* @api public * @api public
*/ */
vary: function(field){ vary(field) {
vary(this.res, field); vary(this.res, field);
}, },
@ -251,7 +251,7 @@ module.exports = {
* @api public * @api public
*/ */
redirect: function(url, alt){ redirect(url, alt) {
// location // location
if ('back' == url) url = this.ctx.get('Referrer') || alt || '/'; if ('back' == url) url = this.ctx.get('Referrer') || alt || '/';
this.set('Location', url); this.set('Location', url);
@ -279,7 +279,7 @@ module.exports = {
* @api public * @api public
*/ */
attachment: function(filename){ attachment(filename) {
if (filename) this.type = extname(filename); if (filename) this.type = extname(filename);
this.set('Content-Disposition', contentDisposition(filename)); this.set('Content-Disposition', contentDisposition(filename));
}, },
@ -382,7 +382,7 @@ module.exports = {
* @api public * @api public
*/ */
is: function(types){ is(types) {
const type = this.type; const type = this.type;
if (!types) return type || false; if (!types) return type || false;
if (!Array.isArray(types)) types = [].slice.call(arguments); if (!Array.isArray(types)) types = [].slice.call(arguments);
@ -405,7 +405,7 @@ module.exports = {
* @api public * @api public
*/ */
get: function(field){ get(field) {
return this.header[field.toLowerCase()] || ''; return this.header[field.toLowerCase()] || '';
}, },
@ -424,7 +424,7 @@ module.exports = {
* @api public * @api public
*/ */
set: function(field, val){ set(field, val) {
if (2 == arguments.length) { if (2 == arguments.length) {
if (Array.isArray(val)) val = val.map(String); if (Array.isArray(val)) val = val.map(String);
else val = String(val); else val = String(val);
@ -450,7 +450,7 @@ module.exports = {
* @api public * @api public
*/ */
append: function(field, val){ append(field, val) {
const prev = this.get(field); const prev = this.get(field);
if (prev) { if (prev) {
@ -469,7 +469,7 @@ module.exports = {
* @api public * @api public
*/ */
remove: function(field){ remove(field) {
this.res.removeHeader(field); this.res.removeHeader(field);
}, },
@ -495,7 +495,7 @@ module.exports = {
* @api public * @api public
*/ */
inspect: function(){ inspect() {
if (!this.res) return; if (!this.res) return;
const o = this.toJSON(); const o = this.toJSON();
o.body = this.body; o.body = this.body;
@ -509,7 +509,7 @@ module.exports = {
* @api public * @api public
*/ */
toJSON: function(){ toJSON() {
return { return {
status: this.status, status: this.status,
message: this.message, message: this.message,