diff --git a/coverage/coverage.json b/coverage/coverage.json index ec49323..0ac12b2 100644 --- a/coverage/coverage.json +++ b/coverage/coverage.json @@ -1 +1 @@ -{"/Users/smithun/Desktop/github/node-rules/index.js":{"path":"/Users/smithun/Desktop/github/node-rules/index.js","s":{"1":1,"2":1},"b":{},"f":{"1":1},"fnMap":{"1":{"name":"(anonymous_1)","line":7,"loc":{"start":{"line":7,"column":1},"end":{"line":7,"column":12}}}},"statementMap":{"1":{"start":{"line":7,"column":0},"end":{"line":11,"column":19}},"2":{"start":{"line":10,"column":4},"end":{"line":10,"column":49}}},"branchMap":{}},"/Users/smithun/Desktop/github/node-rules/lib/node-rules.js":{"path":"/Users/smithun/Desktop/github/node-rules/lib/node-rules.js","s":{"1":1,"2":1,"3":1,"4":1,"5":20,"6":20,"7":17,"8":20,"9":1,"10":20,"11":1,"12":23,"13":23,"14":1,"15":22,"16":16,"17":6,"18":6,"19":22,"20":1,"21":26,"22":46,"23":25,"24":46,"25":41,"26":26,"27":20,"28":13,"29":7,"30":1,"31":6,"32":6,"33":6,"34":6,"35":6,"36":6,"37":6,"38":6,"39":17,"40":2,"41":11,"42":9,"43":9,"44":9,"45":9,"46":9,"47":2,"48":2,"49":0,"50":4,"51":4,"52":7,"53":0,"54":0,"55":0,"56":7,"57":7,"58":17,"59":11,"60":11,"61":6,"62":6,"63":6,"64":1,"65":10,"66":1,"67":9,"68":9,"69":1,"70":2,"71":2,"72":2,"73":2,"74":2,"75":1,"76":2,"77":2,"78":2,"79":2,"80":2,"81":1,"82":2,"83":2,"84":2,"85":2,"86":2,"87":2,"88":0,"89":0,"90":0,"91":2,"92":1,"93":2,"94":2,"95":0,"96":2,"97":2,"98":2,"99":2,"100":2,"101":0,"102":0,"103":0,"104":2,"105":1},"b":{"1":[17,3],"2":[1,19],"3":[16,6],"4":[6,0],"5":[6,6],"6":[25,21],"7":[41,5],"8":[13,7],"9":[20,13],"10":[9,2],"11":[9,7,5],"12":[0,7],"13":[7,6],"14":[11,6],"15":[17,15],"16":[1,9],"17":[1,1],"18":[2,2],"19":[2,0],"20":[0,0],"21":[0,2],"22":[2,0],"23":[0,0],"24":[0,0]},"f":{"1":1,"2":20,"3":23,"4":22,"5":26,"6":46,"7":20,"8":6,"9":17,"10":2,"11":11,"12":9,"13":2,"14":0,"15":4,"16":7,"17":0,"18":7,"19":6,"20":10,"21":2,"22":2,"23":2,"24":2,"25":2,"26":2},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":12}}},"2":{"name":"RuleEngine","line":6,"loc":{"start":{"line":6,"column":4},"end":{"line":6,"column":40}}},"3":{"name":"(anonymous_3)","line":16,"loc":{"start":{"line":16,"column":32},"end":{"line":16,"column":48}}},"4":{"name":"(anonymous_4)","line":20,"loc":{"start":{"line":20,"column":36},"end":{"line":20,"column":52}}},"5":{"name":"(anonymous_5)","line":28,"loc":{"start":{"line":28,"column":32},"end":{"line":28,"column":43}}},"6":{"name":"(anonymous_6)","line":29,"loc":{"start":{"line":29,"column":45},"end":{"line":29,"column":57}}},"7":{"name":"(anonymous_7)","line":37,"loc":{"start":{"line":37,"column":30},"end":{"line":37,"column":45}}},"8":{"name":"(anonymous_8)","line":45,"loc":{"start":{"line":45,"column":35},"end":{"line":45,"column":60}}},"9":{"name":"FnRuleLoop","line":55,"loc":{"start":{"line":55,"column":9},"end":{"line":55,"column":32}}},"10":{"name":"(anonymous_10)","line":57,"loc":{"start":{"line":57,"column":24},"end":{"line":57,"column":35}}},"11":{"name":"(anonymous_11)","line":58,"loc":{"start":{"line":58,"column":24},"end":{"line":58,"column":42}}},"12":{"name":"(anonymous_12)","line":62,"loc":{"start":{"line":62,"column":41},"end":{"line":62,"column":52}}},"13":{"name":"(anonymous_13)","line":67,"loc":{"start":{"line":67,"column":41},"end":{"line":67,"column":52}}},"14":{"name":"(anonymous_14)","line":72,"loc":{"start":{"line":72,"column":27},"end":{"line":72,"column":38}}},"15":{"name":"(anonymous_15)","line":75,"loc":{"start":{"line":75,"column":24},"end":{"line":75,"column":35}}},"16":{"name":"(anonymous_16)","line":79,"loc":{"start":{"line":79,"column":24},"end":{"line":79,"column":35}}},"17":{"name":"(anonymous_17)","line":82,"loc":{"start":{"line":82,"column":41},"end":{"line":82,"column":52}}},"18":{"name":"(anonymous_18)","line":86,"loc":{"start":{"line":86,"column":41},"end":{"line":86,"column":52}}},"19":{"name":"(anonymous_19)","line":96,"loc":{"start":{"line":96,"column":33},"end":{"line":96,"column":44}}},"20":{"name":"(anonymous_20)","line":103,"loc":{"start":{"line":103,"column":37},"end":{"line":103,"column":54}}},"21":{"name":"(anonymous_21)","line":111,"loc":{"start":{"line":111,"column":32},"end":{"line":111,"column":56}}},"22":{"name":"(anonymous_22)","line":119,"loc":{"start":{"line":119,"column":38},"end":{"line":119,"column":65}}},"23":{"name":"(anonymous_23)","line":127,"loc":{"start":{"line":127,"column":34},"end":{"line":127,"column":45}}},"24":{"name":"(anonymous_24)","line":130,"loc":{"start":{"line":130,"column":30},"end":{"line":130,"column":45}}},"25":{"name":"(anonymous_25)","line":141,"loc":{"start":{"line":141,"column":36},"end":{"line":141,"column":52}}},"26":{"name":"(anonymous_26)","line":147,"loc":{"start":{"line":147,"column":30},"end":{"line":147,"column":45}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":159,"column":19}},"2":{"start":{"line":3,"column":4},"end":{"line":3,"column":34}},"3":{"start":{"line":4,"column":4},"end":{"line":4,"column":30}},"4":{"start":{"line":6,"column":4},"end":{"line":15,"column":5}},"5":{"start":{"line":7,"column":8},"end":{"line":7,"column":20}},"6":{"start":{"line":8,"column":8},"end":{"line":10,"column":9}},"7":{"start":{"line":9,"column":12},"end":{"line":9,"column":33}},"8":{"start":{"line":11,"column":8},"end":{"line":13,"column":9}},"9":{"start":{"line":12,"column":12},"end":{"line":12,"column":63}},"10":{"start":{"line":14,"column":8},"end":{"line":14,"column":20}},"11":{"start":{"line":16,"column":4},"end":{"line":19,"column":6}},"12":{"start":{"line":17,"column":8},"end":{"line":17,"column":24}},"13":{"start":{"line":18,"column":8},"end":{"line":18,"column":30}},"14":{"start":{"line":20,"column":4},"end":{"line":27,"column":6}},"15":{"start":{"line":21,"column":8},"end":{"line":25,"column":9}},"16":{"start":{"line":22,"column":12},"end":{"line":22,"column":50}},"17":{"start":{"line":23,"column":15},"end":{"line":25,"column":9}},"18":{"start":{"line":24,"column":12},"end":{"line":24,"column":35}},"19":{"start":{"line":26,"column":8},"end":{"line":26,"column":20}},"20":{"start":{"line":28,"column":4},"end":{"line":44,"column":6}},"21":{"start":{"line":29,"column":8},"end":{"line":36,"column":11}},"22":{"start":{"line":30,"column":12},"end":{"line":32,"column":13}},"23":{"start":{"line":31,"column":16},"end":{"line":31,"column":28}},"24":{"start":{"line":33,"column":12},"end":{"line":35,"column":13}},"25":{"start":{"line":34,"column":16},"end":{"line":34,"column":25}},"26":{"start":{"line":37,"column":8},"end":{"line":43,"column":11}},"27":{"start":{"line":38,"column":12},"end":{"line":42,"column":13}},"28":{"start":{"line":39,"column":16},"end":{"line":39,"column":47}},"29":{"start":{"line":41,"column":16},"end":{"line":41,"column":25}},"30":{"start":{"line":45,"column":4},"end":{"line":102,"column":6}},"31":{"start":{"line":48,"column":8},"end":{"line":48,"column":29}},"32":{"start":{"line":49,"column":8},"end":{"line":49,"column":27}},"33":{"start":{"line":50,"column":8},"end":{"line":50,"column":36}},"34":{"start":{"line":51,"column":8},"end":{"line":51,"column":40}},"35":{"start":{"line":52,"column":8},"end":{"line":52,"column":38}},"36":{"start":{"line":53,"column":8},"end":{"line":53,"column":27}},"37":{"start":{"line":54,"column":8},"end":{"line":54,"column":55}},"38":{"start":{"line":55,"column":8},"end":{"line":101,"column":14}},"39":{"start":{"line":56,"column":12},"end":{"line":91,"column":14}},"40":{"start":{"line":57,"column":37},"end":{"line":57,"column":54}},"41":{"start":{"line":59,"column":20},"end":{"line":70,"column":21}},"42":{"start":{"line":60,"column":24},"end":{"line":60,"column":65}},"43":{"start":{"line":61,"column":24},"end":{"line":61,"column":92}},"44":{"start":{"line":62,"column":24},"end":{"line":65,"column":27}},"45":{"start":{"line":63,"column":28},"end":{"line":63,"column":65}},"46":{"start":{"line":64,"column":28},"end":{"line":64,"column":69}},"47":{"start":{"line":67,"column":24},"end":{"line":69,"column":27}},"48":{"start":{"line":68,"column":28},"end":{"line":68,"column":39}},"49":{"start":{"line":73,"column":20},"end":{"line":73,"column":41}},"50":{"start":{"line":76,"column":20},"end":{"line":76,"column":36}},"51":{"start":{"line":77,"column":20},"end":{"line":77,"column":41}},"52":{"start":{"line":80,"column":20},"end":{"line":89,"column":21}},"53":{"start":{"line":81,"column":24},"end":{"line":81,"column":55}},"54":{"start":{"line":82,"column":24},"end":{"line":84,"column":27}},"55":{"start":{"line":83,"column":28},"end":{"line":83,"column":42}},"56":{"start":{"line":86,"column":24},"end":{"line":88,"column":27}},"57":{"start":{"line":87,"column":28},"end":{"line":87,"column":53}},"58":{"start":{"line":92,"column":12},"end":{"line":100,"column":13}},"59":{"start":{"line":93,"column":16},"end":{"line":93,"column":48}},"60":{"start":{"line":94,"column":16},"end":{"line":94,"column":50}},"61":{"start":{"line":96,"column":16},"end":{"line":99,"column":19}},"62":{"start":{"line":97,"column":20},"end":{"line":97,"column":50}},"63":{"start":{"line":98,"column":20},"end":{"line":98,"column":45}},"64":{"start":{"line":103,"column":4},"end":{"line":110,"column":5}},"65":{"start":{"line":104,"column":8},"end":{"line":109,"column":9}},"66":{"start":{"line":105,"column":12},"end":{"line":105,"column":30}},"67":{"start":{"line":107,"column":12},"end":{"line":107,"column":41}},"68":{"start":{"line":108,"column":12},"end":{"line":108,"column":46}},"69":{"start":{"line":111,"column":4},"end":{"line":118,"column":5}},"70":{"start":{"line":112,"column":8},"end":{"line":112,"column":70}},"71":{"start":{"line":113,"column":8},"end":{"line":113,"column":43}},"72":{"start":{"line":114,"column":8},"end":{"line":116,"column":9}},"73":{"start":{"line":115,"column":12},"end":{"line":115,"column":32}},"74":{"start":{"line":117,"column":8},"end":{"line":117,"column":20}},"75":{"start":{"line":119,"column":4},"end":{"line":126,"column":5}},"76":{"start":{"line":120,"column":8},"end":{"line":120,"column":42}},"77":{"start":{"line":121,"column":8},"end":{"line":121,"column":43}},"78":{"start":{"line":122,"column":8},"end":{"line":124,"column":9}},"79":{"start":{"line":123,"column":12},"end":{"line":123,"column":41}},"80":{"start":{"line":125,"column":8},"end":{"line":125,"column":20}},"81":{"start":{"line":127,"column":4},"end":{"line":140,"column":6}},"82":{"start":{"line":128,"column":8},"end":{"line":128,"column":31}},"83":{"start":{"line":129,"column":8},"end":{"line":138,"column":9}},"84":{"start":{"line":130,"column":12},"end":{"line":134,"column":15}},"85":{"start":{"line":131,"column":16},"end":{"line":131,"column":59}},"86":{"start":{"line":132,"column":16},"end":{"line":132,"column":63}},"87":{"start":{"line":133,"column":16},"end":{"line":133,"column":28}},"88":{"start":{"line":135,"column":15},"end":{"line":138,"column":9}},"89":{"start":{"line":136,"column":12},"end":{"line":136,"column":57}},"90":{"start":{"line":137,"column":12},"end":{"line":137,"column":61}},"91":{"start":{"line":139,"column":8},"end":{"line":139,"column":21}},"92":{"start":{"line":141,"column":4},"end":{"line":157,"column":6}},"93":{"start":{"line":142,"column":8},"end":{"line":142,"column":20}},"94":{"start":{"line":143,"column":8},"end":{"line":145,"column":9}},"95":{"start":{"line":144,"column":12},"end":{"line":144,"column":38}},"96":{"start":{"line":146,"column":8},"end":{"line":155,"column":9}},"97":{"start":{"line":147,"column":12},"end":{"line":151,"column":15}},"98":{"start":{"line":148,"column":16},"end":{"line":148,"column":66}},"99":{"start":{"line":149,"column":16},"end":{"line":149,"column":70}},"100":{"start":{"line":150,"column":16},"end":{"line":150,"column":28}},"101":{"start":{"line":152,"column":15},"end":{"line":155,"column":9}},"102":{"start":{"line":153,"column":12},"end":{"line":153,"column":64}},"103":{"start":{"line":154,"column":12},"end":{"line":154,"column":68}},"104":{"start":{"line":156,"column":8},"end":{"line":156,"column":29}},"105":{"start":{"line":158,"column":4},"end":{"line":158,"column":32}}},"branchMap":{"1":{"line":8,"type":"if","locations":[{"start":{"line":8,"column":8},"end":{"line":8,"column":8}},{"start":{"line":8,"column":8},"end":{"line":8,"column":8}}]},"2":{"line":11,"type":"if","locations":[{"start":{"line":11,"column":8},"end":{"line":11,"column":8}},{"start":{"line":11,"column":8},"end":{"line":11,"column":8}}]},"3":{"line":21,"type":"if","locations":[{"start":{"line":21,"column":8},"end":{"line":21,"column":8}},{"start":{"line":21,"column":8},"end":{"line":21,"column":8}}]},"4":{"line":23,"type":"if","locations":[{"start":{"line":23,"column":15},"end":{"line":23,"column":15}},{"start":{"line":23,"column":15},"end":{"line":23,"column":15}}]},"5":{"line":23,"type":"binary-expr","locations":[{"start":{"line":23,"column":19},"end":{"line":23,"column":33}},{"start":{"line":23,"column":37},"end":{"line":23,"column":62}}]},"6":{"line":30,"type":"if","locations":[{"start":{"line":30,"column":12},"end":{"line":30,"column":12}},{"start":{"line":30,"column":12},"end":{"line":30,"column":12}}]},"7":{"line":33,"type":"if","locations":[{"start":{"line":33,"column":12},"end":{"line":33,"column":12}},{"start":{"line":33,"column":12},"end":{"line":33,"column":12}}]},"8":{"line":38,"type":"if","locations":[{"start":{"line":38,"column":12},"end":{"line":38,"column":12}},{"start":{"line":38,"column":12},"end":{"line":38,"column":12}}]},"9":{"line":38,"type":"binary-expr","locations":[{"start":{"line":38,"column":16},"end":{"line":38,"column":26}},{"start":{"line":38,"column":30},"end":{"line":38,"column":40}}]},"10":{"line":59,"type":"if","locations":[{"start":{"line":59,"column":20},"end":{"line":59,"column":20}},{"start":{"line":59,"column":20},"end":{"line":59,"column":20}}]},"11":{"line":61,"type":"binary-expr","locations":[{"start":{"line":61,"column":47},"end":{"line":61,"column":59}},{"start":{"line":61,"column":63},"end":{"line":61,"column":77}},{"start":{"line":61,"column":81},"end":{"line":61,"column":91}}]},"12":{"line":80,"type":"if","locations":[{"start":{"line":80,"column":20},"end":{"line":80,"column":20}},{"start":{"line":80,"column":20},"end":{"line":80,"column":20}}]},"13":{"line":80,"type":"binary-expr","locations":[{"start":{"line":80,"column":24},"end":{"line":80,"column":42}},{"start":{"line":80,"column":46},"end":{"line":80,"column":78}}]},"14":{"line":92,"type":"if","locations":[{"start":{"line":92,"column":12},"end":{"line":92,"column":12}},{"start":{"line":92,"column":12},"end":{"line":92,"column":12}}]},"15":{"line":92,"type":"binary-expr","locations":[{"start":{"line":92,"column":16},"end":{"line":92,"column":33}},{"start":{"line":92,"column":37},"end":{"line":92,"column":55}}]},"16":{"line":104,"type":"if","locations":[{"start":{"line":104,"column":8},"end":{"line":104,"column":8}},{"start":{"line":104,"column":8},"end":{"line":104,"column":8}}]},"17":{"line":112,"type":"cond-expr","locations":[{"start":{"line":112,"column":57},"end":{"line":112,"column":61}},{"start":{"line":112,"column":64},"end":{"line":112,"column":69}}]},"18":{"line":112,"type":"binary-expr","locations":[{"start":{"line":112,"column":21},"end":{"line":112,"column":35}},{"start":{"line":112,"column":39},"end":{"line":112,"column":53}}]},"19":{"line":129,"type":"if","locations":[{"start":{"line":129,"column":8},"end":{"line":129,"column":8}},{"start":{"line":129,"column":8},"end":{"line":129,"column":8}}]},"20":{"line":135,"type":"if","locations":[{"start":{"line":135,"column":15},"end":{"line":135,"column":15}},{"start":{"line":135,"column":15},"end":{"line":135,"column":15}}]},"21":{"line":143,"type":"if","locations":[{"start":{"line":143,"column":8},"end":{"line":143,"column":8}},{"start":{"line":143,"column":8},"end":{"line":143,"column":8}}]},"22":{"line":146,"type":"if","locations":[{"start":{"line":146,"column":8},"end":{"line":146,"column":8}},{"start":{"line":146,"column":8},"end":{"line":146,"column":8}}]},"23":{"line":152,"type":"if","locations":[{"start":{"line":152,"column":15},"end":{"line":152,"column":15}},{"start":{"line":152,"column":15},"end":{"line":152,"column":15}}]},"24":{"line":152,"type":"binary-expr","locations":[{"start":{"line":152,"column":19},"end":{"line":152,"column":33}},{"start":{"line":152,"column":37},"end":{"line":152,"column":62}}]}}}} \ No newline at end of file +{"/Users/smithun/Desktop/NodeRules/node-rules/index.js":{"path":"/Users/smithun/Desktop/NodeRules/node-rules/index.js","s":{"1":1,"2":1},"b":{},"f":{"1":1},"fnMap":{"1":{"name":"(anonymous_1)","line":7,"loc":{"start":{"line":7,"column":1},"end":{"line":7,"column":12}}}},"statementMap":{"1":{"start":{"line":7,"column":0},"end":{"line":11,"column":19}},"2":{"start":{"line":10,"column":4},"end":{"line":10,"column":49}}},"branchMap":{}},"/Users/smithun/Desktop/NodeRules/node-rules/lib/node-rules.js":{"path":"/Users/smithun/Desktop/NodeRules/node-rules/lib/node-rules.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":20,"7":20,"8":17,"9":20,"10":1,"11":20,"12":1,"13":21,"14":21,"15":1,"16":21,"17":14,"18":7,"19":7,"20":21,"21":1,"22":25,"23":49,"24":29,"25":49,"26":44,"27":25,"28":24,"29":16,"30":8,"31":1,"32":9,"33":9,"34":9,"35":9,"36":9,"37":9,"38":9,"39":9,"40":9,"41":30,"42":2,"43":21,"44":13,"45":13,"46":13,"47":13,"48":13,"49":8,"50":8,"51":1,"52":7,"53":7,"54":14,"55":1,"56":1,"57":1,"58":13,"59":13,"60":30,"61":30,"62":21,"63":21,"64":9,"65":9,"66":9,"67":1,"68":44,"69":21,"70":23,"71":1,"72":11,"73":1,"74":10,"75":11,"76":10,"77":23,"78":23,"79":1,"80":2,"81":2,"82":2,"83":2,"84":2,"85":1,"86":2,"87":2,"88":2,"89":2,"90":2,"91":1},"b":{"1":[17,3],"2":[1,19],"3":[14,7],"4":[7,0],"5":[7,7],"6":[29,20],"7":[44,5],"8":[16,8],"9":[24,16],"10":[13,8],"11":[13,11,6],"12":[1,13],"13":[14,13],"14":[21,9],"15":[30,28],"16":[21,23],"17":[44,44],"18":[1,10],"19":[11,1],"20":[1,1],"21":[2,2]},"f":{"1":1,"2":20,"3":21,"4":21,"5":25,"6":49,"7":24,"8":9,"9":30,"10":2,"11":21,"12":13,"13":8,"14":1,"15":7,"16":14,"17":1,"18":13,"19":9,"20":44,"21":11,"22":23,"23":23,"24":2,"25":2},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":1},"end":{"line":1,"column":12}}},"2":{"name":"RuleEngine","line":8,"loc":{"start":{"line":8,"column":4},"end":{"line":8,"column":40}}},"3":{"name":"(anonymous_3)","line":18,"loc":{"start":{"line":18,"column":32},"end":{"line":18,"column":48}}},"4":{"name":"(anonymous_4)","line":22,"loc":{"start":{"line":22,"column":36},"end":{"line":22,"column":52}}},"5":{"name":"(anonymous_5)","line":30,"loc":{"start":{"line":30,"column":32},"end":{"line":30,"column":43}}},"6":{"name":"(anonymous_6)","line":31,"loc":{"start":{"line":31,"column":45},"end":{"line":31,"column":57}}},"7":{"name":"(anonymous_7)","line":39,"loc":{"start":{"line":39,"column":30},"end":{"line":39,"column":45}}},"8":{"name":"(anonymous_8)","line":47,"loc":{"start":{"line":47,"column":35},"end":{"line":47,"column":60}}},"9":{"name":"FnRuleLoop","line":58,"loc":{"start":{"line":58,"column":9},"end":{"line":58,"column":32}}},"10":{"name":"(anonymous_10)","line":60,"loc":{"start":{"line":60,"column":24},"end":{"line":60,"column":35}}},"11":{"name":"(anonymous_11)","line":61,"loc":{"start":{"line":61,"column":24},"end":{"line":61,"column":42}}},"12":{"name":"(anonymous_12)","line":65,"loc":{"start":{"line":65,"column":44},"end":{"line":65,"column":55}}},"13":{"name":"(anonymous_13)","line":70,"loc":{"start":{"line":70,"column":44},"end":{"line":70,"column":55}}},"14":{"name":"(anonymous_14)","line":75,"loc":{"start":{"line":75,"column":27},"end":{"line":75,"column":38}}},"15":{"name":"(anonymous_15)","line":78,"loc":{"start":{"line":78,"column":24},"end":{"line":78,"column":35}}},"16":{"name":"(anonymous_16)","line":82,"loc":{"start":{"line":82,"column":24},"end":{"line":82,"column":35}}},"17":{"name":"(anonymous_17)","line":85,"loc":{"start":{"line":85,"column":44},"end":{"line":85,"column":55}}},"18":{"name":"(anonymous_18)","line":89,"loc":{"start":{"line":89,"column":44},"end":{"line":89,"column":55}}},"19":{"name":"(anonymous_19)","line":100,"loc":{"start":{"line":100,"column":36},"end":{"line":100,"column":47}}},"20":{"name":"(anonymous_20)","line":107,"loc":{"start":{"line":107,"column":36},"end":{"line":107,"column":57}}},"21":{"name":"(anonymous_21)","line":114,"loc":{"start":{"line":114,"column":37},"end":{"line":114,"column":53}}},"22":{"name":"(anonymous_22)","line":121,"loc":{"start":{"line":121,"column":37},"end":{"line":121,"column":53}}},"23":{"name":"(anonymous_23)","line":122,"loc":{"start":{"line":122,"column":47},"end":{"line":122,"column":62}}},"24":{"name":"(anonymous_24)","line":128,"loc":{"start":{"line":128,"column":32},"end":{"line":128,"column":56}}},"25":{"name":"(anonymous_25)","line":136,"loc":{"start":{"line":136,"column":38},"end":{"line":136,"column":65}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":145,"column":19}},"2":{"start":{"line":3,"column":4},"end":{"line":3,"column":30}},"3":{"start":{"line":5,"column":4},"end":{"line":5,"column":44}},"4":{"start":{"line":6,"column":4},"end":{"line":6,"column":48}},"5":{"start":{"line":8,"column":4},"end":{"line":17,"column":5}},"6":{"start":{"line":9,"column":8},"end":{"line":9,"column":20}},"7":{"start":{"line":10,"column":8},"end":{"line":12,"column":9}},"8":{"start":{"line":11,"column":12},"end":{"line":11,"column":33}},"9":{"start":{"line":13,"column":8},"end":{"line":15,"column":9}},"10":{"start":{"line":14,"column":12},"end":{"line":14,"column":63}},"11":{"start":{"line":16,"column":8},"end":{"line":16,"column":20}},"12":{"start":{"line":18,"column":4},"end":{"line":21,"column":6}},"13":{"start":{"line":19,"column":8},"end":{"line":19,"column":24}},"14":{"start":{"line":20,"column":8},"end":{"line":20,"column":30}},"15":{"start":{"line":22,"column":4},"end":{"line":29,"column":6}},"16":{"start":{"line":23,"column":8},"end":{"line":27,"column":9}},"17":{"start":{"line":24,"column":12},"end":{"line":24,"column":50}},"18":{"start":{"line":25,"column":15},"end":{"line":27,"column":9}},"19":{"start":{"line":26,"column":12},"end":{"line":26,"column":35}},"20":{"start":{"line":28,"column":8},"end":{"line":28,"column":20}},"21":{"start":{"line":30,"column":4},"end":{"line":46,"column":6}},"22":{"start":{"line":31,"column":8},"end":{"line":38,"column":11}},"23":{"start":{"line":32,"column":12},"end":{"line":34,"column":13}},"24":{"start":{"line":33,"column":16},"end":{"line":33,"column":28}},"25":{"start":{"line":35,"column":12},"end":{"line":37,"column":13}},"26":{"start":{"line":36,"column":16},"end":{"line":36,"column":25}},"27":{"start":{"line":39,"column":8},"end":{"line":45,"column":11}},"28":{"start":{"line":40,"column":12},"end":{"line":44,"column":13}},"29":{"start":{"line":41,"column":16},"end":{"line":41,"column":47}},"30":{"start":{"line":43,"column":16},"end":{"line":43,"column":25}},"31":{"start":{"line":47,"column":4},"end":{"line":106,"column":6}},"32":{"start":{"line":50,"column":8},"end":{"line":50,"column":30}},"33":{"start":{"line":51,"column":8},"end":{"line":51,"column":29}},"34":{"start":{"line":52,"column":8},"end":{"line":52,"column":27}},"35":{"start":{"line":53,"column":8},"end":{"line":53,"column":38}},"36":{"start":{"line":54,"column":8},"end":{"line":54,"column":42}},"37":{"start":{"line":55,"column":8},"end":{"line":55,"column":38}},"38":{"start":{"line":56,"column":8},"end":{"line":56,"column":27}},"39":{"start":{"line":57,"column":8},"end":{"line":57,"column":55}},"40":{"start":{"line":58,"column":8},"end":{"line":105,"column":14}},"41":{"start":{"line":59,"column":12},"end":{"line":94,"column":14}},"42":{"start":{"line":60,"column":37},"end":{"line":60,"column":54}},"43":{"start":{"line":62,"column":20},"end":{"line":73,"column":21}},"44":{"start":{"line":63,"column":24},"end":{"line":63,"column":65}},"45":{"start":{"line":64,"column":24},"end":{"line":64,"column":92}},"46":{"start":{"line":65,"column":24},"end":{"line":68,"column":27}},"47":{"start":{"line":66,"column":28},"end":{"line":66,"column":65}},"48":{"start":{"line":67,"column":28},"end":{"line":67,"column":69}},"49":{"start":{"line":70,"column":24},"end":{"line":72,"column":27}},"50":{"start":{"line":71,"column":28},"end":{"line":71,"column":39}},"51":{"start":{"line":76,"column":20},"end":{"line":76,"column":41}},"52":{"start":{"line":79,"column":20},"end":{"line":79,"column":36}},"53":{"start":{"line":80,"column":20},"end":{"line":80,"column":41}},"54":{"start":{"line":83,"column":20},"end":{"line":92,"column":21}},"55":{"start":{"line":84,"column":24},"end":{"line":84,"column":57}},"56":{"start":{"line":85,"column":24},"end":{"line":87,"column":27}},"57":{"start":{"line":86,"column":28},"end":{"line":86,"column":42}},"58":{"start":{"line":89,"column":24},"end":{"line":91,"column":27}},"59":{"start":{"line":90,"column":28},"end":{"line":90,"column":53}},"60":{"start":{"line":95,"column":12},"end":{"line":95,"column":44}},"61":{"start":{"line":96,"column":12},"end":{"line":104,"column":13}},"62":{"start":{"line":97,"column":16},"end":{"line":97,"column":48}},"63":{"start":{"line":98,"column":16},"end":{"line":98,"column":50}},"64":{"start":{"line":100,"column":16},"end":{"line":103,"column":19}},"65":{"start":{"line":101,"column":20},"end":{"line":101,"column":50}},"66":{"start":{"line":102,"column":20},"end":{"line":102,"column":45}},"67":{"start":{"line":107,"column":4},"end":{"line":113,"column":6}},"68":{"start":{"line":108,"column":8},"end":{"line":112,"column":9}},"69":{"start":{"line":109,"column":12},"end":{"line":109,"column":41}},"70":{"start":{"line":111,"column":12},"end":{"line":111,"column":38}},"71":{"start":{"line":114,"column":4},"end":{"line":127,"column":6}},"72":{"start":{"line":115,"column":8},"end":{"line":126,"column":9}},"73":{"start":{"line":116,"column":12},"end":{"line":116,"column":30}},"74":{"start":{"line":119,"column":12},"end":{"line":119,"column":93}},"75":{"start":{"line":119,"column":46},"end":{"line":119,"column":91}},"76":{"start":{"line":121,"column":12},"end":{"line":125,"column":15}},"77":{"start":{"line":122,"column":16},"end":{"line":124,"column":19}},"78":{"start":{"line":123,"column":20},"end":{"line":123,"column":52}},"79":{"start":{"line":128,"column":4},"end":{"line":135,"column":6}},"80":{"start":{"line":129,"column":8},"end":{"line":129,"column":70}},"81":{"start":{"line":130,"column":8},"end":{"line":130,"column":43}},"82":{"start":{"line":131,"column":8},"end":{"line":133,"column":9}},"83":{"start":{"line":132,"column":12},"end":{"line":132,"column":32}},"84":{"start":{"line":134,"column":8},"end":{"line":134,"column":20}},"85":{"start":{"line":136,"column":4},"end":{"line":143,"column":6}},"86":{"start":{"line":137,"column":8},"end":{"line":137,"column":42}},"87":{"start":{"line":138,"column":8},"end":{"line":138,"column":43}},"88":{"start":{"line":139,"column":8},"end":{"line":141,"column":9}},"89":{"start":{"line":140,"column":12},"end":{"line":140,"column":41}},"90":{"start":{"line":142,"column":8},"end":{"line":142,"column":20}},"91":{"start":{"line":144,"column":4},"end":{"line":144,"column":32}}},"branchMap":{"1":{"line":10,"type":"if","locations":[{"start":{"line":10,"column":8},"end":{"line":10,"column":8}},{"start":{"line":10,"column":8},"end":{"line":10,"column":8}}]},"2":{"line":13,"type":"if","locations":[{"start":{"line":13,"column":8},"end":{"line":13,"column":8}},{"start":{"line":13,"column":8},"end":{"line":13,"column":8}}]},"3":{"line":23,"type":"if","locations":[{"start":{"line":23,"column":8},"end":{"line":23,"column":8}},{"start":{"line":23,"column":8},"end":{"line":23,"column":8}}]},"4":{"line":25,"type":"if","locations":[{"start":{"line":25,"column":15},"end":{"line":25,"column":15}},{"start":{"line":25,"column":15},"end":{"line":25,"column":15}}]},"5":{"line":25,"type":"binary-expr","locations":[{"start":{"line":25,"column":19},"end":{"line":25,"column":33}},{"start":{"line":25,"column":37},"end":{"line":25,"column":62}}]},"6":{"line":32,"type":"if","locations":[{"start":{"line":32,"column":12},"end":{"line":32,"column":12}},{"start":{"line":32,"column":12},"end":{"line":32,"column":12}}]},"7":{"line":35,"type":"if","locations":[{"start":{"line":35,"column":12},"end":{"line":35,"column":12}},{"start":{"line":35,"column":12},"end":{"line":35,"column":12}}]},"8":{"line":40,"type":"if","locations":[{"start":{"line":40,"column":12},"end":{"line":40,"column":12}},{"start":{"line":40,"column":12},"end":{"line":40,"column":12}}]},"9":{"line":40,"type":"binary-expr","locations":[{"start":{"line":40,"column":16},"end":{"line":40,"column":26}},{"start":{"line":40,"column":30},"end":{"line":40,"column":40}}]},"10":{"line":62,"type":"if","locations":[{"start":{"line":62,"column":20},"end":{"line":62,"column":20}},{"start":{"line":62,"column":20},"end":{"line":62,"column":20}}]},"11":{"line":64,"type":"binary-expr","locations":[{"start":{"line":64,"column":47},"end":{"line":64,"column":59}},{"start":{"line":64,"column":63},"end":{"line":64,"column":77}},{"start":{"line":64,"column":81},"end":{"line":64,"column":91}}]},"12":{"line":83,"type":"if","locations":[{"start":{"line":83,"column":20},"end":{"line":83,"column":20}},{"start":{"line":83,"column":20},"end":{"line":83,"column":20}}]},"13":{"line":83,"type":"binary-expr","locations":[{"start":{"line":83,"column":24},"end":{"line":83,"column":42}},{"start":{"line":83,"column":46},"end":{"line":83,"column":76}}]},"14":{"line":96,"type":"if","locations":[{"start":{"line":96,"column":12},"end":{"line":96,"column":12}},{"start":{"line":96,"column":12},"end":{"line":96,"column":12}}]},"15":{"line":96,"type":"binary-expr","locations":[{"start":{"line":96,"column":16},"end":{"line":96,"column":33}},{"start":{"line":96,"column":37},"end":{"line":96,"column":55}}]},"16":{"line":108,"type":"if","locations":[{"start":{"line":108,"column":8},"end":{"line":108,"column":8}},{"start":{"line":108,"column":8},"end":{"line":108,"column":8}}]},"17":{"line":108,"type":"binary-expr","locations":[{"start":{"line":108,"column":12},"end":{"line":108,"column":42}},{"start":{"line":108,"column":46},"end":{"line":108,"column":62}}]},"18":{"line":115,"type":"if","locations":[{"start":{"line":115,"column":8},"end":{"line":115,"column":8}},{"start":{"line":115,"column":8},"end":{"line":115,"column":8}}]},"19":{"line":119,"type":"binary-expr","locations":[{"start":{"line":119,"column":46},"end":{"line":119,"column":70}},{"start":{"line":119,"column":74},"end":{"line":119,"column":91}}]},"20":{"line":129,"type":"cond-expr","locations":[{"start":{"line":129,"column":57},"end":{"line":129,"column":61}},{"start":{"line":129,"column":64},"end":{"line":129,"column":69}}]},"21":{"line":129,"type":"binary-expr","locations":[{"start":{"line":129,"column":21},"end":{"line":129,"column":35}},{"start":{"line":129,"column":39},"end":{"line":129,"column":53}}]}}}} \ No newline at end of file diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html index c6c67e3..d8e43e3 100644 --- a/coverage/lcov-report/index.html +++ b/coverage/lcov-report/index.html @@ -20,24 +20,24 @@
(function() { 'use strict'; - var _ = require('underscore'); exports.version = '3.0.0'; + + var isEqual = require('lodash.isequal'); + var clonedeep = require('lodash.clonedeep'); function RuleEngine(rules, options) { this.init(); @@ -375,7 +349,7 @@this.ignoreFactChanges = options.ignoreFactChanges; } return this; - } + }; RuleEngine.prototype.init = function(rules) { this.rules = []; this.activeRules = []; @@ -408,10 +382,11 @@
RuleEngine.prototype.execute = function(fact, callback) { //these new attributes have to be in both last session and current session to support // the compare function + var thisHolder = this; var complete = false; fact.result = true; - var session = _.clone(fact); - var lastSession = _.clone(fact); + var session = clonedeep(fact); + var lastSession = clonedeep(fact); var _rules = this.activeRules; var matchPath = []; var ignoreFactChanges = this.ignoreFactChanges; @@ -422,55 +397,69 @@
if (outcome) { var _consequence = _rules[x].consequence; _consequence.ruleRef = _rules[x].id || _rules[x].name || 'index_'+x; - process.nextTick(function() { + thisHolder.nextTick(function() { matchPath.push(_consequence.ruleRef); _consequence.call(session, API, session); }); } else { - process.nextTick(function() { + thisHolder.nextTick(function() { API.next(); }); } }, - "restart": function() { - return FnRuleLoop(0); + "restart": function() { + return FnRuleLoop(0); }, "stop": function() { complete = true; return FnRuleLoop(0); }, "next": function() { - Iif (!ignoreFactChanges && !_.isEqual(lastSession, session)) { - lastSession = _.clone(session); - process.nextTick(function() { - API.restart(); + if (!ignoreFactChanges && !isEqual(lastSession, session)) { + lastSession = clonedeep(session); + thisHolder.nextTick(function() { + API.restart(); }); } else { - process.nextTick(function() { + thisHolder.nextTick(function() { return FnRuleLoop(x + 1); }); } } }; + _rules = thisHolder.activeRules; if (x < _rules.length && complete === false) { var _rule = _rules[x].condition; _rule.call(session, API, session); } else { - process.nextTick(function() { + thisHolder.nextTick(function() { session.matchPath = matchPath; return callback(session); }); } })(0); }; - RuleEngine.prototype.findRules = function(filter) { - if (typeof(filter) === "undefined") { + RuleEngine.prototype.nextTick = function(callbackFn) { + if (typeof process !== 'undefined' && process.nextTick) { + process.nextTick(callbackFn); + } else { + setTimeout(callbackFn, 0); + } + }; + RuleEngine.prototype.findRules = function(query) { + if (typeof(query) === "undefined") { return this.rules; } else { - var find = _.matches(filter); - return _.filter(this.rules, find); + // Clean the properties set to undefined in the search query if any to prevent miss match issues. + Object.keys(query).forEach(key => query[key] === undefined && delete query[key]); + // Return rules in the registered rules array which match partially to the query. + return this.rules.filter(function (rule) { + return Object.keys(query).some(function (key) { + return query[key] === rule[key]; + }); + }); } - } + }; RuleEngine.prototype.turn = function(state, filter) { var state = (state === "on" || state === "ON") ? true : false; var rules = this.findRules(filter); @@ -478,7 +467,7 @@
rules[i].on = state; } this.sync(); - } + }; RuleEngine.prototype.prioritize = function(priority, filter) { priority = parseInt(priority, 10); var rules = this.findRules(filter); @@ -486,37 +475,6 @@
rules[i].priority = priority; } this.sync(); - } - RuleEngine.prototype.toJSON = function() { - var rules = this.rules; - Eif (rules instanceof Array) { - rules = rules.map(function(rule) { - rule.condition = rule.condition.toString(); - rule.consequence = rule.consequence.toString(); - return rule; - }); - } else if (typeof(rules) != "undefined") { - rules.condition = rules.condition.toString(); - rules.consequence = rules.consequence.toString(); - } - return rules; - }; - RuleEngine.prototype.fromJSON = function(rules) { - this.init(); - Iif (typeof(rules) == "string") { - rules = JSON.parse(rules); - } - Eif (rules instanceof Array) { - rules = rules.map(function(rule) { - rule.condition = eval("(" + rule.condition + ")"); - rule.consequence = eval("(" + rule.consequence + ")"); - return rule; - }); - } else if (rules !== null && typeof(rules) == "object") { - rules.condition = eval("(" + rules.condition + ")"); - rules.consequence = eval("(" + rules.consequence + ")"); - } - this.register(rules); }; module.exports = RuleEngine; }(module.exports)); @@ -526,7 +484,7 @@
diff --git a/coverage/lcov.info b/coverage/lcov.info index aa08377..3c70bbc 100644 --- a/coverage/lcov.info +++ b/coverage/lcov.info @@ -1,5 +1,5 @@ TN: -SF:/Users/smithun/Desktop/github/node-rules/index.js +SF:/Users/smithun/Desktop/NodeRules/node-rules/index.js FN:7,(anonymous_1) FNF:1 FNH:1 @@ -12,217 +12,194 @@ BRF:0 BRH:0 end_of_record TN: -SF:/Users/smithun/Desktop/github/node-rules/lib/node-rules.js +SF:/Users/smithun/Desktop/NodeRules/node-rules/lib/node-rules.js FN:1,(anonymous_1) -FN:6,RuleEngine -FN:16,(anonymous_3) -FN:20,(anonymous_4) -FN:28,(anonymous_5) -FN:29,(anonymous_6) -FN:37,(anonymous_7) -FN:45,(anonymous_8) -FN:55,FnRuleLoop -FN:57,(anonymous_10) -FN:58,(anonymous_11) -FN:62,(anonymous_12) -FN:67,(anonymous_13) -FN:72,(anonymous_14) -FN:75,(anonymous_15) -FN:79,(anonymous_16) -FN:82,(anonymous_17) -FN:86,(anonymous_18) -FN:96,(anonymous_19) -FN:103,(anonymous_20) -FN:111,(anonymous_21) -FN:119,(anonymous_22) -FN:127,(anonymous_23) -FN:130,(anonymous_24) -FN:141,(anonymous_25) -FN:147,(anonymous_26) -FNF:26 -FNH:24 +FN:8,RuleEngine +FN:18,(anonymous_3) +FN:22,(anonymous_4) +FN:30,(anonymous_5) +FN:31,(anonymous_6) +FN:39,(anonymous_7) +FN:47,(anonymous_8) +FN:58,FnRuleLoop +FN:60,(anonymous_10) +FN:61,(anonymous_11) +FN:65,(anonymous_12) +FN:70,(anonymous_13) +FN:75,(anonymous_14) +FN:78,(anonymous_15) +FN:82,(anonymous_16) +FN:85,(anonymous_17) +FN:89,(anonymous_18) +FN:100,(anonymous_19) +FN:107,(anonymous_20) +FN:114,(anonymous_21) +FN:121,(anonymous_22) +FN:122,(anonymous_23) +FN:128,(anonymous_24) +FN:136,(anonymous_25) +FNF:25 +FNH:25 FNDA:1,(anonymous_1) FNDA:20,RuleEngine -FNDA:23,(anonymous_3) -FNDA:22,(anonymous_4) -FNDA:26,(anonymous_5) -FNDA:46,(anonymous_6) -FNDA:20,(anonymous_7) -FNDA:6,(anonymous_8) -FNDA:17,FnRuleLoop +FNDA:21,(anonymous_3) +FNDA:21,(anonymous_4) +FNDA:25,(anonymous_5) +FNDA:49,(anonymous_6) +FNDA:24,(anonymous_7) +FNDA:9,(anonymous_8) +FNDA:30,FnRuleLoop FNDA:2,(anonymous_10) -FNDA:11,(anonymous_11) -FNDA:9,(anonymous_12) -FNDA:2,(anonymous_13) -FNDA:0,(anonymous_14) -FNDA:4,(anonymous_15) -FNDA:7,(anonymous_16) -FNDA:0,(anonymous_17) -FNDA:7,(anonymous_18) -FNDA:6,(anonymous_19) -FNDA:10,(anonymous_20) -FNDA:2,(anonymous_21) -FNDA:2,(anonymous_22) -FNDA:2,(anonymous_23) +FNDA:21,(anonymous_11) +FNDA:13,(anonymous_12) +FNDA:8,(anonymous_13) +FNDA:1,(anonymous_14) +FNDA:7,(anonymous_15) +FNDA:14,(anonymous_16) +FNDA:1,(anonymous_17) +FNDA:13,(anonymous_18) +FNDA:9,(anonymous_19) +FNDA:44,(anonymous_20) +FNDA:11,(anonymous_21) +FNDA:23,(anonymous_22) +FNDA:23,(anonymous_23) FNDA:2,(anonymous_24) FNDA:2,(anonymous_25) -FNDA:2,(anonymous_26) DA:1,1 DA:3,1 -DA:4,1 +DA:5,1 DA:6,1 -DA:7,20 -DA:8,20 -DA:9,17 -DA:11,20 -DA:12,1 -DA:14,20 -DA:16,1 -DA:17,23 -DA:18,23 -DA:20,1 -DA:21,22 -DA:22,16 -DA:23,6 -DA:24,6 -DA:26,22 -DA:28,1 -DA:29,26 -DA:30,46 +DA:8,1 +DA:9,20 +DA:10,20 +DA:11,17 +DA:13,20 +DA:14,1 +DA:16,20 +DA:18,1 +DA:19,21 +DA:20,21 +DA:22,1 +DA:23,21 +DA:24,14 +DA:25,7 +DA:26,7 +DA:28,21 +DA:30,1 DA:31,25 -DA:33,46 -DA:34,41 -DA:37,26 -DA:38,20 -DA:39,13 -DA:41,7 -DA:45,1 -DA:48,6 -DA:49,6 -DA:50,6 -DA:51,6 -DA:52,6 -DA:53,6 -DA:54,6 -DA:55,6 -DA:56,17 -DA:57,2 -DA:59,11 -DA:60,9 -DA:61,9 -DA:62,9 -DA:63,9 -DA:64,9 -DA:67,2 -DA:68,2 -DA:73,0 -DA:76,4 -DA:77,4 +DA:32,49 +DA:33,29 +DA:35,49 +DA:36,44 +DA:39,25 +DA:40,24 +DA:41,16 +DA:43,8 +DA:47,1 +DA:50,9 +DA:51,9 +DA:52,9 +DA:53,9 +DA:54,9 +DA:55,9 +DA:56,9 +DA:57,9 +DA:58,9 +DA:59,30 +DA:60,2 +DA:62,21 +DA:63,13 +DA:64,13 +DA:65,13 +DA:66,13 +DA:67,13 +DA:70,8 +DA:71,8 +DA:76,1 +DA:79,7 DA:80,7 -DA:81,0 -DA:82,0 -DA:83,0 -DA:86,7 -DA:87,7 -DA:92,17 -DA:93,11 -DA:94,11 -DA:96,6 -DA:97,6 -DA:98,6 -DA:103,1 -DA:104,10 -DA:105,1 -DA:107,9 -DA:108,9 -DA:111,1 -DA:112,2 -DA:113,2 -DA:114,2 -DA:115,2 -DA:117,2 -DA:119,1 -DA:120,2 -DA:121,2 -DA:122,2 -DA:123,2 -DA:125,2 -DA:127,1 -DA:128,2 +DA:83,14 +DA:84,1 +DA:85,1 +DA:86,1 +DA:89,13 +DA:90,13 +DA:95,30 +DA:96,30 +DA:97,21 +DA:98,21 +DA:100,9 +DA:101,9 +DA:102,9 +DA:107,1 +DA:108,44 +DA:109,21 +DA:111,23 +DA:114,1 +DA:115,11 +DA:116,1 +DA:119,11 +DA:121,10 +DA:122,23 +DA:123,23 +DA:128,1 DA:129,2 DA:130,2 DA:131,2 DA:132,2 -DA:133,2 -DA:135,0 -DA:136,0 -DA:137,0 +DA:134,2 +DA:136,1 +DA:137,2 +DA:138,2 DA:139,2 -DA:141,1 +DA:140,2 DA:142,2 -DA:143,2 -DA:144,0 -DA:146,2 -DA:147,2 -DA:148,2 -DA:149,2 -DA:150,2 -DA:152,0 -DA:153,0 -DA:154,0 -DA:156,2 -DA:158,1 -LF:105 -LH:94 -BRDA:8,1,0,17 -BRDA:8,1,1,3 -BRDA:11,2,0,1 -BRDA:11,2,1,19 -BRDA:21,3,0,16 -BRDA:21,3,1,6 -BRDA:23,4,0,6 -BRDA:23,4,1,0 -BRDA:23,5,0,6 -BRDA:23,5,1,6 -BRDA:30,6,0,25 -BRDA:30,6,1,21 -BRDA:33,7,0,41 -BRDA:33,7,1,5 -BRDA:38,8,0,13 -BRDA:38,8,1,7 -BRDA:38,9,0,20 -BRDA:38,9,1,13 -BRDA:59,10,0,9 -BRDA:59,10,1,2 -BRDA:61,11,0,9 -BRDA:61,11,1,7 -BRDA:61,11,2,5 -BRDA:80,12,0,0 -BRDA:80,12,1,7 -BRDA:80,13,0,7 -BRDA:80,13,1,6 -BRDA:92,14,0,11 -BRDA:92,14,1,6 -BRDA:92,15,0,17 -BRDA:92,15,1,15 -BRDA:104,16,0,1 -BRDA:104,16,1,9 -BRDA:112,17,0,1 -BRDA:112,17,1,1 -BRDA:112,18,0,2 -BRDA:112,18,1,2 -BRDA:129,19,0,2 -BRDA:129,19,1,0 -BRDA:135,20,0,0 -BRDA:135,20,1,0 -BRDA:143,21,0,0 -BRDA:143,21,1,2 -BRDA:146,22,0,2 -BRDA:146,22,1,0 -BRDA:152,23,0,0 -BRDA:152,23,1,0 -BRDA:152,24,0,0 -BRDA:152,24,1,0 -BRF:49 -BRH:38 +DA:144,1 +LF:90 +LH:90 +BRDA:10,1,0,17 +BRDA:10,1,1,3 +BRDA:13,2,0,1 +BRDA:13,2,1,19 +BRDA:23,3,0,14 +BRDA:23,3,1,7 +BRDA:25,4,0,7 +BRDA:25,4,1,0 +BRDA:25,5,0,7 +BRDA:25,5,1,7 +BRDA:32,6,0,29 +BRDA:32,6,1,20 +BRDA:35,7,0,44 +BRDA:35,7,1,5 +BRDA:40,8,0,16 +BRDA:40,8,1,8 +BRDA:40,9,0,24 +BRDA:40,9,1,16 +BRDA:62,10,0,13 +BRDA:62,10,1,8 +BRDA:64,11,0,13 +BRDA:64,11,1,11 +BRDA:64,11,2,6 +BRDA:83,12,0,1 +BRDA:83,12,1,13 +BRDA:83,13,0,14 +BRDA:83,13,1,13 +BRDA:96,14,0,21 +BRDA:96,14,1,9 +BRDA:96,15,0,30 +BRDA:96,15,1,28 +BRDA:108,16,0,21 +BRDA:108,16,1,23 +BRDA:108,17,0,44 +BRDA:108,17,1,44 +BRDA:115,18,0,1 +BRDA:115,18,1,10 +BRDA:119,19,0,11 +BRDA:119,19,1,1 +BRDA:129,20,0,1 +BRDA:129,20,1,1 +BRDA:129,21,0,2 +BRDA:129,21,1,2 +BRF:43 +BRH:42 end_of_record diff --git a/package.json b/package.json index 461a467..5cd29e4 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-rules", - "version": "6.1.0", + "version": "6.2.0", "description": "Business Rules Engine for JavaScript", "keywords": [ "bre", diff --git a/test/index.js b/test/index.js index a948862..f166627 100644 --- a/test/index.js +++ b/test/index.js @@ -60,8 +60,11 @@ describe("Rules", function() { }]; var R1 = new RuleEngine(rules); var R2 = new RuleEngine(rules[0]); + var R3 = new RuleEngine(); R2.register(rules[1]); expect(R1.rules).to.eql(R2.rules); + R3.register(rules); + expect(R1.rules).to.eql(R3.rules); }); }); describe(".sync()", function() { @@ -265,6 +268,26 @@ describe("Rules", function() { }); }); + it("should work even when process.NextTick is unavailable", function() { + process.nextTick = undefined; + + var rule = { + "condition": function(R) { + R.when(this && (this.transactionTotal < 500)); + }, + "consequence": function(R) { + this.result = false; + R.stop(); + } + }; + var R = new RuleEngine(rule); + R.execute({ + "transactionTotal": 200 + }, function(result) { + expect(result.result).to.eql(false); + }); + }); + }); describe(".findRules()", function() { var rules = [{ @@ -295,6 +318,12 @@ describe("Rules", function() { "id": "one" })[0].id).to.eql("one"); }); + it("find selector function should filter off undefined entries in the query if any", function() { + expect(R.findRules({ + "id": "one", + "myMistake": undefined + })[0].id).to.eql("one"); + }); it("find without condition works fine", function() { expect(R.findRules().length).to.eql(2); });