1var SnapshotArray = function (length) {2this.snaps = [];3this.currentIndex = 0;4this.currentSnaps = [];5};67SnapshotArray.prototype.set = function (index, val) {8this.currentSnaps[index] = val;9};1011SnapshotArray.prototype.snap = function () {12this.snaps[this.currentIndex] = [...this.currentSnaps];1314return this.currentIndex++;15};1617SnapshotArray.prototype.get = function (index, snap_id) {18const res = this.snaps[snap_id];1920if (res[index] === undefined) return 0;2122return res[index];23};