import {Tags} from '../../util';
import {Counter} from '../counter';
import {Resettable} from '../resettable';
import {LocalSettable} from './settable';
export class LocalCounter extends LocalSettable<number> implements Counter<number>, Resettable {
constructor(name: string, tags: Tags = {}) {
super(name, tags);
this.set(0);
}
increment(value = 1, tags: Tags = {}): void {
const update = (this.raw || 0) + value;
this.set(update, tags);
}
reset(): void {
this.set(0);
}
get raw(): number {
return this._val.value || 0;
}
}
|