You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							28 lines
						
					
					
						
							609 B
						
					
					
				
			
		
		
	
	
							28 lines
						
					
					
						
							609 B
						
					
					
				| "use strict";
 | |
| Object.defineProperty(exports, "__esModule", { value: true });
 | |
| const events_1 = require("events");
 | |
| class Counter extends events_1.EventEmitter {
 | |
|     constructor() {
 | |
|         super();
 | |
|         this.value = 0;
 | |
|     }
 | |
|     increment() {
 | |
|         this.value++;
 | |
|     }
 | |
|     decrement() {
 | |
|         if (--this.value === 0) {
 | |
|             this.emit('zero');
 | |
|         }
 | |
|     }
 | |
|     isZero() {
 | |
|         return this.value === 0;
 | |
|     }
 | |
|     onceZero(fn) {
 | |
|         if (this.isZero()) {
 | |
|             return fn();
 | |
|         }
 | |
|         this.once('zero', fn);
 | |
|     }
 | |
| }
 | |
| exports.default = Counter;
 | |
| //# sourceMappingURL=counter.js.map
 |