refactor res.append()
OCDOCDOCD
This commit is contained in:
parent
8ac26b1d77
commit
255a39b876
1 changed files with 5 additions and 6 deletions
|
@ -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);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue