Skip to content

Commit 1fa3a71

Browse files
author
Mithun Satheesh
committed
[#94][#95] Fix Module build failed error while generating dist
1. Fix Module build failed error while generating dist 2. Remove lodash matches dependency for partial matches
1 parent 84f1398 commit 1fa3a71

File tree

4 files changed

+13
-9
lines changed

4 files changed

+13
-9
lines changed

.babelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["env"]
2+
"presets": ["@babel/preset-env"]
33
}

dist/node-rules.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/node-rules.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
var isEqual = require('lodash.isequal');
66
var clonedeep = require('lodash.clonedeep');
7-
var matches = require('lodash.matches');
87

98
function RuleEngine(rules, options) {
109
this.init();
@@ -105,12 +104,18 @@
105104
}
106105
})(0);
107106
};
108-
RuleEngine.prototype.findRules = function(filter) {
109-
if (typeof(filter) === "undefined") {
107+
RuleEngine.prototype.findRules = function(query) {
108+
if (typeof(query) === "undefined") {
110109
return this.rules;
111110
} else {
112-
var find = matches(filter);
113-
return this.rules.filter(find);
111+
// Clean the properties set to undefined in the search query if any to prevent miss match issues.
112+
Object.keys(query).forEach(key => query[key] === undefined && delete query[key]);
113+
// Return rules in the registered rules array which match partially to the query.
114+
return this.rules.filter(function (rule) {
115+
return Object.keys(query).some(function (key) {
116+
return query[key] === rule[key];
117+
});
118+
});
114119
}
115120
}
116121
RuleEngine.prototype.turn = function(state, filter) {

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@
3737
},
3838
"dependencies": {
3939
"lodash.clonedeep": "^4.5.0",
40-
"lodash.isequal": "^4.5.0",
41-
"lodash.matches": "^4.6.0"
40+
"lodash.isequal": "^4.5.0"
4241
},
4342
"devDependencies": {
4443
"@babel/cli": "^7.12.0",

0 commit comments

Comments
 (0)