Created
March 6, 2022 19:18
-
-
Save scarletquasar/9245eb9b6dd5e123e4c04604ccd4f630 to your computer and use it in GitHub Desktop.
Random thoughts about switch case alternatives...
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
function shift(value) { | |
const internal = { | |
option: (target, callback) => { | |
switch(typeof target) { | |
case "object": | |
target.includes(value) && callback(target[target.indexOf(value)]) | |
break; | |
default: | |
value === target && callback(target) | |
break; | |
} | |
return shift(value); | |
} | |
} | |
return internal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment