Skip to content

Instantly share code, notes, and snippets.

@naush
Created August 14, 2020 01:51
Show Gist options
  • Save naush/3f5c2d191c34a71b4acbf41b5af837db to your computer and use it in GitHub Desktop.
Save naush/3f5c2d191c34a71b4acbf41b5af837db to your computer and use it in GitHub Desktop.
enum WishState {
PENDING = 1,
STARTED = 2,
FULFILLED = 3,
};
const forward = (state: WishState) => {
switch (state) {
case WishState.PENDING:
return WishState.STARTED;
case WishState.STARTED:
return WishState.FULFILLED;
default:
return WishState.PENDING;
}
}
const backward = (state: WishState) => {
switch (state) {
case WishState.FULFILLED:
return WishState.STARTED;
case WishState.STARTED:
return WishState.PENDING;
default:
return WishState.PENDING;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment