Skip to content

Commit 41318e1

Browse files
author
Cache Hamm
committed
latest compile
1 parent f024be8 commit 41318e1

1 file changed

Lines changed: 20 additions & 24 deletions

File tree

dist/engine.js

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,18 @@ var Engine = function (_EventEmitter) {
161161
}, {
162162
key: 'prioritizeRules',
163163
value: function prioritizeRules() {
164-
var _this2 = this;
165-
166164
if (!this.prioritizedRules) {
167-
(function () {
168-
var ruleSets = _this2.rules.reduce(function (sets, rule) {
169-
var priority = rule.priority;
170-
if (!sets[priority]) sets[priority] = [];
171-
sets[priority].push(rule);
172-
return sets;
173-
}, {});
174-
_this2.prioritizedRules = Object.keys(ruleSets).sort(function (a, b) {
175-
return Number(a) > Number(b) ? -1 : 1; // order highest priority -> lowest
176-
}).map(function (priority) {
177-
return ruleSets[priority];
178-
});
179-
})();
165+
var ruleSets = this.rules.reduce(function (sets, rule) {
166+
var priority = rule.priority;
167+
if (!sets[priority]) sets[priority] = [];
168+
sets[priority].push(rule);
169+
return sets;
170+
}, {});
171+
this.prioritizedRules = Object.keys(ruleSets).sort(function (a, b) {
172+
return Number(a) > Number(b) ? -1 : 1; // order highest priority -> lowest
173+
}).map(function (priority) {
174+
return ruleSets[priority];
175+
});
180176
}
181177
return this.prioritizedRules;
182178
}
@@ -217,25 +213,25 @@ var Engine = function (_EventEmitter) {
217213
key: 'evaluateRules',
218214
value: function () {
219215
var _ref = _asyncToGenerator(regeneratorRuntime.mark(function _callee(ruleArray, almanac) {
220-
var _this3 = this;
216+
var _this2 = this;
221217

222218
return regeneratorRuntime.wrap(function _callee$(_context) {
223219
while (1) {
224220
switch (_context.prev = _context.next) {
225221
case 0:
226222
return _context.abrupt('return', Promise.all(ruleArray.map(function (rule) {
227-
if (_this3.status !== RUNNING) {
228-
debug('engine::run status:' + _this3.status + '; skipping remaining rules');
223+
if (_this2.status !== RUNNING) {
224+
debug('engine::run status:' + _this2.status + '; skipping remaining rules');
229225
return;
230226
}
231227
return rule.evaluate(almanac).then(function (rulePasses) {
232228
debug('engine::run ruleResult:' + rulePasses);
233229
if (rulePasses) {
234-
_this3.emit('success', rule.event, almanac);
235-
_this3.emit(rule.event.type, rule.event.params, _this3);
230+
_this2.emit('success', rule.event, almanac);
231+
_this2.emit(rule.event.type, rule.event.params, _this2);
236232
almanac.factValue('success-events', { event: rule.event });
237233
}
238-
if (!rulePasses) _this3.emit('failure', rule, almanac);
234+
if (!rulePasses) _this2.emit('failure', rule, almanac);
239235
});
240236
})));
241237

@@ -265,7 +261,7 @@ var Engine = function (_EventEmitter) {
265261
key: 'run',
266262
value: function () {
267263
var _ref2 = _asyncToGenerator(regeneratorRuntime.mark(function _callee2() {
268-
var _this4 = this;
264+
var _this3 = this;
269265

270266
var runtimeFacts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
271267
var almanac, orderedSets, cursor;
@@ -286,12 +282,12 @@ var Engine = function (_EventEmitter) {
286282
return _context2.abrupt('return', new Promise(function (resolve, reject) {
287283
orderedSets.map(function (set) {
288284
cursor = cursor.then(function () {
289-
return _this4.evaluateRules(set, almanac);
285+
return _this3.evaluateRules(set, almanac);
290286
}).catch(reject);
291287
return cursor;
292288
});
293289
cursor.then(function () {
294-
_this4.status = FINISHED;
290+
_this3.status = FINISHED;
295291
debug('engine::run completed');
296292
resolve(almanac.factValue('success-events'));
297293
}).catch(reject);

0 commit comments

Comments
 (0)