anandrajneesh / decision-engine

Nodejs Rule Engine
https://anandrajneesh.github.io/decision-engine/
MIT License
12 stars 4 forks source link

Duplicate RuleEngine.deleteRule() method #13

Open jpenna opened 7 years ago

jpenna commented 7 years ago

Hi Anand!

I was taking a look at the code and you have two method declarations for deletion.

src/engine.js

  RuleEngine.deleteRule = function (rule) {
    if (_rules[rule.group]) {
      _rules[rule.group] = _rules[rule.group].filter(function (arg) {
        return rule.group !== arg.group && rule.name !== arg.name
      })
    }
  }

  RuleEngine.deleteRule = function (name, group) {
    if (_rules[group]) {
      _rules[group] = _rules[group].filter(function (arg) {
        return group !== arg.group && name !== arg.name
      })
    }
  }

The second declaration will override the first. In the documentation you are using the (name, group) pattern, so I was going to delete the second, but maybe you are willing to let both available, so you might consider checking if group is set or if the first passed param is an object, or whatever you think fit.

Do you want me to send a pull request for this?

anandrajneesh commented 7 years ago

thanks @jpenna for reporting this. I guess my Java kicked in while writing this :). I will be fixing it in few days.