4 Commits

Author SHA1 Message Date
917e630554 1.0.6 2020-01-23 15:12:55 +00:00
b3b02fee70 fix(core): update 2020-01-23 15:12:55 +00:00
8c257bc0fd 1.0.5 2020-01-23 15:11:30 +00:00
a4ff5c26e2 fix(core): update 2020-01-23 15:11:29 +00:00
3 changed files with 17 additions and 13 deletions

2
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartrule",
"version": "1.0.4",
"version": "1.0.6",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View File

@@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartrule",
"version": "1.0.4",
"version": "1.0.6",
"private": false,
"description": "a smart rule library for handling decision trees.",
"main": "dist/index.js",

View File

@@ -26,7 +26,7 @@ export class SmartRule<T> {
};
// lets run the checks
const runNextBatch = async (startPriority: number) => {
const runNextBatch = async (startPriority: number): Promise<void> => {
const nextBatch = getNextParallelBatch(0);
const outcomes: TTreeActionResult[] = [];
for (const rule of nextBatch) {
@@ -35,21 +35,25 @@ export class SmartRule<T> {
await rule.actionFunction(objectArg);
}
outcomes.push(checkResult);
};
}
const finalOutcome: TTreeActionResult = outcomes.reduce((previous, current, index, array) => {
if (current.includes('continue') || previous.includes('continue')) {
return 'continue';
} else {
return 'stop';
if (outcomes.length > 0) {
const finalOutcomeOfBatch: TTreeActionResult = outcomes.reduce((previous, current, index, array) => {
if (current.includes('continue') || previous.includes('continue')) {
return 'continue';
} else {
return 'stop';
}
});
if (finalOutcomeOfBatch === 'stop') {
return;
}
});
if (finalOutcome === 'stop') {
return;
}
if (startPriority < this.rules[this.rules.length-1].priority) {
runNextBatch(startPriority++);
await runNextBatch(startPriority++);
} else {
return;
}
};