Skip to content

Instantly share code, notes, and snippets.

@hden
Created July 16, 2015 06:39
Show Gist options
  • Save hden/5b5cdff072fbbe79d08d to your computer and use it in GitHub Desktop.
Save hden/5b5cdff072fbbe79d08d to your computer and use it in GitHub Desktop.
functional FSM
// turnstile.js
let lock, open
lock = (action) => {
if (action === 'coin') {
return open
} else {
return lock
}
}
open = (action) => {
if (action === 'push') {
return lock
} else {
return open
}
}
export default lock
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment