Skip to content

Commit

Permalink
Remove fromJSON and toJSON from exposed APIs
Browse files Browse the repository at this point in the history
Remove fromJSON and toJSON from exposed APIs in V5.0.0
  • Loading branch information
mithunsatheesh authored Mar 16, 2020
1 parent 1b07c48 commit 1008622
Showing 1 changed file with 0 additions and 31 deletions.
31 changes: 0 additions & 31 deletions lib/node-rules.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,36 +128,5 @@
}
this.sync();
}
RuleEngine.prototype.toJSON = function() {
var rules = this.rules;
if (rules instanceof Array) {
rules = rules.map(function(rule) {
rule.condition = rule.condition.toString();
rule.consequence = rule.consequence.toString();
return rule;
});
} else if (typeof(rules) != "undefined") {
rules.condition = rules.condition.toString();
rules.consequence = rules.consequence.toString();
}
return rules;
};
RuleEngine.prototype.fromJSON = function(rules) {
this.init();
if (typeof(rules) == "string") {
rules = JSON.parse(rules);
}
if (rules instanceof Array) {
rules = rules.map(function(rule) {
rule.condition = eval("(" + rule.condition + ")");
rule.consequence = eval("(" + rule.consequence + ")");
return rule;
});
} else if (rules !== null && typeof(rules) == "object") {
rules.condition = eval("(" + rules.condition + ")");
rules.consequence = eval("(" + rules.consequence + ")");
}
this.register(rules);
};
module.exports = RuleEngine;
}(module.exports));

0 comments on commit 1008622

Please sign in to comment.