Skip to content

Duplicate RuleEngine.deleteRule() method #13

@jpenna

Description

@jpenna

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?

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions