From 255a39b876beff4546832c6c70901893dd1fc4e4 Mon Sep 17 00:00:00 2001 From: TJ Holowaychuk Date: Tue, 27 Jan 2015 10:14:57 -0800 Subject: [PATCH] refactor res.append() OCDOCDOCD --- lib/response.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/response.js b/lib/response.js index 3ea3727..844c137 100644 --- a/lib/response.js +++ b/lib/response.js @@ -440,15 +440,14 @@ module.exports = { append: function(field, val){ var prev = this.get(field); - var value = val; + if (prev) { - // concat the new and prev vals - value = Array.isArray(prev) ? prev.concat(val) - : Array.isArray(val) ? [prev].concat(val) - : [prev, val]; + val = Array.isArray(prev) + ? prev.concat(val) + : [prev].concat(val); } - return this.set(field, value); + return this.set(field, val); }, /**