Have ideas to improve npm?Join in the discussion! »

    bexp

    1.0.2 • Public • Published

    Boolean Expression Parser (bexp)

    $ npm install bexp
    const BexpParser = require("bexp");
     
    bexpParser = new BexpParser("a and b or c but !d");
    BexpParser.test("a")
    BexpParser.test(["a","b"])

    Supported expressions example

    • a and b or c but !d
    • a And b Or c But !d
    • a AND b OR c BUT !d
    • a + b OR c -d
    • a + b || c -d
    • a - b
    • a && b || c !d
    • a && b || c !d

    Note:

    • when operand is not given before not then it is considered as AND
    • but is an alias of and.

    Boolean Expressions

    const BexpParser = require("bexp");
     
    bexpParser = new BexpParser();
    BexpParser.evaluate("True and false or true but !N")

    Supported expressions example

    • True and false or true but !N
    • True And false Or true But !N
    • True AND false OR true BUT not N
    • True + false OR true -N
    • True + false || true -N
    • Yes && false || true !N
    • Y && false || true !N

    Note:

    • when operand is not given before not then it is considered as AND
    • but is an alias of and.

    Applications

    Use it to evaluate which functional test has to be run when tag expression is given

    • @focus
    • @All but not @Ignore

    Or to build advanced mongodb search queries

    • (nodejs or reactjs or angularjs )
    • !java
    • (sql or mongodb) and (java or nodejs)

    Install

    npm i bexp

    DownloadsWeekly Downloads

    4

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    7.26 kB

    Total Files

    4

    Last publish

    Collaborators

    • avatar