edit-history
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

edit-history

npm NPM npm bundle size

Manage your undo/redo operations with ease!

Highlights

  • Supports TypeScript!
  • Supports Node and browser
  • Includes full JSDoc documentation
  • Very lightweight!
  • Contains tests

Installation

NodeJS

npm install edit-history --save

Browser

Import the script:

<script src="https://joker876.github.io/edit-history/edit-history.min.js">

And import the class from a global object:

new EditHistory(/* capacity */);

Usage

import EditHistory from 'edit-history';

Constructor

new EditHistory<T = any>(capacity: number);

EditHistory constructor takes the history's maximum capacity as its only argument. Capacity is optional, and defaults to 100.

The type of the elements can also be specified explicitly. The default type is any.

const history = new EditHistory(50);
// or with specified type
const history = new EditHistory<number>(50);

Members

  • size - the amount of past changes in the history (changes that can be undone).
  • undoAmount - alias of size.
  • redoAmount - the amount of future changes in the history (changes that can be redone).
  • capacity - the maximum number of elements that can be stored in the history. Exceeding this value will cause the elements to be overwritten when pushed.

Package Sidebar

Install

npm i edit-history

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

118 kB

Total Files

7

Last publish

Collaborators

  • joker876