semantic-switch

0.0.3 • Public • Published

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' );
    } );

Readme

Keywords

none

Package Sidebar

Install

npm i semantic-switch

Weekly Downloads

0

Version

0.0.3

License

BSD-2-Clause

Last publish

Collaborators

  • 4dr144n