From 696d55d73b2019bbfc06522fd14a31f5cdbdf069 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 10 Jun 2014 14:33:13 -0700 Subject: [PATCH] refactor res.status= --- lib/response.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/lib/response.js b/lib/response.js index 000e239..41a9b8c 100644 --- a/lib/response.js +++ b/lib/response.js @@ -10,10 +10,10 @@ var escape = require('escape-html'); var onfinish = require('finished'); var status = require('statuses'); var destroy = require('dethroy'); +var assert = require('assert'); var http = require('http'); var path = require('path'); var vary = require('vary'); -var assert = require('assert'); var basename = path.basename; var extname = path.extname; @@ -66,12 +66,10 @@ module.exports = { */ set status(code) { - assert(typeof code === 'number', 'status code must be a number'); - if(!http.STATUS_CODES[code]) throw new Error('invalid status code: ' + code); - + assert('number' == typeof code, 'status code must be a number'); + assert(http.STATUS_CODES[code], 'invalid status code: ' + code); this._explicitStatus = true; this.res.statusCode = code; - if (this.body && status.empty[code]) this.body = null; },