text: // import helper from '../helper';
  
  export default class History {
    constructor() {
      this.undoItems = [];
      this.redoItems = [];
    }
  
    add(data) {
      this.undoItems.push(JSON.stringify(data));
      this.redoItems = [];
      //console.log("histry add");
    }
  
    canUndo() {
      return this.undoItems.length > 0;
    }
  
    canRedo() {
      return this.redoItems.length > 0;
    }
  
    undo(currentd, cb) {
      const { undoItems, redoItems } = this;
      if (this.canUndo()) {
        redoItems.push(JSON.stringify(currentd));
        cb(JSON.parse(undoItems.pop()));
      }
    }
  
    redo(currentd, cb) {
      const { undoItems, redoItems } = this;
      if (this.canRedo()) {
        undoItems.push(JSON.stringify(currentd));
        cb(JSON.parse(redoItems.pop()));
      }
    }
  }
  