Built motion from commit (unavailable).|2.4.7
[motion2.git] / server / services / routing / lib / rule-engine.js
index b710558..922be5f 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0x9ce7=['index_','call','nextTick','next','isEqual','restart','length','condition','matchPath','findRules','matches','turn','prioritize','priority','map','toString','fromJSON','parse','object','lodash','EventEmitter','register','ignoreFactChanges','inherits','prototype','init','rules','activeRules','isArray','isObject','push','sync','filter','isNil','asc','execute','result','clone','consequence','ruleRef','name'];(function(_0x3e58b3,_0x2dace0){var _0x18da3d=function(_0x170164){while(--_0x170164){_0x3e58b3['push'](_0x3e58b3['shift']());}};_0x18da3d(++_0x2dace0);}(_0x9ce7,0x65));var _0x79ce=function(_0x1b94c4,_0x16a6fd){_0x1b94c4=_0x1b94c4-0x0;var _0x4e6a0a=_0x9ce7[_0x1b94c4];return _0x4e6a0a;};'use strict';var _=require(_0x79ce('0x0'));var util=require('util');var EventEmitter=require('events')[_0x79ce('0x1')];function RuleEngine(_0x1ebd1a,_0x4d3a20){this['init']();if(!_['isNil'](_0x1ebd1a)){this[_0x79ce('0x2')](_0x1ebd1a);}if(_0x4d3a20){this[_0x79ce('0x3')]=_0x4d3a20[_0x79ce('0x3')];}return this;}util[_0x79ce('0x4')](RuleEngine,EventEmitter);RuleEngine[_0x79ce('0x5')][_0x79ce('0x6')]=function(_0x25e654){this[_0x79ce('0x7')]=[];this[_0x79ce('0x8')]=[];};RuleEngine[_0x79ce('0x5')][_0x79ce('0x2')]=function(_0x48b5c1){if(Array[_0x79ce('0x9')](_0x48b5c1)){this[_0x79ce('0x7')]=this[_0x79ce('0x7')]['concat'](_0x48b5c1);}else if(_0x48b5c1!==null&&_[_0x79ce('0xa')](_0x48b5c1)){this[_0x79ce('0x7')][_0x79ce('0xb')](_0x48b5c1);}this['sync']();};RuleEngine[_0x79ce('0x5')][_0x79ce('0xc')]=function(){this[_0x79ce('0x8')]=this[_0x79ce('0x7')][_0x79ce('0xd')](function(_0x21f61e){if(_[_0x79ce('0xe')](_0x21f61e['on'])){_0x21f61e['on']=!![];}if(_0x21f61e['on']===!![]){return _0x21f61e;}});this['activeRules']=_['orderBy'](this['activeRules'],['p'],[_0x79ce('0xf')]);};RuleEngine[_0x79ce('0x5')][_0x79ce('0x10')]=function(_0x579d6d,_0x233d6b){var _0x4c1972=![];_0x579d6d[_0x79ce('0x11')]=!![];var _0x20d6e6=_['clone'](_0x579d6d);var _0x5ca4f3=_[_0x79ce('0x12')](_0x579d6d);var _0x126ed6=this['activeRules'];var _0x52ab8b=[];var _0x59c7ab=this[_0x79ce('0x3')];(function FnRuleLoop(_0x203574){var _0x4a3bd1={'rules':function(){return _0x126ed6;},'rule':function(){return _0x126ed6[_0x203574];},'when':function(_0x2ad388){if(_0x2ad388){var _0x597085=_0x126ed6[_0x203574][_0x79ce('0x13')];_0x597085[_0x79ce('0x14')]=_0x126ed6[_0x203574]['id']||_0x126ed6[_0x203574][_0x79ce('0x15')]||_0x79ce('0x16')+_0x203574;process['nextTick'](function(){_0x52ab8b[_0x79ce('0xb')](_0x597085['ruleRef']);_0x597085[_0x79ce('0x17')](_0x20d6e6,_0x4a3bd1);});}else{process[_0x79ce('0x18')](function(){_0x4a3bd1[_0x79ce('0x19')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x4c1972=!![];return FnRuleLoop(0x0);},'next':function(_0x2ef7bf){if(!_0x59c7ab&&!_[_0x79ce('0x1a')](_0x5ca4f3,_0x20d6e6)){_0x5ca4f3=_[_0x79ce('0x12')](_0x20d6e6);process[_0x79ce('0x18')](function(){_0x4a3bd1[_0x79ce('0x1b')]();});}else{process[_0x79ce('0x18')](function(){if(_[_0x79ce('0xe')](_0x2ef7bf)){return FnRuleLoop(_0x203574+0x1);}else{return FnRuleLoop(_0x2ef7bf);}});}}};if(_0x203574<_0x126ed6[_0x79ce('0x1c')]&&_0x4c1972===![]){var _0x1bd0ea=_0x126ed6[_0x203574][_0x79ce('0x1d')];_0x1bd0ea[_0x79ce('0x17')](_0x20d6e6,_0x4a3bd1);}else{process['nextTick'](function(){_0x20d6e6[_0x79ce('0x1e')]=_0x52ab8b;return _0x233d6b?_0x233d6b(_0x20d6e6):_['noop']();});}}(0x0));};RuleEngine[_0x79ce('0x5')][_0x79ce('0x1f')]=function(_0x17447d){if(_[_0x79ce('0xe')](_0x17447d)){return this[_0x79ce('0x7')];}else{var _0x447818=_[_0x79ce('0x20')](_0x17447d);return _[_0x79ce('0xd')](this[_0x79ce('0x7')],_0x447818);}};RuleEngine[_0x79ce('0x5')][_0x79ce('0x21')]=function(_0xff581,_0x35e559){var _0xff581=_0xff581==='on'||_0xff581==='ON'?!![]:![];var _0x26c6e6=this[_0x79ce('0x1f')](_0x35e559);for(var _0x4bd215=0x0,_0x367ddc=_0x26c6e6['length'];_0x4bd215<_0x367ddc;_0x4bd215+=0x1){_0x26c6e6[_0x4bd215]['on']=_0xff581;}this[_0x79ce('0xc')]();};RuleEngine[_0x79ce('0x5')][_0x79ce('0x22')]=function(_0x308b8f,_0x39507a){_0x308b8f=parseInt(_0x308b8f,0xa);var _0x2257f4=this[_0x79ce('0x1f')](_0x39507a);for(var _0x51234b=0x0,_0x12a92a=_0x2257f4[_0x79ce('0x1c')];_0x51234b<_0x12a92a;_0x51234b+=0x1){_0x2257f4[_0x51234b][_0x79ce('0x23')]=_0x308b8f;}this[_0x79ce('0xc')]();};RuleEngine[_0x79ce('0x5')]['toJSON']=function(){var _0x16edc2=this[_0x79ce('0x7')];if(_0x16edc2 instanceof Array){_0x16edc2=_0x16edc2[_0x79ce('0x24')](function(_0x27b0cd){_0x27b0cd[_0x79ce('0x1d')]=_0x27b0cd[_0x79ce('0x1d')][_0x79ce('0x25')]();_0x27b0cd[_0x79ce('0x13')]=_0x27b0cd[_0x79ce('0x13')][_0x79ce('0x25')]();return _0x27b0cd;});}else if(!_[_0x79ce('0xe')](_0x16edc2)){_0x16edc2[_0x79ce('0x1d')]=_0x16edc2[_0x79ce('0x1d')][_0x79ce('0x25')]();_0x16edc2[_0x79ce('0x13')]=_0x16edc2[_0x79ce('0x13')]['toString']();}return _0x16edc2;};RuleEngine[_0x79ce('0x5')][_0x79ce('0x26')]=function(_0x3a356b){this[_0x79ce('0x6')]();if(_['isString'](_0x3a356b)){_0x3a356b=JSON[_0x79ce('0x27')](_0x3a356b);}if(_0x3a356b instanceof Array){_0x3a356b=_0x3a356b[_0x79ce('0x24')](function(_0x334b7e){_0x334b7e['condition']=eval('('+_0x334b7e[_0x79ce('0x1d')]+')');_0x334b7e[_0x79ce('0x13')]=eval('('+_0x334b7e[_0x79ce('0x13')]+')');return _0x334b7e;});}else if(_0x3a356b!==null&&typeof _0x3a356b==_0x79ce('0x28')){_0x3a356b[_0x79ce('0x1d')]=eval('('+_0x3a356b[_0x79ce('0x1d')]+')');_0x3a356b['consequence']=eval('('+_0x3a356b[_0x79ce('0x13')]+')');}this[_0x79ce('0x2')](_0x3a356b);};module['exports']=RuleEngine;
\ No newline at end of file
+var _0x5b06=['index_','call','next','isEqual','nextTick','restart','length','condition','noop','findRules','matches','prioritize','toJSON','map','toString','isString','parse','object','exports','lodash','events','EventEmitter','init','isNil','register','ignoreFactChanges','prototype','rules','isArray','concat','push','sync','activeRules','orderBy','asc','execute','clone','consequence','ruleRef','name'];(function(_0x504919,_0x18710e){var _0x15c215=function(_0x1db910){while(--_0x1db910){_0x504919['push'](_0x504919['shift']());}};_0x15c215(++_0x18710e);}(_0x5b06,0xb3));var _0x65b0=function(_0xdb5743,_0x412ad0){_0xdb5743=_0xdb5743-0x0;var _0x1925ff=_0x5b06[_0xdb5743];return _0x1925ff;};'use strict';var _=require(_0x65b0('0x0'));var util=require('util');var EventEmitter=require(_0x65b0('0x1'))[_0x65b0('0x2')];function RuleEngine(_0x31e32d,_0x4649ce){this[_0x65b0('0x3')]();if(!_[_0x65b0('0x4')](_0x31e32d)){this[_0x65b0('0x5')](_0x31e32d);}if(_0x4649ce){this[_0x65b0('0x6')]=_0x4649ce[_0x65b0('0x6')];}return this;}util['inherits'](RuleEngine,EventEmitter);RuleEngine[_0x65b0('0x7')]['init']=function(_0x2573a2){this[_0x65b0('0x8')]=[];this['activeRules']=[];};RuleEngine[_0x65b0('0x7')][_0x65b0('0x5')]=function(_0x56b3cf){if(Array[_0x65b0('0x9')](_0x56b3cf)){this[_0x65b0('0x8')]=this[_0x65b0('0x8')][_0x65b0('0xa')](_0x56b3cf);}else if(_0x56b3cf!==null&&_['isObject'](_0x56b3cf)){this['rules'][_0x65b0('0xb')](_0x56b3cf);}this[_0x65b0('0xc')]();};RuleEngine[_0x65b0('0x7')][_0x65b0('0xc')]=function(){this[_0x65b0('0xd')]=this[_0x65b0('0x8')]['filter'](function(_0x22aa26){if(_[_0x65b0('0x4')](_0x22aa26['on'])){_0x22aa26['on']=!![];}if(_0x22aa26['on']===!![]){return _0x22aa26;}});this[_0x65b0('0xd')]=_[_0x65b0('0xe')](this[_0x65b0('0xd')],['p'],[_0x65b0('0xf')]);};RuleEngine[_0x65b0('0x7')][_0x65b0('0x10')]=function(_0x1057b4,_0x5e16d0){var _0x3d1ea5=![];_0x1057b4['result']=!![];var _0x2991b7=_[_0x65b0('0x11')](_0x1057b4);var _0x27e0ca=_[_0x65b0('0x11')](_0x1057b4);var _0x598a96=this[_0x65b0('0xd')];var _0x4aa41f=[];var _0xb0b7cb=this[_0x65b0('0x6')];(function FnRuleLoop(_0x53766a){var _0x5f5a17={'rules':function(){return _0x598a96;},'rule':function(){return _0x598a96[_0x53766a];},'when':function(_0x5196d9){if(_0x5196d9){var _0x1d23de=_0x598a96[_0x53766a][_0x65b0('0x12')];_0x1d23de[_0x65b0('0x13')]=_0x598a96[_0x53766a]['id']||_0x598a96[_0x53766a][_0x65b0('0x14')]||_0x65b0('0x15')+_0x53766a;process['nextTick'](function(){_0x4aa41f[_0x65b0('0xb')](_0x1d23de[_0x65b0('0x13')]);_0x1d23de[_0x65b0('0x16')](_0x2991b7,_0x5f5a17);});}else{process['nextTick'](function(){_0x5f5a17[_0x65b0('0x17')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x3d1ea5=!![];return FnRuleLoop(0x0);},'next':function(_0x3882ce){if(!_0xb0b7cb&&!_[_0x65b0('0x18')](_0x27e0ca,_0x2991b7)){_0x27e0ca=_[_0x65b0('0x11')](_0x2991b7);process[_0x65b0('0x19')](function(){_0x5f5a17[_0x65b0('0x1a')]();});}else{process[_0x65b0('0x19')](function(){if(_[_0x65b0('0x4')](_0x3882ce)){return FnRuleLoop(_0x53766a+0x1);}else{return FnRuleLoop(_0x3882ce);}});}}};if(_0x53766a<_0x598a96[_0x65b0('0x1b')]&&_0x3d1ea5===![]){var _0x44c628=_0x598a96[_0x53766a][_0x65b0('0x1c')];_0x44c628[_0x65b0('0x16')](_0x2991b7,_0x5f5a17);}else{process[_0x65b0('0x19')](function(){_0x2991b7['matchPath']=_0x4aa41f;return _0x5e16d0?_0x5e16d0(_0x2991b7):_[_0x65b0('0x1d')]();});}}(0x0));};RuleEngine[_0x65b0('0x7')][_0x65b0('0x1e')]=function(_0x16efe6){if(_['isNil'](_0x16efe6)){return this['rules'];}else{var _0x7be6d3=_[_0x65b0('0x1f')](_0x16efe6);return _['filter'](this[_0x65b0('0x8')],_0x7be6d3);}};RuleEngine[_0x65b0('0x7')]['turn']=function(_0x159d1f,_0x5d849b){var _0x159d1f=_0x159d1f==='on'||_0x159d1f==='ON'?!![]:![];var _0x38c62b=this['findRules'](_0x5d849b);for(var _0x54a384=0x0,_0xc1a387=_0x38c62b[_0x65b0('0x1b')];_0x54a384<_0xc1a387;_0x54a384+=0x1){_0x38c62b[_0x54a384]['on']=_0x159d1f;}this[_0x65b0('0xc')]();};RuleEngine[_0x65b0('0x7')][_0x65b0('0x20')]=function(_0x303a69,_0x40db6c){_0x303a69=parseInt(_0x303a69,0xa);var _0x3bbf6f=this[_0x65b0('0x1e')](_0x40db6c);for(var _0x10992c=0x0,_0x8241f4=_0x3bbf6f[_0x65b0('0x1b')];_0x10992c<_0x8241f4;_0x10992c+=0x1){_0x3bbf6f[_0x10992c]['priority']=_0x303a69;}this[_0x65b0('0xc')]();};RuleEngine['prototype'][_0x65b0('0x21')]=function(){var _0x210738=this[_0x65b0('0x8')];if(_0x210738 instanceof Array){_0x210738=_0x210738[_0x65b0('0x22')](function(_0xd46ba5){_0xd46ba5[_0x65b0('0x1c')]=_0xd46ba5['condition'][_0x65b0('0x23')]();_0xd46ba5[_0x65b0('0x12')]=_0xd46ba5[_0x65b0('0x12')][_0x65b0('0x23')]();return _0xd46ba5;});}else if(!_[_0x65b0('0x4')](_0x210738)){_0x210738[_0x65b0('0x1c')]=_0x210738[_0x65b0('0x1c')][_0x65b0('0x23')]();_0x210738[_0x65b0('0x12')]=_0x210738['consequence'][_0x65b0('0x23')]();}return _0x210738;};RuleEngine[_0x65b0('0x7')]['fromJSON']=function(_0x482d54){this[_0x65b0('0x3')]();if(_[_0x65b0('0x24')](_0x482d54)){_0x482d54=JSON[_0x65b0('0x25')](_0x482d54);}if(_0x482d54 instanceof Array){_0x482d54=_0x482d54[_0x65b0('0x22')](function(_0x217a03){_0x217a03[_0x65b0('0x1c')]=eval('('+_0x217a03['condition']+')');_0x217a03['consequence']=eval('('+_0x217a03[_0x65b0('0x12')]+')');return _0x217a03;});}else if(_0x482d54!==null&&typeof _0x482d54==_0x65b0('0x26')){_0x482d54['condition']=eval('('+_0x482d54['condition']+')');_0x482d54[_0x65b0('0x12')]=eval('('+_0x482d54[_0x65b0('0x12')]+')');}this[_0x65b0('0x5')](_0x482d54);};module[_0x65b0('0x27')]=RuleEngine;
\ No newline at end of file