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

multi-layer-dss

v3.1.4

Published

A npm package that builds a multi-layered decision support system (DSS) for Node.js. You can program what each layer and the total flow does and returns, with a simple JS function.

Downloads

21

Readme

Build Status Coverage Status

multi-layer-dss

A npm package that builds a multi-layered Decision Support System (DSS) for Node.js.

This package makes use of three core clases: Flow, Layer, Rule; written in TypeScript and builded to JS.

  • A Flow is the complete system. It contains Layers and a "resolve" function (Coded by the user) receiving all Layers results. Flow.execute receives the Object to pass the Flow.
  • A Layer contains related Rules and a "resolve" function (Coded by the user) receiving all Rules of this Layer and the Object. "resolve" should call the "resolve" function of each Rule.
  • A Rule contains any number of "conditions" as functions that receive the Object and should return a boolean, a "content" of any type, a number "weigth" useful in its "resolve" function, that also receives the Object.

Installation

npm install multi-layer-dss --save

Usage

Commands

  • Run EsLint test:
npm run lint
  • Run Mocha test (If builded):
npm run test
  • Build JS:
npm run build
  • Make use of 'debugFlow.js':
npm run debugFlow
  • Make use of 'debugStep.js':
npm run debugStep

Code example

var mldss = require('multi-layer-dss');
var flow = mldss.Flow;
var layer = mldss.Layer;
var rule = mldss.Rule;

Step by step

See debugStep.js

'use strict';
var index = require('multi-layer-dss');
var flow = index.Flow;
var layer = index.Layer;
var rule = index.Rule;

let rules = [];
rules.push(new rule(1, 'General Grievous', [(o) => { return o.value === 2; }]));
rules.push(new rule(1, 'General Kenobi', [(o) => { return o.value === 1; }]));

let layers = [];
layers.push(new layer((rul, o) => {
    let ret = 'Hello there';
    console.log(ret);

    for (let i = 0; i < rul.length; i++){
        if (rul[i].resolve(o))
            ret = rul[i].getContent();
    }

    return ret;
}, rules));

let newRule = new rule(1, 'Master Skywalker', [(o) => { return o.value === 3; }]);
layers[0].addRule(newRule);

let resolveFunc = (results) => {
    return results[0];
};
let actualFlow = new flow(resolveFunc);
for (let i = 0; i < layers.length; i++){
    actualFlow.addLayer(layers[i]);
}

let obj = {
    value: 1
}

actualFlow.execute(obj)
.then(val => {
    console.log(val);
})
.catch(err => {
    console.log(err);
});

JSO

See debugFlow.js

'use strict';
var index = require('multi-layer-dss');
var flow = index.Flow;

let layers = [{
        resolve: (rul, o) => {
            let ret = 'Hello there';
            console.log(ret);

            for (let i = 0; i < rul.length; i++){
                if (rul[i].resolve(o))
                    ret = rul[i].getContent();
            }

            return ret;
        },
        rules: [
            {
                weigth: 1,
                content: 'General Kenobi',
                conditions: [
                    (o) => {
                        return o.value === 1;
                    }
                ]
            },
            {
                weigth: 1,
                content: 'General Grievous',
                conditions: [
                    (o) => {
                        return o.value === 2;
                    }
                ]
            }
        ]
    }
];
let resolveFunc = (results) => {
    return results[0];
};

let actualFlow = new flow(resolveFunc, layers);
let obj = {
    value: 1
}

actualFlow.execute(obj)
.then(val => {
    console.log(val);
})
.catch(err => {
    console.log(err);
});