* Iterates over the engine rules, organizing them by highest -> lowest priority * @return {Rule[][]} two dimensional array of Rules. * Each outer array element represents a single priority(integer). Inner array is * all rules with that priority.
()
| 195 | * all rules with that priority. |
| 196 | */ |
| 197 | prioritizeRules () { |
| 198 | if (!this.prioritizedRules) { |
| 199 | const ruleSets = this.rules.reduce((sets, rule) => { |
| 200 | const priority = rule.priority |
| 201 | if (!sets[priority]) sets[priority] = [] |
| 202 | sets[priority].push(rule) |
| 203 | return sets |
| 204 | }, {}) |
| 205 | this.prioritizedRules = Object.keys(ruleSets).sort((a, b) => { |
| 206 | return Number(a) > Number(b) ? -1 : 1 // order highest priority -> lowest |
| 207 | }).map((priority) => ruleSets[priority]) |
| 208 | } |
| 209 | return this.prioritizedRules |
| 210 | } |
| 211 | |
| 212 | /** |
| 213 | * Stops the rules engine from running the next priority set of Rules. All remaining rules will be resolved as undefined, |
no outgoing calls