fd22b0bf58
V2 (Laravel re-make)
21 lines
518 B
JavaScript
Vendored
21 lines
518 B
JavaScript
Vendored
'use strict';
|
|
|
|
module.exports = function merge(value) {
|
|
var arrayOrObject = value;
|
|
|
|
if (typeof arrayOrObject === 'string') {
|
|
arrayOrObject = [arrayOrObject];
|
|
}
|
|
|
|
if (Array.isArray(this.items) && Array.isArray(arrayOrObject)) {
|
|
return new this.constructor(this.items.concat(arrayOrObject));
|
|
}
|
|
|
|
var collection = JSON.parse(JSON.stringify(this.items));
|
|
|
|
Object.keys(arrayOrObject).forEach(function (key) {
|
|
collection[key] = arrayOrObject[key];
|
|
});
|
|
|
|
return new this.constructor(collection);
|
|
}; |