1.1.2 • Published 5 years ago

@cuties/if-else v1.1.2

Weekly downloads
5
License
MIT
Repository
github
Last release
5 years ago

cutie-if-else

NPM Version Build Status codecov

Cutie extension for work with if-else statements. It's based on the Async Tree Pattern.

Examples

You can find examples of using this library in the test directory.

Install

npm install @cuties/if-else

Run test

npm test

Run build

npm run build

Usage

const {
  If, ElseIf, Else
} = require('@cuties/if-else');

new If(
 asyncTreeThatRepresentsBooleanStatement, asyncTreeThatIsBeingInvokedIfFirstArgumentIsTrue,   
 new ElseIf(
   anotherAsyncTreeThatRepresentsBooleanStatement, 
   anotherAsyncTreeThatIsBeingInvokedIfFirstArgumentIsTrue,
   new ElseIf(..., 
    new Else(otherwiseThisAsyncTreeIsBeingInvoked)
   )
 )
).call();
Async ObjectParameters(description)Representation result
Ifstatement, action, next(ElseIf or Else)boolean value of statement
IfNotstatement, action, next(ElseIf or Else)boolean value of !statement
ElseIfstatement, action, next(ElseIf or Else)boolean value of statement
Elseactiontrue
And...statementsstatements.every(s => s)
Or...statementsstatements.some(s => s)
Not...statementsstatements.map(s => !s)