# Undoo
Undo/redo manager

<a href="https://travis-ci.org/fabioricali/undoo" target="_blank"><img src="https://travis-ci.org/fabioricali/undoo.svg?branch=master" title="Build Status"/></a>
<a href="https://opensource.org/licenses/MIT" target="_blank"><img src="https://img.shields.io/badge/License-MIT-yellow.svg" title="License: MIT"/></a>

## Installation

### Node.js
```
npm install undoo --save
```

### Browser

#### Local
```html
<script src="node_modules/undoo/dist/undoo.min.js"></script>
```

#### CDN unpkg
```html
<script src="https://unpkg.com/undoo/dist/undoo.min.js"></script>
```

## Example

```javascript
const Undoo = require('undoo');

const myHistory = new Undoo();

myHistory
    .save('one')
    .save('two')
    .save('three')
    .save('four');

myHistory.undo((item)=>{
    console.log(item); //=> three
});

myHistory.current(); //=> three

myHistory.redo((item)=>{
    console.log(item); //=> four
});

```

## Use provider

```javascript
const Undoo = require('undoo');

const myHistory = new Undoo({
    provider: () => document.getElementById('myTextArea').value
});

myHistory.save();

```

## API

{{>main}}

## Changelog
You can view the changelog <a target="_blank" href="https://github.com/fabioricali/undoo/blob/master/CHANGELOG.md">here</a>

## License
Undoo is open-sourced software licensed under the <a target="_blank" href="http://opensource.org/licenses/MIT">MIT license</a>

## Author
<a target="_blank" href="http://rica.li">Fabio Ricali</a>
