Skip to content

Instantly share code, notes, and snippets.

View satodaiki's full-sized avatar
:shipit:
Very happy.

satodai satodaiki

:shipit:
Very happy.
  • 東京
View GitHub Profile
@satodaiki
satodaiki / memento.js
Created March 24, 2021 14:28 — forked from jmgunn87/memento.js
js memento(undo redo)
function Memento(originalState) {
this.state = originalState;
this.stack = new Array(this.state);
this.stackIndex = 0;
}
Memento.prototype.undo = function () {
return this.stackIndex > 0 ?
this.state = this.stack[--this.stackIndex]: this.state;
};
Memento.prototype.save = function (state) {