core-graphics
Version:
A core library for creating shape-based graphic editors
36 lines (35 loc) • 969 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getUndoEvent = getUndoEvent;
exports.getRedoEvent = getRedoEvent;
function getUndoEvent(history, author) {
if (history.length === 0) {
return null;
}
for (var i = history.length - 1; i >= 0; i--) {
var ev = history[i];
if (ev.author === author && ev.applied === true) {
return ev;
}
}
return null;
}
function getRedoEvent(history, author) {
if (history.length === 0) {
return null;
}
var lastUnappliedAuthorEvent = null;
for (var i = history.length - 1; i >= 0; i--) {
var ev = history[i];
if (ev.author === author && ev.applied === false) {
lastUnappliedAuthorEvent = ev;
continue;
}
if (ev.author === author && ev.applied === true) {
return lastUnappliedAuthorEvent;
}
}
return lastUnappliedAuthorEvent;
}