Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (record === data) {
return this;
}
const newId = getModelId(record);
const type = getModelType(record);
const viewIndexes = this.views.map((view) => view.list.indexOf(record));
if (this.__collection) {
this.__collection.removeOne(type, newId);
this.__collection.add(data);
}
updateModel(data, modelToJSON(record));
updateModelId(data, newId);
this.views.forEach((view, index) => {
if (viewIndexes[index] !== -1) {
view.list[viewIndexes[index]] = data;
}
});
return new Response(this.__response, this.__collection, this.__options, data);
}