UNPKG

@gsretail.com/gui-core

Version:

A skeleton to create your own React component library using Rollup, TypeScript, Sass and Storybook

2 lines (1 loc) 592 B
class t{static MAX_LENGTH=100;states=[];currentIndex=0;get currentState(){return this.states[this.currentIndex]}get isEmpty(){return 0===this.states.length}push(s){this.currentIndex<this.states.length-1&&(this.states.length=this.currentIndex+1),this.states.push(s),this.states.length>t.MAX_LENGTH&&this.states.shift(),this.currentIndex=this.states.length-1}go(t){return this.currentIndex=Math.min(Math.max(this.currentIndex+t,0),this.states.length-1),this.currentState}undo(){return this.go(-1)}redo(){return this.go(1)}clear(){this.states.length=0,this.currentIndex=0}}export{t as default};