Skip to content

Instantly share code, notes, and snippets.

@scarletquasar
Created March 6, 2022 19:18
Show Gist options
  • Save scarletquasar/9245eb9b6dd5e123e4c04604ccd4f630 to your computer and use it in GitHub Desktop.
Save scarletquasar/9245eb9b6dd5e123e4c04604ccd4f630 to your computer and use it in GitHub Desktop.
Random thoughts about switch case alternatives...
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