Created
October 14, 2012 05:05
-
-
Save samarpanda/3887435 to your computer and use it in GitHub Desktop.
Counter
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
var counter = (function(){ | |
var i = 0, | |
timer = {}; | |
timer.get = function(){ | |
return i; | |
}; | |
timer.set = function(value){ | |
i = value; | |
}; | |
timer.increment = function(){ | |
++i; | |
}; | |
timer.decrement = function(){ | |
i = (i === 1 ? 0 : (i-1)); | |
}; | |
return timer; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment