Skip to content

TheInsomnolent/AsyncLogic

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsyncLogic

An Asynchronous framework for logical operands in NodeJS.

See full API docs here

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:

  1. An AsyncLogic instance
  2. At least one async operator such as AsyncOr
  3. 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()

About

An Asynchronous framework for logical operands in NodeJS

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published