Skip to content

ricksteam/uredo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

uredo

A straightforward undo/redo stack library.

Build Status Badge

Installing

You can install this package from the public npm repository:

npm

npm install uredo

yarn

yarn add uredo

Usage

node

const CommandExecutor = require("uredo")

webpack

import CommandExecutor from "uredo

API

Table of Contents

CommandExecutor

Class that implements an undo/redo stack. To use, pass an object to the do function that has at least two paramaterless functions, do() and undo(). If the object have a member variable includeWithPrevious set to true, the undo and redo stack will treat command as an incremental command that should be done/redone with the previous command.

do

Execute a command and place it on the undo stack. Also clears the redo stack()

Parameters

  • command object An object with two parameterless functions, do() and undo()

undo

Pop the last item on the undo stack, call its undo function, and push it on the redo stack. Throws an error if there is no undo stack. If the last object was the includeWithPrevious flag set, it will undo the previous command until the undo stack is empty or a command is found without the includeWithPrevious or a command with that flag set to false.

redo

Pop the last item off the redo stack, call its do() functions, and push it on the undo stack. Throws an error if there is no redo stack. If the following object(s) have the includeWithPrevious flag set, it will redo the following commands until the redo stack is empty or a command is found with the includeWithPrevious flag or a command with that flag set to false.

canUndo

Check to see if the undo stack has at least one object.

canRedo

Check to see if the redo stack has at least one object.

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • PurpleBooth for the template of this page.

About

A command object-based undo redo library.

Resources

License

Stars

Watchers

Forks

Packages

No packages published