UNPKG

deth

Version:

Ethereum node focused on Developer Experience

28 lines (27 loc) 530 B
export class CheckpointMap { constructor(state = {}) { this.state = state; this.checkpoints = []; } checkpoint() { this.checkpoints.push(this.state); } revert() { this.state = this.checkpoints.pop(); } commit() { this.checkpoints.pop(); } get(k) { return this.state[k]; } set(k, v) { this.state = { ...this.state, [k]: v, }; } copy() { return new CheckpointMap(this.state); } }