npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@brixx/decision-script

v1.1.0

Published

A free JavaScript decision table and rules engine for Web and Node.js Applications with full integration into HTML without coding.

Downloads

40

Readme

Brixx-Decision-Script

Decisions are the most important part of programming

Brixx-Decision-Script is a free JavaScript library for rule-based decision systems. With our Brixx-Decision-Script, the programming can be reduced to a minimum and for adjustments or extensions via rules, for example with a decision table, it can be replaced by a technical configuration (low-code development). Fast integration into any HTML document is possible, especially with the integrated Brixx-Script (smarte web components) as Brixx HTML elements or as Brixx script components in JavaScript applications and frameworks and also support JavaScript environments such as Node.js® (cross-platform JavaScript runtime environment). Rules can be easily managed in an external decision table definition file with the decision model notation (DMN). No programming tasks or complicated deployments are required for changes or adjustments and basic configurations from a decision table definition file can also be expanded with Brixx-Decision-Script HTML elements.

Why the rule engine for JavaScript?

We have decided to publish Brixx-Decision-Script as a decision table and rule engine for JavaScript. As a result, Brixx-Decision-Script can be used in common frameworks, development environments, programming languages and platforms as a web application or web service for low-code development without a special platform. In addition, Brixx-Decision-Script enables direct integration into an HTML document, which makes it special. This also gives non-programmers the opportunity to design dynamic websites. Ask about integration into your applications, whether Python, Java, as a RESTful API or as a Docker solution.

Usage

Web

Brixx web component in the Brixx script component file brixx-check-age.js

// Check decision table callback function (optional)
const checkDecisionTable = (output) => {
    console.log("Output:", output);
}

// Create a Brixx default element
Brixx.element = (
    <div>
        <p>HTML element &lt;brixx-check-age&gt; created with Brixx-Script.</p>
        <DecisionTable>
            <ul>
                <li>Baby (0 years old) - <i>It's still a baby!</i></li>
                <li>Preschool (under 5 years old) - <i>Unfortunately too young!</i></li>
                <li>Kids (under 13 years old) - <i>https://www.youtube.com/kids/</i></li>
                <li>Teens (13 years or older) - <i>https://www.youtube.com/</i></li>
            </ul>
            <Input name={"age"} type={"number"}>
                <div>Please enter age</div>
                <Field />
            </Input>
            <Output name={"info"}>
                <Field readonly />
            </Output>
            <Output name={"url"}>
                <Link />
            </Output>
            <Rule age={""} priority={30} info={"Please enter a valid age!"} url={"https://github.com/BietSoft/brixx.docs/"} />
            <Rule age={"0"} priority={40} info={"It's is still a baby!"} />
            <Rule age={"< 5"} priority={20} info={"Unfortunately too young!"} />
            <Rule age={">= 13"} url={"https://www.youtube.com/"} />
            <Rule age={"< 13"} priority={10} info={"Internet Safety for Kids"} url={"https://www.youtube.com/kids/"} />
            <Check button label={"Check age"} action={checkDecisionTable} />
        </DecisionTable>
    </div>
);

// Register a Brixx HTML-Element <brixx-check-age>
Brixx.registerElement({ name: "check-age" });

Brixx HTML element in the HTML file index.html

<!DOCTYPE html>
<html>
<head>
    <!-- Load Brixx-Decision-Script standalone for development-->
    <script src="https://brixx.it/@brixx/standalone/brixx-decision.min.js"></script>
    <!-- Include the Brixx script component files for development -->
    <script type="text/babel" src="./brixx-check-age.js" data-type="module" data-presets="brixx"></script>
</head>

<body>
    <!-- Add the Brixx HTML element -->
    <brixx-check-age></brixx-check-age>
</body>
</html>

Node.js

Install the Brixx-Decision-Script package e.g. in a Visual Studio Code terminal window (see documentation below).

> npm i @brixx/decision-script

Brixx decision table definition in the JSON file brixx_check_age.json

{
    "description": "Check age",
    "hitPolicy": "Priority",
    "input": {
        "age": {
        "description": "The age to check",
        "type": "number",
        "default": 0
        }
    },
    "output": {
        "info": {
        "description": "An additional information"
        },
        "url": {
        "description": "The url to link to"
        }
    },
    "rules": {
        "No entry": {
        "age": "",
        "info": "Please enter a valid age!",
        "url": "https://github.com/BietSoft/brixx.docs/",
        "priority": 30
        },
        "Baby": {
        "age": "0",
        "info": "It's is still a baby!",
        "priority": 40
        },
        "Preschool": {
        "age": "< 5",
        "info": "Unfortunately too young!",
        "priority": 20
        },
        "Teens": {
        "age": ">= 13",
        "url": "https://www.youtube.com/"
        },
        "Kids": {
        "age": "< 13",
        "info": "Internet Safety for Kids",
        "url": "https://www.youtube.com/kids/",
        "priority": 10
        }
    }
}

Node.js app in the JavaScript file ./brixx-check-age.js

// Imports
const BrixxDecisionTable = require("@brixx/decision-script/node").default;

/**
*  Set the decision table input data list to check
*  represents e.g. data from a web service or a database
*/
const input_data = [
    { age: "" },
    { age: 0 },
    { age: 3 },
    { age: 12 },
    { age: 13 }
]

// Create a BrixxDecisionTable instance
const table = new BrixxDecisionTable({ file: "./brixx_check_age.json" });

// Check the decision table input data list
input_data.map((input) => {
    // Get the output from decision table input data
    const output = table.check(input)
    // Prints the output to console
    console.log(output)
})

Start Brixx decision table application in terminal

> node brixx-check-age.js

Documentation

See BRIXX.it documentation repository