refactor res.append()

OCDOCDOCD
This commit is contained in:
TJ Holowaychuk 2015-01-27 10:14:57 -08:00
parent 8ac26b1d77
commit 255a39b876

View file

@ -440,15 +440,14 @@ module.exports = {
append: function(field, val){ append: function(field, val){
var prev = this.get(field); var prev = this.get(field);
var value = val;
if (prev) { if (prev) {
// concat the new and prev vals val = Array.isArray(prev)
value = Array.isArray(prev) ? prev.concat(val) ? prev.concat(val)
: Array.isArray(val) ? [prev].concat(val) : [prev].concat(val);
: [prev, val];
} }
return this.set(field, value); return this.set(field, val);
}, },
/** /**