Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 917e630554 | |||
| b3b02fee70 | |||
| 8c257bc0fd | |||
| a4ff5c26e2 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartrule",
|
"name": "@pushrocks/smartrule",
|
||||||
"version": "1.0.4",
|
"version": "1.0.6",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartrule",
|
"name": "@pushrocks/smartrule",
|
||||||
"version": "1.0.4",
|
"version": "1.0.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a smart rule library for handling decision trees.",
|
"description": "a smart rule library for handling decision trees.",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export class SmartRule<T> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// lets run the checks
|
// lets run the checks
|
||||||
const runNextBatch = async (startPriority: number) => {
|
const runNextBatch = async (startPriority: number): Promise<void> => {
|
||||||
const nextBatch = getNextParallelBatch(0);
|
const nextBatch = getNextParallelBatch(0);
|
||||||
const outcomes: TTreeActionResult[] = [];
|
const outcomes: TTreeActionResult[] = [];
|
||||||
for (const rule of nextBatch) {
|
for (const rule of nextBatch) {
|
||||||
@@ -35,21 +35,25 @@ export class SmartRule<T> {
|
|||||||
await rule.actionFunction(objectArg);
|
await rule.actionFunction(objectArg);
|
||||||
}
|
}
|
||||||
outcomes.push(checkResult);
|
outcomes.push(checkResult);
|
||||||
};
|
}
|
||||||
|
|
||||||
const finalOutcome: TTreeActionResult = outcomes.reduce((previous, current, index, array) => {
|
if (outcomes.length > 0) {
|
||||||
if (current.includes('continue') || previous.includes('continue')) {
|
const finalOutcomeOfBatch: TTreeActionResult = outcomes.reduce((previous, current, index, array) => {
|
||||||
return 'continue';
|
if (current.includes('continue') || previous.includes('continue')) {
|
||||||
} else {
|
return 'continue';
|
||||||
return 'stop';
|
} else {
|
||||||
|
return 'stop';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (finalOutcomeOfBatch === 'stop') {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
if (finalOutcome === 'stop') {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (startPriority < this.rules[this.rules.length-1].priority) {
|
if (startPriority < this.rules[this.rules.length-1].priority) {
|
||||||
runNextBatch(startPriority++);
|
await runNextBatch(startPriority++);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user