class Table { updateCells(row, col, values) { // check if we don't need to add new columns to accomodate // incoming row cells const columns = this.adjustColumns(col, values) const rows = [] let i = row let lastRow = this.rowIndex.lastKey for (let value of values) { let entry if (i < this.rowIndex.length) { // update existing row, starting from given column entry = new Entry(this.rowIndex.entries[i].key, value) } else { // we went over existing rows // append new rows at the end of the table let rowKey = generateKey(this.hashId, lastRow, MAX_KEY) entry = new Entry(rowKey, value) lastRow = rowKey } rows.push(entry) i++ } const update = { timestamp: this.incVersion(), upsertRows: { columns, rows } } this.apply(update) this.onUpdate(update) } } class Table { applyUpsertRows(columns, entries,…