Built motion from commit (unavailable).|2.5.31
[motion2.git] / server / services / routing / lib / rule-engine.js
index 7ae1681..d0e9797 100644 (file)
@@ -15,4 +15,4 @@
 // * treaties. The SOFTWARE PRODUCT is licensed, not sold.                        *
 // *                                                                       *
 // *************************************************************************
-var _0xb8c2=['clone','index_','nextTick','ruleRef','call','next','isEqual','restart','length','condition','matchPath','noop','findRules','matches','turn','prioritize','priority','toJSON','map','toString','consequence','parse','object','exports','lodash','util','events','init','register','ignoreFactChanges','rules','prototype','isArray','concat','isObject','push','sync','activeRules','filter','isNil','orderBy','execute','result'];(function(_0xa6eae8,_0xaf8845){var _0x204e02=function(_0x4373fe){while(--_0x4373fe){_0xa6eae8['push'](_0xa6eae8['shift']());}};_0x204e02(++_0xaf8845);}(_0xb8c2,0x6e));var _0x2b8c=function(_0x2641f9,_0x26715f){_0x2641f9=_0x2641f9-0x0;var _0x585741=_0xb8c2[_0x2641f9];return _0x585741;};'use strict';var _=require(_0x2b8c('0x0'));var util=require(_0x2b8c('0x1'));var EventEmitter=require(_0x2b8c('0x2'))['EventEmitter'];function RuleEngine(_0x8f9d7,_0x3603b0){this[_0x2b8c('0x3')]();if(!_['isNil'](_0x8f9d7)){this[_0x2b8c('0x4')](_0x8f9d7);}if(_0x3603b0){this[_0x2b8c('0x5')]=_0x3603b0[_0x2b8c('0x5')];}return this;}util['inherits'](RuleEngine,EventEmitter);RuleEngine['prototype']['init']=function(_0x5c78a5){this[_0x2b8c('0x6')]=[];this['activeRules']=[];};RuleEngine[_0x2b8c('0x7')][_0x2b8c('0x4')]=function(_0x9a1751){if(Array[_0x2b8c('0x8')](_0x9a1751)){this[_0x2b8c('0x6')]=this[_0x2b8c('0x6')][_0x2b8c('0x9')](_0x9a1751);}else if(_0x9a1751!==null&&_[_0x2b8c('0xa')](_0x9a1751)){this['rules'][_0x2b8c('0xb')](_0x9a1751);}this[_0x2b8c('0xc')]();};RuleEngine[_0x2b8c('0x7')]['sync']=function(){this[_0x2b8c('0xd')]=this[_0x2b8c('0x6')][_0x2b8c('0xe')](function(_0x5dce59){if(_[_0x2b8c('0xf')](_0x5dce59['on'])){_0x5dce59['on']=!![];}if(_0x5dce59['on']===!![]){return _0x5dce59;}});this[_0x2b8c('0xd')]=_[_0x2b8c('0x10')](this[_0x2b8c('0xd')],['p'],['asc']);};RuleEngine[_0x2b8c('0x7')][_0x2b8c('0x11')]=function(_0x5161dc,_0xf2c997){var _0x4c3c77=![];_0x5161dc[_0x2b8c('0x12')]=!![];var _0x16572f=_[_0x2b8c('0x13')](_0x5161dc);var _0x13dec4=_[_0x2b8c('0x13')](_0x5161dc);var _0x6d0ec=this[_0x2b8c('0xd')];var _0x3888e6=[];var _0x288728=this[_0x2b8c('0x5')];(function FnRuleLoop(_0x23145a){var _0x534950={'rules':function(){return _0x6d0ec;},'rule':function(){return _0x6d0ec[_0x23145a];},'when':function(_0x5d602c){if(_0x5d602c){var _0x56dcac=_0x6d0ec[_0x23145a]['consequence'];_0x56dcac['ruleRef']=_0x6d0ec[_0x23145a]['id']||_0x6d0ec[_0x23145a]['name']||_0x2b8c('0x14')+_0x23145a;process[_0x2b8c('0x15')](function(){_0x3888e6['push'](_0x56dcac[_0x2b8c('0x16')]);_0x56dcac[_0x2b8c('0x17')](_0x16572f,_0x534950);});}else{process[_0x2b8c('0x15')](function(){_0x534950[_0x2b8c('0x18')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0x4c3c77=!![];return FnRuleLoop(0x0);},'next':function(_0x382bb1){if(!_0x288728&&!_[_0x2b8c('0x19')](_0x13dec4,_0x16572f)){_0x13dec4=_[_0x2b8c('0x13')](_0x16572f);process[_0x2b8c('0x15')](function(){_0x534950[_0x2b8c('0x1a')]();});}else{process['nextTick'](function(){if(_[_0x2b8c('0xf')](_0x382bb1)){return FnRuleLoop(_0x23145a+0x1);}else{return FnRuleLoop(_0x382bb1);}});}}};if(_0x23145a<_0x6d0ec[_0x2b8c('0x1b')]&&_0x4c3c77===![]){var _0x350e74=_0x6d0ec[_0x23145a][_0x2b8c('0x1c')];_0x350e74['call'](_0x16572f,_0x534950);}else{process[_0x2b8c('0x15')](function(){_0x16572f[_0x2b8c('0x1d')]=_0x3888e6;return _0xf2c997?_0xf2c997(_0x16572f):_[_0x2b8c('0x1e')]();});}}(0x0));};RuleEngine[_0x2b8c('0x7')][_0x2b8c('0x1f')]=function(_0x48b79c){if(_[_0x2b8c('0xf')](_0x48b79c)){return this[_0x2b8c('0x6')];}else{var _0x3b5a23=_[_0x2b8c('0x20')](_0x48b79c);return _[_0x2b8c('0xe')](this['rules'],_0x3b5a23);}};RuleEngine[_0x2b8c('0x7')][_0x2b8c('0x21')]=function(_0x2614a0,_0x542516){var _0x153dc6=_0x2614a0==='on'||_0x2614a0==='ON'?!![]:![];var _0x3d2160=this[_0x2b8c('0x1f')](_0x542516);for(var _0x132e33=0x0,_0x3d200a=_0x3d2160[_0x2b8c('0x1b')];_0x132e33<_0x3d200a;_0x132e33+=0x1){_0x3d2160[_0x132e33]['on']=_0x153dc6;}this['sync']();};RuleEngine[_0x2b8c('0x7')][_0x2b8c('0x22')]=function(_0x393804,_0x259ea5){_0x393804=parseInt(_0x393804,0xa);var _0x1205db=this[_0x2b8c('0x1f')](_0x259ea5);for(var _0x3e18eb=0x0,_0x2b6840=_0x1205db[_0x2b8c('0x1b')];_0x3e18eb<_0x2b6840;_0x3e18eb+=0x1){_0x1205db[_0x3e18eb][_0x2b8c('0x23')]=_0x393804;}this[_0x2b8c('0xc')]();};RuleEngine['prototype'][_0x2b8c('0x24')]=function(){var _0x56dc24=this[_0x2b8c('0x6')];if(_0x56dc24 instanceof Array){_0x56dc24=_0x56dc24[_0x2b8c('0x25')](function(_0x137783){_0x137783[_0x2b8c('0x1c')]=_0x137783[_0x2b8c('0x1c')][_0x2b8c('0x26')]();_0x137783['consequence']=_0x137783[_0x2b8c('0x27')][_0x2b8c('0x26')]();return _0x137783;});}else if(!_[_0x2b8c('0xf')](_0x56dc24)){_0x56dc24[_0x2b8c('0x1c')]=_0x56dc24[_0x2b8c('0x1c')][_0x2b8c('0x26')]();_0x56dc24[_0x2b8c('0x27')]=_0x56dc24[_0x2b8c('0x27')][_0x2b8c('0x26')]();}return _0x56dc24;};RuleEngine[_0x2b8c('0x7')]['fromJSON']=function(_0xe9f448){this['init']();if(_['isString'](_0xe9f448)){_0xe9f448=JSON[_0x2b8c('0x28')](_0xe9f448);}if(_0xe9f448 instanceof Array){_0xe9f448=_0xe9f448[_0x2b8c('0x25')](function(_0x510e34){_0x510e34[_0x2b8c('0x1c')]=eval('('+_0x510e34[_0x2b8c('0x1c')]+')');_0x510e34['consequence']=eval('('+_0x510e34['consequence']+')');return _0x510e34;});}else if(_0xe9f448!==null&&typeof _0xe9f448==_0x2b8c('0x29')){_0xe9f448['condition']=eval('('+_0xe9f448[_0x2b8c('0x1c')]+')');_0xe9f448[_0x2b8c('0x27')]=eval('('+_0xe9f448['consequence']+')');}this[_0x2b8c('0x4')](_0xe9f448);};module[_0x2b8c('0x2a')]=RuleEngine;
\ No newline at end of file
+var _0xf55d=['parse','map','object','util','events','EventEmitter','isNil','ignoreFactChanges','inherits','prototype','init','rules','activeRules','register','isArray','concat','isObject','push','sync','orderBy','asc','result','clone','consequence','ruleRef','name','index_','nextTick','call','next','isEqual','restart','length','condition','findRules','matches','turn','prioritize','priority','toJSON','toString','fromJSON','isString'];(function(_0x17ea31,_0x224963){var _0x16fec7=function(_0xca2451){while(--_0xca2451){_0x17ea31['push'](_0x17ea31['shift']());}};_0x16fec7(++_0x224963);}(_0xf55d,0xaf));var _0xdf55=function(_0x791367,_0x3c855e){_0x791367=_0x791367-0x0;var _0x6cb69=_0xf55d[_0x791367];return _0x6cb69;};'use strict';var _=require('lodash');var util=require(_0xdf55('0x0'));var EventEmitter=require(_0xdf55('0x1'))[_0xdf55('0x2')];function RuleEngine(_0x2773c8,_0x19c377){this['init']();if(!_[_0xdf55('0x3')](_0x2773c8)){this['register'](_0x2773c8);}if(_0x19c377){this[_0xdf55('0x4')]=_0x19c377['ignoreFactChanges'];}return this;}util[_0xdf55('0x5')](RuleEngine,EventEmitter);RuleEngine[_0xdf55('0x6')][_0xdf55('0x7')]=function(_0xe2fbb9){this[_0xdf55('0x8')]=[];this[_0xdf55('0x9')]=[];};RuleEngine[_0xdf55('0x6')][_0xdf55('0xa')]=function(_0x29e7ec){if(Array[_0xdf55('0xb')](_0x29e7ec)){this[_0xdf55('0x8')]=this[_0xdf55('0x8')][_0xdf55('0xc')](_0x29e7ec);}else if(_0x29e7ec!==null&&_[_0xdf55('0xd')](_0x29e7ec)){this[_0xdf55('0x8')][_0xdf55('0xe')](_0x29e7ec);}this[_0xdf55('0xf')]();};RuleEngine['prototype']['sync']=function(){this[_0xdf55('0x9')]=this[_0xdf55('0x8')]['filter'](function(_0x1e5b3e){if(_[_0xdf55('0x3')](_0x1e5b3e['on'])){_0x1e5b3e['on']=!![];}if(_0x1e5b3e['on']===!![]){return _0x1e5b3e;}});this['activeRules']=_[_0xdf55('0x10')](this[_0xdf55('0x9')],['p'],[_0xdf55('0x11')]);};RuleEngine[_0xdf55('0x6')]['execute']=function(_0x584540,_0x4b69da){var _0xa10b8=![];_0x584540[_0xdf55('0x12')]=!![];var _0x445961=_['clone'](_0x584540);var _0x17fefa=_[_0xdf55('0x13')](_0x584540);var _0x14dc7f=this[_0xdf55('0x9')];var _0x32d130=[];var _0x18f0a7=this[_0xdf55('0x4')];(function FnRuleLoop(_0x3b1118){var _0x20dc09={'rules':function(){return _0x14dc7f;},'rule':function(){return _0x14dc7f[_0x3b1118];},'when':function(_0x2342ea){if(_0x2342ea){var _0x5b2c36=_0x14dc7f[_0x3b1118][_0xdf55('0x14')];_0x5b2c36[_0xdf55('0x15')]=_0x14dc7f[_0x3b1118]['id']||_0x14dc7f[_0x3b1118][_0xdf55('0x16')]||_0xdf55('0x17')+_0x3b1118;process[_0xdf55('0x18')](function(){_0x32d130['push'](_0x5b2c36[_0xdf55('0x15')]);_0x5b2c36[_0xdf55('0x19')](_0x445961,_0x20dc09);});}else{process[_0xdf55('0x18')](function(){_0x20dc09[_0xdf55('0x1a')]();});}},'restart':function(){return FnRuleLoop(0x0);},'stop':function(){_0xa10b8=!![];return FnRuleLoop(0x0);},'next':function(_0x4c315f){if(!_0x18f0a7&&!_[_0xdf55('0x1b')](_0x17fefa,_0x445961)){_0x17fefa=_[_0xdf55('0x13')](_0x445961);process[_0xdf55('0x18')](function(){_0x20dc09[_0xdf55('0x1c')]();});}else{process['nextTick'](function(){if(_[_0xdf55('0x3')](_0x4c315f)){return FnRuleLoop(_0x3b1118+0x1);}else{return FnRuleLoop(_0x4c315f);}});}}};if(_0x3b1118<_0x14dc7f[_0xdf55('0x1d')]&&_0xa10b8===![]){var _0x5ecc9f=_0x14dc7f[_0x3b1118][_0xdf55('0x1e')];_0x5ecc9f[_0xdf55('0x19')](_0x445961,_0x20dc09);}else{process[_0xdf55('0x18')](function(){_0x445961['matchPath']=_0x32d130;return _0x4b69da?_0x4b69da(_0x445961):_['noop']();});}}(0x0));};RuleEngine[_0xdf55('0x6')][_0xdf55('0x1f')]=function(_0x1e4fef){if(_[_0xdf55('0x3')](_0x1e4fef)){return this['rules'];}else{var _0x45851d=_[_0xdf55('0x20')](_0x1e4fef);return _['filter'](this['rules'],_0x45851d);}};RuleEngine[_0xdf55('0x6')][_0xdf55('0x21')]=function(_0xf9ae2a,_0x3f9dd7){var _0x3f070d=_0xf9ae2a==='on'||_0xf9ae2a==='ON'?!![]:![];var _0x2f9d56=this[_0xdf55('0x1f')](_0x3f9dd7);for(var _0x53288e=0x0,_0x321edf=_0x2f9d56[_0xdf55('0x1d')];_0x53288e<_0x321edf;_0x53288e+=0x1){_0x2f9d56[_0x53288e]['on']=_0x3f070d;}this[_0xdf55('0xf')]();};RuleEngine[_0xdf55('0x6')][_0xdf55('0x22')]=function(_0x2acb79,_0x22278f){_0x2acb79=parseInt(_0x2acb79,0xa);var _0x154960=this[_0xdf55('0x1f')](_0x22278f);for(var _0x2fbbe0=0x0,_0x37c6b7=_0x154960[_0xdf55('0x1d')];_0x2fbbe0<_0x37c6b7;_0x2fbbe0+=0x1){_0x154960[_0x2fbbe0][_0xdf55('0x23')]=_0x2acb79;}this['sync']();};RuleEngine[_0xdf55('0x6')][_0xdf55('0x24')]=function(){var _0x167317=this[_0xdf55('0x8')];if(_0x167317 instanceof Array){_0x167317=_0x167317['map'](function(_0x37b672){_0x37b672[_0xdf55('0x1e')]=_0x37b672[_0xdf55('0x1e')][_0xdf55('0x25')]();_0x37b672[_0xdf55('0x14')]=_0x37b672[_0xdf55('0x14')]['toString']();return _0x37b672;});}else if(!_[_0xdf55('0x3')](_0x167317)){_0x167317[_0xdf55('0x1e')]=_0x167317[_0xdf55('0x1e')][_0xdf55('0x25')]();_0x167317[_0xdf55('0x14')]=_0x167317[_0xdf55('0x14')][_0xdf55('0x25')]();}return _0x167317;};RuleEngine[_0xdf55('0x6')][_0xdf55('0x26')]=function(_0x2121dc){this[_0xdf55('0x7')]();if(_[_0xdf55('0x27')](_0x2121dc)){_0x2121dc=JSON[_0xdf55('0x28')](_0x2121dc);}if(_0x2121dc instanceof Array){_0x2121dc=_0x2121dc[_0xdf55('0x29')](function(_0x54ae7e){_0x54ae7e['condition']=eval('('+_0x54ae7e[_0xdf55('0x1e')]+')');_0x54ae7e[_0xdf55('0x14')]=eval('('+_0x54ae7e[_0xdf55('0x14')]+')');return _0x54ae7e;});}else if(_0x2121dc!==null&&typeof _0x2121dc==_0xdf55('0x2a')){_0x2121dc[_0xdf55('0x1e')]=eval('('+_0x2121dc[_0xdf55('0x1e')]+')');_0x2121dc[_0xdf55('0x14')]=eval('('+_0x2121dc[_0xdf55('0x14')]+')');}this['register'](_0x2121dc);};module['exports']=RuleEngine;
\ No newline at end of file