Skip to content

a javascript parser for a more simple and easy to use switch-case

License

Notifications You must be signed in to change notification settings

TheBlindHawk/JS-switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JS-switch

A very simple and easy to use switch-case parser

examples

switch (animal) {
  'dog', 'puppy': console.log('barks');
  'cat', 'kitten': console.log('meows');
  'wolf': console.log('howls');
  default: console.log('silence');
}

The break is added as a default. Here is an example if you don't want to break (example taken from MDN):

switch (foo) {
  case 0:> output += "So ";
  case 1:> output += "What Is";
  case 2:> output += "Your ";
  case 3:> output += "Name";
  case 4: console.log(output+"?");
  default: console.log("Please pick a number from 0 to 5!");
}

Outro

Here is a post explaining why I decided to try and write this code. zenn.dev/theblindhawk Please feel free to open pull requests/issues to improve the parser, any help would be appreciated!

About

a javascript parser for a more simple and easy to use switch-case

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages