# ctrlz

> JSON Edit History Manager for Undo / Redo Functionality

Latest version **0.2.2** (published 2025-12-13) · MIT license · 0 weekly downloads

## Install

```sh
npm install ctrlz
pnpm add ctrlz
yarn add ctrlz
bun add ctrlz
```

## Health

**Score 45/100 (D)** — status: stable.

Positive: no vulnerabilities.

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

## Facts

| | |
|---|---|
| Version | 0.2.2 |
| Published | 2025-12-13 |
| First published | 2020-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.12.6 |
| Dependencies | 0 |
| Unpacked size | 45.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | zbryikt |
| Maintainers | tkirby |

## Links

- npm: https://www.npmjs.com/package/ctrlz
- Repository: https://github.com/plotdb/ctrlz
- Issues: https://github.com/plotdb/ctrlz/issues
- npm.io page: https://npm.io/package/ctrlz

## Recent versions

- 0.2.2 (latest) — 2025-12-13
- 0.2.1 — 2025-12-13
- 0.2.0 — 2022-01-22
- 0.1.0 — 2020-11-26

## README

# ctrlz

JSON Edit History Manager for Undo / Redo Functionality, powered by operational transform. Keep state and support undo for anything that can be expressed / stored by JSON!


# Install

include required js file:


    <script src="path-to-your-ctrlz-bundle.js"></script>


ctrlz uses `@plotdb/json0` as a dependency. `ctrlz.bundle.min.js` already includes it but for a separate file, use `ctrlz.mins.js` instead, and include `@plotdb/json0` separately downloaded from [its repo](https://github.com/plotdb/json0).


## Usage

    /* init directly in constructor */
    mananger = new ctrlz({obj: obj});

    /* or alternatively, reset anytime after initialized */
    manager.reset({obj: obj});

    /* when obj is updated */
    manager.update(obj);

    /* if you have ot to apply: */ 
    manager.apply({op: op});

    /* undo, return a undo-ed object */
    ret = manager.undo();

    /* redo, return a redo-ed object */
    ret = manager.redo();

    /* clean history */
    mananger.clear();



## License

MIT.

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