This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function blob_to_buffer(blob, callback) { | |
const file_reader = new FileReader() | |
file_reader.addEventListener("loadend", event => { | |
if (file_reader.error) { | |
callback(file_reader.error) | |
} else { | |
callback(null, new Buffer(file_reader.result)) | |
} | |
}, false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// first setup our stacks of history states | |
// (const refers to the reference to the arrays, but they arrays themselves are mutable) | |
const undos = []; | |
const redos = []; | |
// undo and redo are symmetrical operations, so they *could* be factored to use an "undoOrRedo" / "stepHistory" function that takes two stacks as arguments, but it might be clearer as two functions | |
const undo = () => { | |
if (undos.length < 1) { return false; } |
OlderNewer