UNPKG

lost-sia

Version:

Single Image Annotation Tool

2 lines (1 loc) 719 B
class e{constructor(t=100){this.hist=[],this.pointer=0,this.maxElements=t}push(t,i="No description"){const s={entry:t,description:i};if(this.pointer!==0)for(;this.pointer!==0;)this.pointer--,this.hist.shift();this.hist.unshift(s),this.hist.length>this.maxElements&&this.hist.pop()}undo(){return this.pointer+1<this.hist.length?(this.pointer++,this.hist[this.pointer]):this.hist[this.hist.length-1]}undoMia(){return this.pointer+1<this.hist.length?(this.pointer++,this.hist[this.pointer-1]):this.hist[this.hist.length-1]}redo(){return this.pointer-1>=0?(this.pointer--,this.hist[this.pointer]):this.hist[0]}getHist(){return this.hist}clearHist(){this.hist=[]}isEmpty(){return this.hist.length===0}}export{e as default};