fd22b0bf58
V2 (Laravel re-make)
25 lines
545 B
JavaScript
Vendored
25 lines
545 B
JavaScript
Vendored
'use strict';
|
|
|
|
module.exports = function replace(items) {
|
|
if (!items) {
|
|
return this;
|
|
}
|
|
|
|
if (Array.isArray(items)) {
|
|
var _replaced = this.items.map(function (value, index) {
|
|
return items[index] || value;
|
|
});
|
|
|
|
return new this.constructor(_replaced);
|
|
}
|
|
|
|
if (items.constructor.name === 'Collection') {
|
|
var _replaced2 = Object.assign({}, this.items, items.all());
|
|
|
|
return new this.constructor(_replaced2);
|
|
}
|
|
|
|
var replaced = Object.assign({}, this.items, items);
|
|
|
|
return new this.constructor(replaced);
|
|
}; |