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