refactor res.append()

OCDOCDOCD
master
TJ Holowaychuk 2015-01-27 10:14:57 -08:00
parent 8ac26b1d77
commit 255a39b876
1 changed files with 5 additions and 6 deletions

View File

@ -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);
},
/**