cutie-if-else
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 Object | Parameters(description) | Representation result |
---|---|---|
If |
statement, action, next(ElseIf or Else) |
boolean value of statement
|
IfNot |
statement, action, next(ElseIf or Else) |
boolean value of !statement
|
ElseIf |
statement, action, next(ElseIf or Else) |
boolean value of statement
|
Else |
action |
true |
And |
...statements |
statements.every(s => s) |
Or |
...statements |
statements.some(s => s) |
Not |
...statements |
statements.map(s => !s) |