You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

25 lines
545 B

'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);
};