Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
nested-rules-engine
Advanced tools
Readme
A simple Decision tree based Rule Engine described using json files. Rules are executed according to decision tree. Create a set of rules (make them nested as you like) and based on set of inputs run the rules.
npm install nested-rules-engine --save
const {executeEngine} = require('nested-rules-engine');
// Step1: Define your conditional rules
const rules = {
"you_are_a_human": {
"you_are_kind": "help_me_find_my_book",
"you_are_smart": "please_do_my_homework",
},
"default": "please_do_my_homework"
};
// Step2: make set of inputs collection
const inputs = {
"type" : "human",
"kindnessLevel": 0,
"intelligence": 10
}
// Step3: Make your custom Functions
const functions = {
default : () => true,
you_are_a_human: ({type}) => type === 'human',
you_are_kind: ({kindnessLevel}) => kindnessLevel > 300,
you_are_smart: ({intelligence}) => intelligence > 5,
help_me_find_my_book: () => ({
payload: 'lets help someone',
effort: 'finding the book'
}),
please_do_my_homework: () => ({
payload: 'doing homework',
effort: 'im getting sick'
})
};
// Step4: Execute Engine
const res = executeEngine(inputs, functions, rules);
// Output res:
/*
{
result: { payload: 'doing homework', effort: 'im getting sick' },
logs: []
}
*/
Engine Execution Signature:
executeEngine(variables, functions, rules, options);
variables
Collection of values on which rule engine will execute
You can change these collection of variables (Add/Edit/Delte them) as you traverse the decision tree of rules.
functions
Collection of functions that decide which way the tree should be traversed.
result
true
: this means this branch should be traversedrules
Decision Tree that will be traversed by this Rule Engine
options
there are different options that you can provide to customize the execution nature
result
: Result of the engine execution. format of Result will be defined by you through functions
logs
: Detailed logs while engine got executed (by default its disabled)FAQs
Nested Conditional Rules Engine
The npm package nested-rules-engine receives a total of 6 weekly downloads. As such, nested-rules-engine popularity was classified as not popular.
We found that nested-rules-engine demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.