AsyncLogic
An Asynchronous framework for logical operands in NodeJS.
Installing
To install AsyncLogic simply run:
$ yarn add @me3d/async-logicor
$ npm install @me3d/async-logicUsing AsyncLogic
Importing
AsyncLogic's base components can be imported into your Node project using:
const { AsyncLogic, AsyncOr, AsyncAnd, AsyncNot } = require('@me3d/async-logic')Setting up a basic AsyncLogic environment
A basic async environment can be constructed with:
- An
AsyncLogicinstance - At least one async operator such as
AsyncOr - At least two async input functions to evaluate
const result = await new AsyncLogic( new AsyncOr( asyncFunctionOne, asyncFunctionTwo ) ).compute()
Multi-input operators
Operators can support an arbitrary number of inputs.
const result = await new AsyncLogic(
new AsyncAnd(
asyncFunctionOne,
asyncFunctionTwo,
asyncFunctionThree,
asyncFunctionFour,
asyncFunctionFive
)
).compute()Nesting operators
Operators can easily be nested as follows:
const result = await new AsyncLogic(
new AsyncAnd(
asyncFunctionOne,
new AsyncOr(
asyncFunctionTwo,
asyncFunctionThree
)
)
).compute()