22 lines
387 B
JavaScript
22 lines
387 B
JavaScript
var RollingCounter;
|
|
|
|
RollingCounter = (function() {
|
|
function RollingCounter(max, min) {
|
|
this.max = max;
|
|
this.min = min != null ? min : 1;
|
|
this.now = this.min;
|
|
}
|
|
|
|
RollingCounter.prototype.next = function() {
|
|
if (!(this.now < this.max)) {
|
|
this.now = this.min;
|
|
}
|
|
return ++this.now;
|
|
};
|
|
|
|
return RollingCounter;
|
|
|
|
})();
|
|
|
|
module.exports = RollingCounter;
|