# booking/11.9/vendors/imask/esm/controls/input-history.js

Booking Calendar, version 11.9. 37 lines.

- Page: https://pluginprobe.com/plugins/booking/11.9/code/vendors/imask/esm/controls/input-history.js
- Raw: https://pluginprobe.com/plugins/booking/11.9/raw/vendors/imask/esm/controls/input-history.js
- Modified: 2025-07-25T07:28:16+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/booking/11.9/code/vendors/imask/esm/controls/input-history.js#L10-L20`.

```javascript
class InputHistory {
  constructor() {
    this.states = [];
    this.currentIndex = 0;
  }
  get currentState() {
    return this.states[this.currentIndex];
  }
  get isEmpty() {
    return this.states.length === 0;
  }
  push(state) {
    // if current index points before the last element then remove the future
    if (this.currentIndex < this.states.length - 1) this.states.length = this.currentIndex + 1;
    this.states.push(state);
    if (this.states.length > InputHistory.MAX_LENGTH) this.states.shift();
    this.currentIndex = this.states.length - 1;
  }
  go(steps) {
    this.currentIndex = Math.min(Math.max(this.currentIndex + steps, 0), this.states.length - 1);
    return this.currentState;
  }
  undo() {
    return this.go(-1);
  }
  redo() {
    return this.go(+1);
  }
  clear() {
    this.states.length = 0;
    this.currentIndex = 0;
  }
}
InputHistory.MAX_LENGTH = 100;

export { InputHistory as default };

```
