my-idlers/node_modules/collect.js/dist/methods/replace.js
cp6 fd22b0bf58 V2 (Laravel re-make)
V2 (Laravel re-make)
2022-03-06 02:02:12 +11:00

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