Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-rule

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-rule

JavaScript implementation of the rules engine

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

js-rule

JavaScript implementation of the rules engine

Features

  • Single or multiple ConditionAction
  • Chain call Rule, eg: A->B->C
  • Multiple Condition setting ANY, ALL, NONE
  • Condition setting NOTINCLUDEEQUALNOT_EQUALGREATERGREATER_EQUALLESSLESS_EQUAL ...
  • Custom Condition Operation

Install

npm install js-rule

Usage

Use the program to indicate

if ((filedA.value === 10) & ["B1", "B2"].includes(filedB.value)) {
  filedC.visible = true;
  filedC.value = "C1";
}

Description using Rule

import { Engine, Rule, ConditionOperationEnum } from "js-rule";

const engine = new Engine();

// Add a rule where Condition is ANY
// ANY: Action is triggered whenever a Condition holds
const rule = new Rule(ConditionOperationEnum.ANY);

/* set condition */
// When the value of 'FiledA' is equal to 10 and the value of 'FieldB' contains "B1" or "B2" is discarded
rule.condition.addCondition("FieldA", "EQUAL", 10);
rule.condition.addCondition("FieldB", "INCLUDE", ["B1", "B1"]);

/* set action */
rule.action.addAction("FieldC", {
  show: true,
  value: "C1",
});

// register rule
engine.addRule(rule);

Submit data

// getAllRuleDetails --> format: JSON
engine.getAllRuleDetails();

// getRules --> format: Original Rule
engine.getRules();

DOCS

  • TODO

FAQs

Package last updated on 02 Apr 2022

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc