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

axiom-rule-engine

v1.0.4

Published

--- #### Author : Axiom ##### Created on : 2th Nov 2015 <!-- ##### Update Date : 24th Nov 2015 --> --- This Rules Engine is used to bind the rules and gets the result based on rules. It have 'RulesEngine()' function which returns 'RE' Object. You req

Downloads

157

Readme

Rules Engine


Author : Axiom

Created on : 2th Nov 2015

This Rules Engine is used to bind the rules and gets the result based on rules. It have 'RulesEngine()' function which returns 'RE' Object. You require to import 'assertHelper.js' file for use this rules engine library.It is also require user to set defaultResult before using getResult() method.

  • Create Instance Of RulesEngine
  • Useful Functions
    • addRule()
    • removeRule()
    • getResult()
    • print()
    • getRule()
    • getAllRules()
  • variable
    • defaultResult

Create Instance Of RulesEngine

To use RulesEngine Library you require to create RulesEngine instance through that you can call it's functions.

  • Example

    var RulesEngine = new RulesEngine();

Here 'RulesEngine' is instance through this you can Call RulesEngine functions.

addRule(rule,result)

This method is used to add rules into 'RulesEngine' Object.It returns index of current rule into 'RulesEngine' object

Parameter Name | Descriptions :------------- | :------------------------------------------------------------------------ rule | This contains array of JSON objects that defines rule result | This contains JSON objects that defines result with respect to given rule

  • Attributes for rule and result Object

| Parameter | Attributes | DataType | Possible Values| | :------------- | :------------- |:------------- |:------------- | | rule | field | string | Any | | | filterType | string | between, in, notin, lt, lteq, gt, gteq, eq, nteq | | | value | array | Any | | result | Any | Any | Any |

  • Example

    RulesEngine.addRule([{field:"growth",filterType:"between",value:[26, 35]},
                          {field:"slope",filterType:"between",value:[26,35]}],
                            {'Color': '#1A9850','Comment': 'Between'});

    Here,rule is binded for

    1> growth is Between 26 to 35.

    2> slope is Between 26 to 35.

    with result 'Color'='#1A9850' and 'Comment'='Between'


removeRule(index)

This method is used to remove the rule from specific index of 'RulesEngine' object.

Parameter Name | Descriptions :------------- | :----------------------------------------------------- index | This defines index of rules into 'RulesEngine' object

  • Example
    RulesEngine.removeRule(0);

Here, It will remove first rule from index 0 of 'RulesEngine' object.


getResult(values)

This method compare the given value with predefined rules and gives result object based on comaprision

Parameter Name | Descriptions :------------- | :-------------------------------------------------------------------------- values | This defines JSON object which contains values to be compare against rules.

  • Example
RulesEngine.addRule([{field:"growth",filterType:"between",value:[26, 35]},
                      {field:"slope",filterType:"between",value:[26,35]}],
                        {'Color': '#1A9850','Comment': 'Between'});

retRestult=RulesEngine.getResult({growth:26,slope:29});

Here,

retRestult.Color contains '#1A9850' and retRestult.Comment contains 'Between'


print()

This method print Entire rules with result and also defaultResult.

  • Example
RulesEngine.print()

defaultResult

defaultResult variable defines default result when no rules mathced.You must require to set default result before use getResult method.

  • Example
RulesEngine.defaultResult={'Color': '#D73027','Comment': 'Default Message'};

getRule(index)

This method is used to get rule from specific index.

Parameter Name | Descriptions :------------- | :----------------------------------------------------- index | This defines index of rules into 'RulesEngine' object

  • Example
RulesEngine.getRule(0)

Here, It will return first rule from index 0 of 'RulesEngine' object.


getAllRules()

This method is used to get all rules of 'RulesEngine' object.

  • Example
RulesEngine.getAllRules()

Here, It will return all rules of 'RulesEngine' object.