# undo-redo-manager2

> undo redo simple

Latest version **1.0.4** (published 2021-11-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install undo-redo-manager2
pnpm add undo-redo-manager2
yarn add undo-redo-manager2
bun add undo-redo-manager2
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.4 |
| Published | 2021-11-18 |
| First published | 2021-11-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 3.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Mantou |
| Maintainers | h5ds |
| Keywords | undo, redo, history |

## Links

- npm: https://www.npmjs.com/package/undo-redo-manager2
- Homepage: https://github.com/mtsee/undo-redo-manager
- npm.io page: https://npm.io/package/undo-redo-manager2

## Recent versions

- 1.0.4 (latest) — 2021-11-18
- 1.0.3 — 2021-11-18
- 1.0.2 — 2021-11-16
- 1.0.1 — 2021-11-16
- 1.0.0 — 2021-11-16

## README

# undo/redo manager

undo redo manager simple for H5DS

[h5ds](https://www.h5ds.com)的undo/redo的记录操作,采用数组缓存数据

### [github](https://github.com/mtsee/undo-redo-manager)

### [example](https://h5ds-cdn.oss-cn-beijing.aliyuncs.com/www/redo_undo/index.html)

### [npm](https://www.npmjs.com/package/undo-redo-manager2)

# use

> npm i undo-redo-manager2 --save

```javascript
import UndoRedoManager from 'undo-redo-manager2';

const manager = new UndoRedoManager({
  limit: 10  // 设置最大记录10次，默认是50次
});

manager.add(1);
manager.add(2);
manager.add(3);
manager.add(4);

const num1 = manager.undo();
// 3

const num2 = manager.undo();
// 2

const num3 = manager.redo();
// 3

```

# API

方法&参数|说明|返回值
--:|--:|--
add(any)|添加记录|插入的值
undo()|撤销|撤销后的记录值
redo()|重做|重做后的记录值
destroy()|销毁|销毁后释放内存
current|getter|当前记录值
canUndo|getter|是否可执行撤销操作
canRedo|getter|是否可执行重做操作
count|getter|记录数量
stacks|getter|记录数据

---
_Source: https://npm.io/package/undo-redo-manager2 · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
