Skip to content

adriaan-pelzer/node-semanticSwitch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SemanticSwitch

the switch statement, reimagined, semantically

acts as a drop-in replacement for the switch statement.

idea & implementation pattern proposed by Mat Carey

Install like this:

npm install semantic-switch

Use like this:

var SemanticSwitch = require ( 'semantic-switch' ).SemanticSwitch;

new SemanticSwitch ( true )
    .CASE ( false, function () {
        console.log ( 'This will not be executed' );
    } )
    .CASE ( true, function () {
        console.log ( 'This will be executed' );
    } )
    .DEFAULT ( function () {
        console.log ( 'This will only be executed if none of the predicates match' );
    } );

About

Semantic switch statement for node.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published