in experimental/todomvc-localstorage/src/store.js [115:141]
Store.prototype.save = function (updateData, callback, id) {
var todos = this.storage.getData();
callback = callback || function () {};
// If an ID was actually given, find the item and update each property
if (id) {
for (var i = 0; i < todos.length; i++) {
if (todos[i].id === id) {
for (var key in updateData)
todos[i][key] = updateData[key];
break;
}
}
this.storage.setData(todos);
callback.call(this, todos);
} else {
// Generate an ID
updateData.id = ID++;
todos.push(updateData);
this.storage.setData(todos);
callback.call(this, [updateData]);
}
};