Last active
January 24, 2017 09:04
-
-
Save electerious/eec8958ca0fd1ee97c1d to your computer and use it in GitHub Desktop.
Toggle between true and false
This file contains hidden or 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
const toggler = (initState) => { | |
initState = initState!==false | |
let state = initState | |
return { | |
get : () => state, | |
reset : () => state = initState, | |
toggle : () => state = !state, | |
on : () => state = true, | |
off : () => state = false | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: