Last active
August 29, 2015 14:05
-
-
Save sergebat/4ae3e3cffe3d00fc9e65 to your computer and use it in GitHub Desktop.
MuteTrigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MuteTrigger { | |
private count: number = 0; | |
private inputSet = {}; | |
mute(reason: string) { | |
if (this.inputSet[reason]) { | |
return; | |
} | |
this.inputSet[reason] = true; | |
this.count++; | |
} | |
unmute(reason: string) { | |
if (!this.inputSet[reason]) { | |
return; | |
} | |
this.inputSet[reason] = false; | |
this.count--; | |
} | |
isMuted(): boolean { | |
return this.count > 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment