Built motion from commit (unavailable).|2.5.4
[motion2.git] / server / services / routing / lib / rule-engine.js
index f0f24da..1429622 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xe908=['nextTick','ruleRef','call','next','isEqual','restart','matchPath','noop','matches','findRules','length','priority','toJSON','map','condition','toString','parse','object','exports','lodash','util','events','EventEmitter','init','isNil','ignoreFactChanges','prototype','rules','activeRules','register','isArray','push','sync','filter','asc','clone','consequence','index_'];(function(_0x19cce8,_0x23a814){var _0x575f93=function(_0x515f8b){while(--_0x515f8b){_0x19cce8['push'](_0x19cce8['shift']());}};_0x575f93(++_0x23a814);}(_0xe908,0xab));var _0x8e90=function(_0x209941,_0x5c9988){_0x209941=_0x209941-0x0;var _0x1e8729=_0xe908[_0x209941];return _0x1e8729;};'use strict';var _=require(_0x8e90('0x0'));var util=require(_0x8e90('0x1'));var EventEmitter=require(_0x8e90('0x2'))[_0x8e90('0x3')];function RuleEngine(_0x4ea9c0,_0x1383fd){this[_0x8e90('0x4')]();if(!_[_0x8e90('0x5')](_0x4ea9c0)){this['register'](_0x4ea9c0);}if(_0x1383fd){this[_0x8e90('0x6')]=_0x1383fd[_0x8e90('0x6')];}return this;}util['inherits'](RuleEngine,EventEmitter);RuleEngine[_0x8e90('0x7')]['init']=function(_0x3600ad){this[_0x8e90('0x8')]=[];this[_0x8e90('0x9')]=[];};RuleEngine[_0x8e90('0x7')][_0x8e90('0xa')]=function(_0x111984){if(Array[_0x8e90('0xb')](_0x111984)){this[_0x8e90('0x8')]=this[_0x8e90('0x8')]['concat'](_0x111984);}else if(_0x111984!==null&&_['isObject'](_0x111984)){this[_0x8e90('0x8')][_0x8e90('0xc')](_0x111984);}this[_0x8e90('0xd')]();};RuleEngine[_0x8e90('0x7')][_0x8e90('0xd')]=function(){this[_0x8e90('0x9')]=this['rules'][_0x8e90('0xe')](function(_0x1edf6a){if(_['isNil'](_0x1edf6a['on'])){_0x1edf6a['on']=!![];}if(_0x1edf6a['on']===!![]){return _0x1edf6a;}});this[_0x8e90('0x9')]=_['orderBy'](this[_0x8e90('0x9')],['p'],[_0x8e90('0xf')]);};RuleEngine['prototype']['execute']=function(_0x17a8aa,_0x1b2a56){var _0x3a8de4=![];_0x17a8aa['result']=!![];var _0x2187b0=_[_0x8e90('0x10')](_0x17a8aa);var _0x1eba4b=_[_0x8e90('0x10')](_0x17a8aa);var _0x4b3169=this[_0x8e90('0x9')];var _0x257625=[];var _0x8f310=this[_0x8e90('0x6')];(function FnRuleLoop(_0xab6e77){var _0x1cc382={'rules':function(){return _0x4b3169;},'rule':function(){return _0x4b3169[_0xab6e77];},'when':function(_0xb6874e){if(_0xb6874e){var _0x3511c3=_0x4b3169[_0xab6e77][_0x8e90('0x11')];_0x3511c3['ruleRef']=_0x4b3169[_0xab6e77]['id']||_0x4b3169[_0xab6e77]['name']||_0x8e90('0x12')+_0xab6e77;process[_0x8e90('0x13')](function(){_0x257625[_0x8e90('0xc')](_0x3511c3[_0x8e90('0x14')]);_0x3511c3[_0x8e90('0x15')](_0x2187b0,_0x1cc382);});}else{process[_0x8e90('0x13')](function(){_0x1cc382[_0x8e90('0x16')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x3a8de4=!![];return FnRuleLoop(0x0);},'next':function(_0x22d859){if(!_0x8f310&&!_[_0x8e90('0x17')](_0x1eba4b,_0x2187b0)){_0x1eba4b=_[_0x8e90('0x10')](_0x2187b0);process[_0x8e90('0x13')](function(){_0x1cc382[_0x8e90('0x18')]();});}else{process['nextTick'](function(){if(_[_0x8e90('0x5')](_0x22d859)){return FnRuleLoop(_0xab6e77+0x1);}else{return FnRuleLoop(_0x22d859);}});}}};if(_0xab6e77<_0x4b3169['length']&&_0x3a8de4===![]){var _0x540838=_0x4b3169[_0xab6e77]['condition'];_0x540838[_0x8e90('0x15')](_0x2187b0,_0x1cc382);}else{process[_0x8e90('0x13')](function(){_0x2187b0[_0x8e90('0x19')]=_0x257625;return _0x1b2a56?_0x1b2a56(_0x2187b0):_[_0x8e90('0x1a')]();});}}(0x0));};RuleEngine['prototype']['findRules']=function(_0x243f29){if(_[_0x8e90('0x5')](_0x243f29)){return this[_0x8e90('0x8')];}else{var _0x2a98d7=_[_0x8e90('0x1b')](_0x243f29);return _[_0x8e90('0xe')](this[_0x8e90('0x8')],_0x2a98d7);}};RuleEngine[_0x8e90('0x7')]['turn']=function(_0x26eacd,_0x51a364){var _0x4825ff=_0x26eacd==='on'||_0x26eacd==='ON'?!![]:![];var _0x58a675=this[_0x8e90('0x1c')](_0x51a364);for(var _0xa76544=0x0,_0x49386a=_0x58a675['length'];_0xa76544<_0x49386a;_0xa76544+=0x1){_0x58a675[_0xa76544]['on']=_0x4825ff;}this[_0x8e90('0xd')]();};RuleEngine[_0x8e90('0x7')]['prioritize']=function(_0x13b82c,_0x54b073){_0x13b82c=parseInt(_0x13b82c,0xa);var _0x1f63f0=this[_0x8e90('0x1c')](_0x54b073);for(var _0x56a3e2=0x0,_0xfc962b=_0x1f63f0[_0x8e90('0x1d')];_0x56a3e2<_0xfc962b;_0x56a3e2+=0x1){_0x1f63f0[_0x56a3e2][_0x8e90('0x1e')]=_0x13b82c;}this[_0x8e90('0xd')]();};RuleEngine[_0x8e90('0x7')][_0x8e90('0x1f')]=function(){var _0x570b22=this[_0x8e90('0x8')];if(_0x570b22 instanceof Array){_0x570b22=_0x570b22[_0x8e90('0x20')](function(_0x2d191b){_0x2d191b[_0x8e90('0x21')]=_0x2d191b[_0x8e90('0x21')][_0x8e90('0x22')]();_0x2d191b[_0x8e90('0x11')]=_0x2d191b[_0x8e90('0x11')][_0x8e90('0x22')]();return _0x2d191b;});}else if(!_[_0x8e90('0x5')](_0x570b22)){_0x570b22[_0x8e90('0x21')]=_0x570b22['condition'][_0x8e90('0x22')]();_0x570b22['consequence']=_0x570b22['consequence']['toString']();}return _0x570b22;};RuleEngine[_0x8e90('0x7')]['fromJSON']=function(_0x7adad9){this[_0x8e90('0x4')]();if(_['isString'](_0x7adad9)){_0x7adad9=JSON[_0x8e90('0x23')](_0x7adad9);}if(_0x7adad9 instanceof Array){_0x7adad9=_0x7adad9['map'](function(_0x1e9c92){_0x1e9c92[_0x8e90('0x21')]=eval('('+_0x1e9c92[_0x8e90('0x21')]+')');_0x1e9c92[_0x8e90('0x11')]=eval('('+_0x1e9c92['consequence']+')');return _0x1e9c92;});}else if(_0x7adad9!==null&&typeof _0x7adad9==_0x8e90('0x24')){_0x7adad9['condition']=eval('('+_0x7adad9['condition']+')');_0x7adad9['consequence']=eval('('+_0x7adad9['consequence']+')');}this[_0x8e90('0xa')](_0x7adad9);};module[_0x8e90('0x25')]=RuleEngine;
\ No newline at end of file
+var _0x2079=['consequence','toString','fromJSON','isString','parse','object','exports','lodash','util','events','EventEmitter','isNil','register','ignoreFactChanges','inherits','prototype','init','rules','isArray','concat','isObject','push','sync','activeRules','filter','orderBy','asc','execute','result','clone','name','ruleRef','call','nextTick','next','isEqual','restart','length','condition','matchPath','turn','prioritize','findRules','priority','toJSON','map'];(function(_0x214d4d,_0x477f6f){var _0xbbc2e3=function(_0x23608f){while(--_0x23608f){_0x214d4d['push'](_0x214d4d['shift']());}};_0xbbc2e3(++_0x477f6f);}(_0x2079,0x1d3));var _0x9207=function(_0x55e64b,_0x1aea90){_0x55e64b=_0x55e64b-0x0;var _0x3edc13=_0x2079[_0x55e64b];return _0x3edc13;};'use strict';var _=require(_0x9207('0x0'));var util=require(_0x9207('0x1'));var EventEmitter=require(_0x9207('0x2'))[_0x9207('0x3')];function RuleEngine(_0x5266db,_0x18ea54){this['init']();if(!_[_0x9207('0x4')](_0x5266db)){this[_0x9207('0x5')](_0x5266db);}if(_0x18ea54){this[_0x9207('0x6')]=_0x18ea54[_0x9207('0x6')];}return this;}util[_0x9207('0x7')](RuleEngine,EventEmitter);RuleEngine[_0x9207('0x8')][_0x9207('0x9')]=function(_0x154935){this[_0x9207('0xa')]=[];this['activeRules']=[];};RuleEngine[_0x9207('0x8')][_0x9207('0x5')]=function(_0x432dd0){if(Array[_0x9207('0xb')](_0x432dd0)){this[_0x9207('0xa')]=this[_0x9207('0xa')][_0x9207('0xc')](_0x432dd0);}else if(_0x432dd0!==null&&_[_0x9207('0xd')](_0x432dd0)){this['rules'][_0x9207('0xe')](_0x432dd0);}this[_0x9207('0xf')]();};RuleEngine[_0x9207('0x8')][_0x9207('0xf')]=function(){this[_0x9207('0x10')]=this[_0x9207('0xa')][_0x9207('0x11')](function(_0xe3c926){if(_[_0x9207('0x4')](_0xe3c926['on'])){_0xe3c926['on']=!![];}if(_0xe3c926['on']===!![]){return _0xe3c926;}});this[_0x9207('0x10')]=_[_0x9207('0x12')](this[_0x9207('0x10')],['p'],[_0x9207('0x13')]);};RuleEngine[_0x9207('0x8')][_0x9207('0x14')]=function(_0x1c4666,_0x132a68){var _0x1e1f06=![];_0x1c4666[_0x9207('0x15')]=!![];var _0x3931bf=_['clone'](_0x1c4666);var _0x20d107=_[_0x9207('0x16')](_0x1c4666);var _0x57a90a=this[_0x9207('0x10')];var _0x49c388=[];var _0x1f5841=this[_0x9207('0x6')];(function FnRuleLoop(_0x11b6a1){var _0x424307={'rules':function(){return _0x57a90a;},'rule':function(){return _0x57a90a[_0x11b6a1];},'when':function(_0x282ad5){if(_0x282ad5){var _0x48bca7=_0x57a90a[_0x11b6a1]['consequence'];_0x48bca7['ruleRef']=_0x57a90a[_0x11b6a1]['id']||_0x57a90a[_0x11b6a1][_0x9207('0x17')]||'index_'+_0x11b6a1;process['nextTick'](function(){_0x49c388['push'](_0x48bca7[_0x9207('0x18')]);_0x48bca7[_0x9207('0x19')](_0x3931bf,_0x424307);});}else{process[_0x9207('0x1a')](function(){_0x424307[_0x9207('0x1b')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x1e1f06=!![];return FnRuleLoop(0x0);},'next':function(_0x454206){if(!_0x1f5841&&!_[_0x9207('0x1c')](_0x20d107,_0x3931bf)){_0x20d107=_[_0x9207('0x16')](_0x3931bf);process[_0x9207('0x1a')](function(){_0x424307[_0x9207('0x1d')]();});}else{process['nextTick'](function(){if(_['isNil'](_0x454206)){return FnRuleLoop(_0x11b6a1+0x1);}else{return FnRuleLoop(_0x454206);}});}}};if(_0x11b6a1<_0x57a90a[_0x9207('0x1e')]&&_0x1e1f06===![]){var _0xb60acc=_0x57a90a[_0x11b6a1][_0x9207('0x1f')];_0xb60acc[_0x9207('0x19')](_0x3931bf,_0x424307);}else{process[_0x9207('0x1a')](function(){_0x3931bf[_0x9207('0x20')]=_0x49c388;return _0x132a68?_0x132a68(_0x3931bf):_['noop']();});}}(0x0));};RuleEngine['prototype']['findRules']=function(_0x5513f1){if(_[_0x9207('0x4')](_0x5513f1)){return this['rules'];}else{var _0x23d0c9=_['matches'](_0x5513f1);return _[_0x9207('0x11')](this['rules'],_0x23d0c9);}};RuleEngine['prototype'][_0x9207('0x21')]=function(_0x4cdab7,_0x32daa3){var _0x75ffa6=_0x4cdab7==='on'||_0x4cdab7==='ON'?!![]:![];var _0x8a7b64=this['findRules'](_0x32daa3);for(var _0x36f34f=0x0,_0x3c604c=_0x8a7b64['length'];_0x36f34f<_0x3c604c;_0x36f34f+=0x1){_0x8a7b64[_0x36f34f]['on']=_0x75ffa6;}this['sync']();};RuleEngine[_0x9207('0x8')][_0x9207('0x22')]=function(_0x4face9,_0x55bdd8){_0x4face9=parseInt(_0x4face9,0xa);var _0x443f18=this[_0x9207('0x23')](_0x55bdd8);for(var _0x368e73=0x0,_0x24a3c2=_0x443f18[_0x9207('0x1e')];_0x368e73<_0x24a3c2;_0x368e73+=0x1){_0x443f18[_0x368e73][_0x9207('0x24')]=_0x4face9;}this['sync']();};RuleEngine['prototype'][_0x9207('0x25')]=function(){var _0x1bd1e4=this[_0x9207('0xa')];if(_0x1bd1e4 instanceof Array){_0x1bd1e4=_0x1bd1e4[_0x9207('0x26')](function(_0x4a367b){_0x4a367b[_0x9207('0x1f')]=_0x4a367b[_0x9207('0x1f')]['toString']();_0x4a367b[_0x9207('0x27')]=_0x4a367b[_0x9207('0x27')][_0x9207('0x28')]();return _0x4a367b;});}else if(!_[_0x9207('0x4')](_0x1bd1e4)){_0x1bd1e4['condition']=_0x1bd1e4[_0x9207('0x1f')]['toString']();_0x1bd1e4[_0x9207('0x27')]=_0x1bd1e4[_0x9207('0x27')][_0x9207('0x28')]();}return _0x1bd1e4;};RuleEngine[_0x9207('0x8')][_0x9207('0x29')]=function(_0x3fc29e){this[_0x9207('0x9')]();if(_[_0x9207('0x2a')](_0x3fc29e)){_0x3fc29e=JSON[_0x9207('0x2b')](_0x3fc29e);}if(_0x3fc29e instanceof Array){_0x3fc29e=_0x3fc29e[_0x9207('0x26')](function(_0x2fe234){_0x2fe234[_0x9207('0x1f')]=eval('('+_0x2fe234[_0x9207('0x1f')]+')');_0x2fe234[_0x9207('0x27')]=eval('('+_0x2fe234[_0x9207('0x27')]+')');return _0x2fe234;});}else if(_0x3fc29e!==null&&typeof _0x3fc29e==_0x9207('0x2c')){_0x3fc29e[_0x9207('0x1f')]=eval('('+_0x3fc29e[_0x9207('0x1f')]+')');_0x3fc29e[_0x9207('0x27')]=eval('('+_0x3fc29e['consequence']+')');}this[_0x9207('0x5')](_0x3fc29e);};module[_0x9207('0x2d')]=RuleEngine;
\ No newline at end of file