@me3d/async-logic
v0.1.2
Published
An Asynchronous framework for logical operands in NodeJS
Downloads
8
Readme
AsyncLogic
An Asynchronous framework for logical operands in NodeJS.
Installing
To install AsyncLogic
simply run:
$ yarn add @me3d/async-logic
or
$ npm install @me3d/async-logic
Using 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
AsyncLogic
instance - 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()