diff --git a/coverage/clover.xml b/coverage/clover.xml new file mode 100644 index 0000000..86e6eca --- /dev/null +++ b/coverage/clover.xml @@ -0,0 +1,304 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/coverage/coverage-final.json b/coverage/coverage-final.json new file mode 100644 index 0000000..1fd8243 --- /dev/null +++ b/coverage/coverage-final.json @@ -0,0 +1,4 @@ +{"/Users/oscb/Projects/segment/tsub-js/src/index.ts": {"path":"/Users/oscb/Projects/segment/tsub-js/src/index.ts","statementMap":{"0":{"start":{"line":1,"column":0},"end":{"line":1,"column":9}},"1":{"start":{"line":1,"column":9},"end":{"line":1,"column":29}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":9}},"3":{"start":{"line":2,"column":9},"end":{"line":2,"column":27}},"4":{"start":{"line":2,"column":29},"end":{"line":2,"column":65}},"5":{"start":{"line":3,"column":0},"end":{"line":3,"column":9}},"6":{"start":{"line":3,"column":9},"end":{"line":3,"column":25}}},"fnMap":{"0":{"name":"(anonymous_1)","decl":{"start":{"line":1,"column":9},"end":{"line":1,"column":16}},"loc":{"start":{"line":1,"column":9},"end":{"line":1,"column":29}}},"1":{"name":"(anonymous_2)","decl":{"start":{"line":2,"column":9},"end":{"line":2,"column":16}},"loc":{"start":{"line":2,"column":9},"end":{"line":2,"column":27}}},"2":{"name":"(anonymous_3)","decl":{"start":{"line":2,"column":29},"end":{"line":2,"column":45}},"loc":{"start":{"line":2,"column":29},"end":{"line":2,"column":65}}},"3":{"name":"(anonymous_4)","decl":{"start":{"line":3,"column":9},"end":{"line":3,"column":16}},"loc":{"start":{"line":3,"column":9},"end":{"line":3,"column":25}}}},"branchMap":{},"s":{"0":1,"1":4,"2":1,"3":6,"4":1,"5":1,"6":3},"f":{"0":3,"1":5,"2":0,"3":2},"b":{}} +,"/Users/oscb/Projects/segment/tsub-js/src/matchers.ts": {"path":"/Users/oscb/Projects/segment/tsub-js/src/matchers.ts","statementMap":{"0":{"start":{"line":2,"column":0},"end":{"line":2,"column":21}},"1":{"start":{"line":5,"column":2},"end":{"line":5,"column":null}},"2":{"start":{"line":4,"column":0},"end":{"line":4,"column":24}},"3":{"start":{"line":9,"column":2},"end":{"line":11,"column":null}},"4":{"start":{"line":10,"column":4},"end":{"line":10,"column":null}},"5":{"start":{"line":13,"column":2},"end":{"line":20,"column":null}},"6":{"start":{"line":15,"column":6},"end":{"line":15,"column":null}},"7":{"start":{"line":17,"column":6},"end":{"line":17,"column":null}},"8":{"start":{"line":19,"column":6},"end":{"line":19,"column":null}},"9":{"start":{"line":8,"column":0},"end":{"line":8,"column":16}},"10":{"start":{"line":24,"column":2},"end":{"line":24,"column":null}},"11":{"start":{"line":28,"column":2},"end":{"line":30,"column":null}},"12":{"start":{"line":29,"column":4},"end":{"line":29,"column":null}},"13":{"start":{"line":29,"column":17},"end":{"line":29,"column":null}},"14":{"start":{"line":32,"column":2},"end":{"line":36,"column":null}},"15":{"start":{"line":33,"column":4},"end":{"line":33,"column":null}},"16":{"start":{"line":35,"column":4},"end":{"line":35,"column":null}},"17":{"start":{"line":38,"column":20},"end":{"line":38,"column":41}},"18":{"start":{"line":39,"column":2},"end":{"line":41,"column":null}},"19":{"start":{"line":40,"column":4},"end":{"line":40,"column":null}},"20":{"start":{"line":40,"column":22},"end":{"line":40,"column":null}},"21":{"start":{"line":42,"column":2},"end":{"line":42,"column":null}},"22":{"start":{"line":42,"column":15},"end":{"line":42,"column":null}},"23":{"start":{"line":46,"column":2},"end":{"line":48,"column":null}},"24":{"start":{"line":47,"column":4},"end":{"line":47,"column":null}},"25":{"start":{"line":47,"column":17},"end":{"line":47,"column":null}},"26":{"start":{"line":50,"column":2},"end":{"line":54,"column":null}},"27":{"start":{"line":51,"column":4},"end":{"line":51,"column":null}},"28":{"start":{"line":53,"column":4},"end":{"line":53,"column":null}},"29":{"start":{"line":56,"column":20},"end":{"line":56,"column":41}},"30":{"start":{"line":57,"column":2},"end":{"line":59,"column":null}},"31":{"start":{"line":58,"column":4},"end":{"line":58,"column":null}},"32":{"start":{"line":58,"column":22},"end":{"line":58,"column":null}},"33":{"start":{"line":60,"column":2},"end":{"line":60,"column":null}},"34":{"start":{"line":60,"column":15},"end":{"line":60,"column":null}},"35":{"start":{"line":45,"column":0},"end":{"line":45,"column":16}},"36":{"start":{"line":75,"column":2},"end":{"line":77,"column":null}},"37":{"start":{"line":76,"column":4},"end":{"line":76,"column":null}},"38":{"start":{"line":76,"column":27},"end":{"line":76,"column":null}},"39":{"start":{"line":79,"column":15},"end":{"line":79,"column":20}},"40":{"start":{"line":81,"column":2},"end":{"line":185,"column":null}},"41":{"start":{"line":85,"column":17},"end":{"line":85,"column":41}},"42":{"start":{"line":86,"column":6},"end":{"line":92,"column":null}},"43":{"start":{"line":87,"column":8},"end":{"line":89,"column":null}},"44":{"start":{"line":88,"column":10},"end":{"line":88,"column":null}},"45":{"start":{"line":91,"column":8},"end":{"line":91,"column":null}},"46":{"start":{"line":96,"column":36},"end":{"line":96,"column":38}},"47":{"start":{"line":97,"column":6},"end":{"line":99,"column":null}},"48":{"start":{"line":97,"column":19},"end":{"line":97,"column":20}},"49":{"start":{"line":98,"column":8},"end":{"line":98,"column":null}},"50":{"start":{"line":100,"column":6},"end":{"line":111,"column":null}},"51":{"start":{"line":101,"column":8},"end":{"line":109,"column":null}},"52":{"start":{"line":101,"column":25},"end":{"line":101,"column":30}},"53":{"start":{"line":101,"column":21},"end":{"line":101,"column":25}},"54":{"start":{"line":102,"column":10},"end":{"line":108,"column":null}},"55":{"start":{"line":103,"column":12},"end":{"line":105,"column":null}},"56":{"start":{"line":104,"column":14},"end":{"line":104,"column":null}},"57":{"start":{"line":107,"column":12},"end":{"line":107,"column":null}},"58":{"start":{"line":107,"column":20},"end":{"line":107,"column":null}},"59":{"start":{"line":110,"column":8},"end":{"line":110,"column":null}},"60":{"start":{"line":115,"column":37},"end":{"line":115,"column":39}},"61":{"start":{"line":116,"column":6},"end":{"line":118,"column":null}},"62":{"start":{"line":116,"column":19},"end":{"line":116,"column":20}},"63":{"start":{"line":117,"column":8},"end":{"line":117,"column":null}},"64":{"start":{"line":119,"column":6},"end":{"line":132,"column":null}},"65":{"start":{"line":120,"column":8},"end":{"line":130,"column":null}},"66":{"start":{"line":120,"column":25},"end":{"line":120,"column":31}},"67":{"start":{"line":120,"column":21},"end":{"line":120,"column":25}},"68":{"start":{"line":121,"column":10},"end":{"line":129,"column":null}},"69":{"start":{"line":122,"column":12},"end":{"line":124,"column":null}},"70":{"start":{"line":123,"column":14},"end":{"line":123,"column":null}},"71":{"start":{"line":126,"column":12},"end":{"line":128,"column":null}},"72":{"start":{"line":127,"column":14},"end":{"line":127,"column":null}},"73":{"start":{"line":131,"column":8},"end":{"line":131,"column":null}},"74":{"start":{"line":137,"column":6},"end":{"line":137,"column":null}},"75":{"start":{"line":144,"column":6},"end":{"line":144,"column":null}},"76":{"start":{"line":147,"column":6},"end":{"line":149,"column":null}},"77":{"start":{"line":148,"column":8},"end":{"line":148,"column":null}},"78":{"start":{"line":154,"column":6},"end":{"line":156,"column":null}},"79":{"start":{"line":155,"column":8},"end":{"line":155,"column":null}},"80":{"start":{"line":159,"column":6},"end":{"line":161,"column":null}},"81":{"start":{"line":160,"column":8},"end":{"line":160,"column":null}},"82":{"start":{"line":164,"column":6},"end":{"line":170,"column":null}},"83":{"start":{"line":165,"column":23},"end":{"line":165,"column":45}},"84":{"start":{"line":166,"column":8},"end":{"line":168,"column":null}},"85":{"start":{"line":167,"column":10},"end":{"line":167,"column":null}},"86":{"start":{"line":169,"column":8},"end":{"line":169,"column":null}},"87":{"start":{"line":174,"column":6},"end":{"line":176,"column":null}},"88":{"start":{"line":175,"column":8},"end":{"line":175,"column":null}},"89":{"start":{"line":179,"column":6},"end":{"line":181,"column":null}},"90":{"start":{"line":180,"column":8},"end":{"line":180,"column":null}},"91":{"start":{"line":184,"column":6},"end":{"line":184,"column":null}},"92":{"start":{"line":190,"column":2},"end":{"line":192,"column":null}},"93":{"start":{"line":191,"column":4},"end":{"line":191,"column":null}},"94":{"start":{"line":195,"column":2},"end":{"line":197,"column":null}},"95":{"start":{"line":196,"column":4},"end":{"line":196,"column":null}},"96":{"start":{"line":200,"column":2},"end":{"line":200,"column":null}},"97":{"start":{"line":204,"column":2},"end":{"line":204,"column":null}},"98":{"start":{"line":204,"column":27},"end":{"line":204,"column":56}},"99":{"start":{"line":212,"column":2},"end":{"line":220,"column":null}},"100":{"start":{"line":213,"column":4},"end":{"line":217,"column":null}},"101":{"start":{"line":214,"column":6},"end":{"line":214,"column":null}},"102":{"start":{"line":216,"column":6},"end":{"line":216,"column":null}},"103":{"start":{"line":216,"column":29},"end":{"line":216,"column":null}},"104":{"start":{"line":219,"column":4},"end":{"line":219,"column":null}},"105":{"start":{"line":222,"column":2},"end":{"line":230,"column":null}},"106":{"start":{"line":223,"column":4},"end":{"line":227,"column":null}},"107":{"start":{"line":224,"column":6},"end":{"line":224,"column":null}},"108":{"start":{"line":226,"column":6},"end":{"line":226,"column":null}},"109":{"start":{"line":226,"column":30},"end":{"line":226,"column":null}},"110":{"start":{"line":229,"column":4},"end":{"line":229,"column":null}},"111":{"start":{"line":234,"column":2},"end":{"line":253,"column":null}},"112":{"start":{"line":237,"column":6},"end":{"line":237,"column":null}},"113":{"start":{"line":237,"column":21},"end":{"line":237,"column":null}},"114":{"start":{"line":238,"column":6},"end":{"line":238,"column":11}},"115":{"start":{"line":241,"column":6},"end":{"line":241,"column":null}},"116":{"start":{"line":241,"column":21},"end":{"line":241,"column":null}},"117":{"start":{"line":242,"column":6},"end":{"line":242,"column":11}},"118":{"start":{"line":245,"column":6},"end":{"line":245,"column":null}},"119":{"start":{"line":245,"column":21},"end":{"line":245,"column":null}},"120":{"start":{"line":246,"column":6},"end":{"line":246,"column":11}},"121":{"start":{"line":249,"column":6},"end":{"line":249,"column":null}},"122":{"start":{"line":249,"column":21},"end":{"line":249,"column":null}},"123":{"start":{"line":250,"column":6},"end":{"line":250,"column":11}},"124":{"start":{"line":252,"column":6},"end":{"line":252,"column":null}},"125":{"start":{"line":255,"column":2},"end":{"line":275,"column":null}},"126":{"start":{"line":258,"column":4},"end":{"line":262,"column":null}},"127":{"start":{"line":259,"column":6},"end":{"line":259,"column":null}},"128":{"start":{"line":261,"column":6},"end":{"line":261,"column":null}},"129":{"start":{"line":264,"column":4},"end":{"line":268,"column":null}},"130":{"start":{"line":265,"column":6},"end":{"line":265,"column":null}},"131":{"start":{"line":267,"column":6},"end":{"line":267,"column":null}},"132":{"start":{"line":270,"column":4},"end":{"line":272,"column":null}},"133":{"start":{"line":271,"column":6},"end":{"line":271,"column":null}},"134":{"start":{"line":274,"column":4},"end":{"line":274,"column":null}},"135":{"start":{"line":283,"column":2},"end":{"line":291,"column":null}},"136":{"start":{"line":284,"column":4},"end":{"line":288,"column":null}},"137":{"start":{"line":285,"column":6},"end":{"line":285,"column":null}},"138":{"start":{"line":287,"column":6},"end":{"line":287,"column":null}},"139":{"start":{"line":287,"column":29},"end":{"line":287,"column":null}},"140":{"start":{"line":290,"column":4},"end":{"line":290,"column":null}},"141":{"start":{"line":293,"column":2},"end":{"line":301,"column":null}},"142":{"start":{"line":294,"column":4},"end":{"line":298,"column":null}},"143":{"start":{"line":295,"column":6},"end":{"line":295,"column":null}},"144":{"start":{"line":297,"column":6},"end":{"line":297,"column":null}},"145":{"start":{"line":297,"column":30},"end":{"line":297,"column":null}},"146":{"start":{"line":300,"column":4},"end":{"line":300,"column":null}},"147":{"start":{"line":308,"column":2},"end":{"line":319,"column":null}},"148":{"start":{"line":311,"column":6},"end":{"line":311,"column":null}},"149":{"start":{"line":311,"column":28},"end":{"line":311,"column":null}},"150":{"start":{"line":312,"column":6},"end":{"line":312,"column":11}},"151":{"start":{"line":315,"column":6},"end":{"line":315,"column":null}},"152":{"start":{"line":315,"column":28},"end":{"line":315,"column":null}},"153":{"start":{"line":316,"column":6},"end":{"line":316,"column":11}},"154":{"start":{"line":318,"column":6},"end":{"line":318,"column":null}},"155":{"start":{"line":321,"column":2},"end":{"line":342,"column":null}},"156":{"start":{"line":324,"column":4},"end":{"line":328,"column":null}},"157":{"start":{"line":325,"column":6},"end":{"line":325,"column":null}},"158":{"start":{"line":327,"column":6},"end":{"line":327,"column":null}},"159":{"start":{"line":330,"column":4},"end":{"line":334,"column":null}},"160":{"start":{"line":331,"column":6},"end":{"line":331,"column":null}},"161":{"start":{"line":333,"column":6},"end":{"line":333,"column":null}},"162":{"start":{"line":336,"column":4},"end":{"line":339,"column":null}},"163":{"start":{"line":337,"column":6},"end":{"line":337,"column":null}},"164":{"start":{"line":338,"column":6},"end":{"line":338,"column":null}},"165":{"start":{"line":341,"column":4},"end":{"line":341,"column":null}},"166":{"start":{"line":346,"column":2},"end":{"line":348,"column":null}},"167":{"start":{"line":347,"column":4},"end":{"line":347,"column":null}},"168":{"start":{"line":350,"column":2},"end":{"line":350,"column":null}},"169":{"start":{"line":354,"column":2},"end":{"line":356,"column":null}},"170":{"start":{"line":355,"column":4},"end":{"line":355,"column":null}},"171":{"start":{"line":358,"column":2},"end":{"line":358,"column":null}},"172":{"start":{"line":363,"column":2},"end":{"line":365,"column":null}},"173":{"start":{"line":364,"column":4},"end":{"line":364,"column":null}},"174":{"start":{"line":368,"column":2},"end":{"line":370,"column":null}},"175":{"start":{"line":369,"column":4},"end":{"line":369,"column":null}},"176":{"start":{"line":372,"column":2},"end":{"line":372,"column":null}},"177":{"start":{"line":379,"column":2},"end":{"line":381,"column":null}},"178":{"start":{"line":380,"column":4},"end":{"line":380,"column":null}},"179":{"start":{"line":384,"column":2},"end":{"line":389,"column":null}},"180":{"start":{"line":388,"column":4},"end":{"line":388,"column":null}},"181":{"start":{"line":391,"column":2},"end":{"line":393,"column":null}},"182":{"start":{"line":392,"column":4},"end":{"line":392,"column":null}},"183":{"start":{"line":395,"column":2},"end":{"line":395,"column":null}},"184":{"start":{"line":399,"column":2},"end":{"line":401,"column":null}},"185":{"start":{"line":400,"column":4},"end":{"line":400,"column":null}},"186":{"start":{"line":403,"column":2},"end":{"line":403,"column":null}},"187":{"start":{"line":411,"column":2},"end":{"line":455,"column":null}},"188":{"start":{"line":411,"column":11},"end":{"line":455,"column":null}},"189":{"start":{"line":412,"column":12},"end":{"line":412,"column":null}},"190":{"start":{"line":413,"column":13},"end":{"line":413,"column":null}},"191":{"start":{"line":414,"column":5},"end":{"line":414,"column":null}},"192":{"start":{"line":415,"column":4},"end":{"line":418,"column":null}},"193":{"start":{"line":417,"column":6},"end":{"line":417,"column":null}},"194":{"start":{"line":421,"column":25},"end":{"line":421,"column":47}},"195":{"start":{"line":421,"column":11},"end":{"line":421,"column":13}},"196":{"start":{"line":421,"column":15},"end":{"line":421,"column":17}},"197":{"start":{"line":421,"column":20},"end":{"line":421,"column":25}},"198":{"start":{"line":422,"column":4},"end":{"line":424,"column":null}},"199":{"start":{"line":423,"column":6},"end":{"line":423,"column":null}},"200":{"start":{"line":429,"column":4},"end":{"line":432,"column":null}},"201":{"start":{"line":430,"column":6},"end":{"line":430,"column":null}},"202":{"start":{"line":431,"column":6},"end":{"line":431,"column":14}},"203":{"start":{"line":434,"column":4},"end":{"line":452,"column":null}},"204":{"start":{"line":436,"column":6},"end":{"line":451,"column":null}},"205":{"start":{"line":436,"column":19},"end":{"line":436,"column":20}},"206":{"start":{"line":437,"column":9},"end":{"line":437,"column":null}},"207":{"start":{"line":438,"column":8},"end":{"line":446,"column":null}},"208":{"start":{"line":440,"column":10},"end":{"line":442,"column":null}},"209":{"start":{"line":441,"column":12},"end":{"line":441,"column":20}},"210":{"start":{"line":444,"column":10},"end":{"line":444,"column":null}},"211":{"start":{"line":445,"column":10},"end":{"line":445,"column":null}},"212":{"start":{"line":448,"column":8},"end":{"line":450,"column":null}},"213":{"start":{"line":449,"column":10},"end":{"line":449,"column":null}},"214":{"start":{"line":454,"column":4},"end":{"line":454,"column":null}},"215":{"start":{"line":457,"column":2},"end":{"line":457,"column":null}},"216":{"start":{"line":461,"column":17},"end":{"line":465,"column":null}},"217":{"start":{"line":467,"column":2},"end":{"line":470,"column":null}},"218":{"start":{"line":468,"column":4},"end":{"line":468,"column":null}},"219":{"start":{"line":469,"column":4},"end":{"line":469,"column":null}},"220":{"start":{"line":472,"column":16},"end":{"line":472,"column":21}},"221":{"start":{"line":475,"column":2},"end":{"line":494,"column":null}},"222":{"start":{"line":475,"column":8},"end":{"line":494,"column":null}},"223":{"start":{"line":476,"column":4},"end":{"line":493,"column":null}},"224":{"start":{"line":479,"column":8},"end":{"line":481,"column":null}},"225":{"start":{"line":480,"column":10},"end":{"line":480,"column":null}},"226":{"start":{"line":482,"column":8},"end":{"line":482,"column":13}},"227":{"start":{"line":484,"column":8},"end":{"line":484,"column":null}},"228":{"start":{"line":485,"column":8},"end":{"line":485,"column":13}},"229":{"start":{"line":487,"column":8},"end":{"line":487,"column":null}},"230":{"start":{"line":488,"column":8},"end":{"line":488,"column":13}},"231":{"start":{"line":490,"column":8},"end":{"line":492,"column":null}},"232":{"start":{"line":491,"column":10},"end":{"line":491,"column":null}},"233":{"start":{"line":496,"column":2},"end":{"line":496,"column":null}},"234":{"start":{"line":497,"column":2},"end":{"line":497,"column":null}},"235":{"start":{"line":498,"column":2},"end":{"line":498,"column":null}},"236":{"start":{"line":505,"column":17},"end":{"line":509,"column":null}},"237":{"start":{"line":511,"column":2},"end":{"line":582,"column":null}},"238":{"start":{"line":512,"column":4},"end":{"line":514,"column":null}},"239":{"start":{"line":513,"column":6},"end":{"line":513,"column":null}},"240":{"start":{"line":516,"column":4},"end":{"line":581,"column":null}},"241":{"start":{"line":518,"column":21},"end":{"line":518,"column":27}},"242":{"start":{"line":519,"column":8},"end":{"line":519,"column":null}},"243":{"start":{"line":520,"column":8},"end":{"line":520,"column":null}},"244":{"start":{"line":522,"column":25},"end":{"line":522,"column":29}},"245":{"start":{"line":523,"column":8},"end":{"line":526,"column":null}},"246":{"start":{"line":524,"column":10},"end":{"line":524,"column":null}},"247":{"start":{"line":525,"column":10},"end":{"line":525,"column":null}},"248":{"start":{"line":529,"column":25},"end":{"line":529,"column":30}},"249":{"start":{"line":530,"column":21},"end":{"line":530,"column":22}},"250":{"start":{"line":531,"column":8},"end":{"line":558,"column":null}},"251":{"start":{"line":532,"column":10},"end":{"line":535,"column":null}},"252":{"start":{"line":533,"column":12},"end":{"line":533,"column":null}},"253":{"start":{"line":534,"column":12},"end":{"line":534,"column":17}},"254":{"start":{"line":537,"column":19},"end":{"line":537,"column":21}},"255":{"start":{"line":538,"column":19},"end":{"line":538,"column":21}},"256":{"start":{"line":539,"column":17},"end":{"line":539,"column":null}},"257":{"start":{"line":540,"column":11},"end":{"line":540,"column":null}},"258":{"start":{"line":541,"column":10},"end":{"line":543,"column":null}},"259":{"start":{"line":542,"column":12},"end":{"line":542,"column":null}},"260":{"start":{"line":545,"column":10},"end":{"line":545,"column":null}},"261":{"start":{"line":546,"column":10},"end":{"line":551,"column":null}},"262":{"start":{"line":547,"column":13},"end":{"line":547,"column":null}},"263":{"start":{"line":548,"column":12},"end":{"line":550,"column":null}},"264":{"start":{"line":549,"column":14},"end":{"line":549,"column":null}},"265":{"start":{"line":553,"column":10},"end":{"line":555,"column":null}},"266":{"start":{"line":554,"column":12},"end":{"line":554,"column":null}},"267":{"start":{"line":557,"column":10},"end":{"line":557,"column":null}},"268":{"start":{"line":560,"column":8},"end":{"line":562,"column":null}},"269":{"start":{"line":561,"column":10},"end":{"line":561,"column":null}},"270":{"start":{"line":563,"column":8},"end":{"line":563,"column":13}},"271":{"start":{"line":565,"column":8},"end":{"line":565,"column":null}},"272":{"start":{"line":566,"column":8},"end":{"line":566,"column":null}},"273":{"start":{"line":567,"column":8},"end":{"line":567,"column":13}},"274":{"start":{"line":569,"column":8},"end":{"line":569,"column":null}},"275":{"start":{"line":570,"column":8},"end":{"line":573,"column":null}},"276":{"start":{"line":571,"column":10},"end":{"line":571,"column":null}},"277":{"start":{"line":572,"column":10},"end":{"line":572,"column":null}},"278":{"start":{"line":576,"column":8},"end":{"line":578,"column":null}},"279":{"start":{"line":577,"column":10},"end":{"line":577,"column":null}},"280":{"start":{"line":579,"column":8},"end":{"line":579,"column":null}},"281":{"start":{"line":580,"column":8},"end":{"line":580,"column":null}},"282":{"start":{"line":584,"column":2},"end":{"line":584,"column":null}},"283":{"start":{"line":585,"column":2},"end":{"line":585,"column":null}},"284":{"start":{"line":586,"column":2},"end":{"line":586,"column":null}},"285":{"start":{"line":587,"column":2},"end":{"line":587,"column":null}},"286":{"start":{"line":592,"column":17},"end":{"line":596,"column":null}},"287":{"start":{"line":598,"column":2},"end":{"line":601,"column":null}},"288":{"start":{"line":599,"column":4},"end":{"line":599,"column":null}},"289":{"start":{"line":600,"column":4},"end":{"line":600,"column":null}},"290":{"start":{"line":603,"column":2},"end":{"line":609,"column":null}},"291":{"start":{"line":604,"column":4},"end":{"line":604,"column":null}},"292":{"start":{"line":605,"column":4},"end":{"line":608,"column":null}},"293":{"start":{"line":606,"column":6},"end":{"line":606,"column":null}},"294":{"start":{"line":607,"column":6},"end":{"line":607,"column":null}},"295":{"start":{"line":613,"column":2},"end":{"line":613,"column":null}},"296":{"start":{"line":614,"column":2},"end":{"line":614,"column":null}},"297":{"start":{"line":615,"column":2},"end":{"line":617,"column":null}},"298":{"start":{"line":616,"column":4},"end":{"line":616,"column":null}},"299":{"start":{"line":619,"column":2},"end":{"line":619,"column":null}}},"fnMap":{"0":{"name":"matches","decl":{"start":{"line":4,"column":24},"end":{"line":4,"column":31}},"loc":{"start":{"line":4,"column":70},"end":{"line":6,"column":1}}},"1":{"name":"getMatchFunction","decl":{"start":{"line":8,"column":16},"end":{"line":8,"column":32}},"loc":{"start":{"line":8,"column":55},"end":{"line":21,"column":1}}},"2":{"name":"all","decl":{"start":{"line":23,"column":9},"end":{"line":23,"column":12}},"loc":{"start":{"line":23,"column":12},"end":{"line":25,"column":1}}},"3":{"name":"fql","decl":{"start":{"line":27,"column":9},"end":{"line":27,"column":12}},"loc":{"start":{"line":27,"column":36},"end":{"line":43,"column":1}}},"4":{"name":"(anonymous_5)","decl":{"start":{"line":29,"column":11},"end":{"line":29,"column":17}},"loc":{"start":{"line":29,"column":11},"end":{"line":29,"column":22}}},"5":{"name":"(anonymous_6)","decl":{"start":{"line":40,"column":11},"end":{"line":40,"column":12}},"loc":{"start":{"line":40,"column":17},"end":{"line":40,"column":23}}},"6":{"name":"(anonymous_7)","decl":{"start":{"line":42,"column":9},"end":{"line":42,"column":15}},"loc":{"start":{"line":42,"column":9},"end":{"line":42,"column":16}}},"7":{"name":"generateFQLEval","decl":{"start":{"line":45,"column":16},"end":{"line":45,"column":31}},"loc":{"start":{"line":45,"column":55},"end":{"line":61,"column":1}}},"8":{"name":"(anonymous_9)","decl":{"start":{"line":47,"column":11},"end":{"line":47,"column":17}},"loc":{"start":{"line":47,"column":11},"end":{"line":47,"column":22}}},"9":{"name":"(anonymous_10)","decl":{"start":{"line":58,"column":11},"end":{"line":58,"column":12}},"loc":{"start":{"line":58,"column":17},"end":{"line":58,"column":23}}},"10":{"name":"(anonymous_11)","decl":{"start":{"line":60,"column":9},"end":{"line":60,"column":15}},"loc":{"start":{"line":60,"column":9},"end":{"line":60,"column":16}}},"11":{"name":"generateEvaluator","decl":{"start":{"line":73,"column":9},"end":{"line":73,"column":26}},"loc":{"start":{"line":73,"column":48},"end":{"line":186,"column":1}}},"12":{"name":"(anonymous_13)","decl":{"start":{"line":76,"column":11},"end":{"line":76,"column":12}},"loc":{"start":{"line":76,"column":22},"end":{"line":76,"column":35}}},"13":{"name":"(anonymous_14)","decl":{"start":{"line":87,"column":15},"end":{"line":87,"column":16}},"loc":{"start":{"line":87,"column":26},"end":{"line":89,"column":9}}},"14":{"name":"(anonymous_15)","decl":{"start":{"line":100,"column":13},"end":{"line":100,"column":14}},"loc":{"start":{"line":100,"column":24},"end":{"line":111,"column":7}}},"15":{"name":"(anonymous_16)","decl":{"start":{"line":119,"column":13},"end":{"line":119,"column":14}},"loc":{"start":{"line":119,"column":24},"end":{"line":132,"column":7}}},"16":{"name":"(anonymous_17)","decl":{"start":{"line":147,"column":13},"end":{"line":147,"column":14}},"loc":{"start":{"line":147,"column":19},"end":{"line":149,"column":7}}},"17":{"name":"(anonymous_18)","decl":{"start":{"line":154,"column":13},"end":{"line":154,"column":14}},"loc":{"start":{"line":154,"column":19},"end":{"line":156,"column":7}}},"18":{"name":"(anonymous_19)","decl":{"start":{"line":159,"column":13},"end":{"line":159,"column":14}},"loc":{"start":{"line":159,"column":19},"end":{"line":161,"column":7}}},"19":{"name":"(anonymous_20)","decl":{"start":{"line":164,"column":13},"end":{"line":164,"column":14}},"loc":{"start":{"line":164,"column":19},"end":{"line":170,"column":7}}},"20":{"name":"(anonymous_21)","decl":{"start":{"line":174,"column":13},"end":{"line":174,"column":14}},"loc":{"start":{"line":174,"column":19},"end":{"line":176,"column":7}}},"21":{"name":"(anonymous_22)","decl":{"start":{"line":179,"column":13},"end":{"line":179,"column":14}},"loc":{"start":{"line":179,"column":19},"end":{"line":181,"column":7}}},"22":{"name":"getValue","decl":{"start":{"line":188,"column":9},"end":{"line":188,"column":17}},"loc":{"start":{"line":188,"column":29},"end":{"line":201,"column":1}}},"23":{"name":"checkInList","decl":{"start":{"line":203,"column":9},"end":{"line":203,"column":20}},"loc":{"start":{"line":203,"column":38},"end":{"line":205,"column":1}}},"24":{"name":"(anonymous_25)","decl":{"start":{"line":204,"column":19},"end":{"line":204,"column":20}},"loc":{"start":{"line":204,"column":22},"end":{"line":204,"column":35}}},"25":{"name":"compareNumbersGenerator","decl":{"start":{"line":207,"column":9},"end":{"line":207,"column":32}},"loc":{"start":{"line":207,"column":56},"end":{"line":276,"column":1}}},"26":{"name":"(anonymous_27)","decl":{"start":{"line":216,"column":18},"end":{"line":216,"column":19}},"loc":{"start":{"line":216,"column":24},"end":{"line":216,"column":37}}},"27":{"name":"(anonymous_28)","decl":{"start":{"line":226,"column":19},"end":{"line":226,"column":20}},"loc":{"start":{"line":226,"column":25},"end":{"line":226,"column":38}}},"28":{"name":"(anonymous_29)","decl":{"start":{"line":237,"column":11},"end":{"line":237,"column":12}},"loc":{"start":{"line":237,"column":16},"end":{"line":237,"column":22}}},"29":{"name":"(anonymous_30)","decl":{"start":{"line":241,"column":11},"end":{"line":241,"column":12}},"loc":{"start":{"line":241,"column":16},"end":{"line":241,"column":22}}},"30":{"name":"(anonymous_31)","decl":{"start":{"line":245,"column":11},"end":{"line":245,"column":12}},"loc":{"start":{"line":245,"column":16},"end":{"line":245,"column":22}}},"31":{"name":"(anonymous_32)","decl":{"start":{"line":249,"column":11},"end":{"line":249,"column":12}},"loc":{"start":{"line":249,"column":16},"end":{"line":249,"column":22}}},"32":{"name":"(anonymous_33)","decl":{"start":{"line":255,"column":9},"end":{"line":255,"column":10}},"loc":{"start":{"line":255,"column":15},"end":{"line":275,"column":3}}},"33":{"name":"compareItemsGenerator","decl":{"start":{"line":278,"column":9},"end":{"line":278,"column":30}},"loc":{"start":{"line":278,"column":54},"end":{"line":343,"column":1}}},"34":{"name":"(anonymous_35)","decl":{"start":{"line":287,"column":18},"end":{"line":287,"column":19}},"loc":{"start":{"line":287,"column":24},"end":{"line":287,"column":37}}},"35":{"name":"(anonymous_36)","decl":{"start":{"line":297,"column":19},"end":{"line":297,"column":20}},"loc":{"start":{"line":297,"column":25},"end":{"line":297,"column":38}}},"36":{"name":"(anonymous_37)","decl":{"start":{"line":311,"column":18},"end":{"line":311,"column":19}},"loc":{"start":{"line":311,"column":23},"end":{"line":311,"column":29}}},"37":{"name":"(anonymous_38)","decl":{"start":{"line":315,"column":18},"end":{"line":315,"column":19}},"loc":{"start":{"line":315,"column":23},"end":{"line":315,"column":29}}},"38":{"name":"(anonymous_39)","decl":{"start":{"line":321,"column":9},"end":{"line":321,"column":10}},"loc":{"start":{"line":321,"column":15},"end":{"line":342,"column":3}}},"39":{"name":"contains","decl":{"start":{"line":345,"column":9},"end":{"line":345,"column":17}},"loc":{"start":{"line":345,"column":31},"end":{"line":351,"column":1}}},"40":{"name":"match","decl":{"start":{"line":353,"column":9},"end":{"line":353,"column":14}},"loc":{"start":{"line":353,"column":24},"end":{"line":359,"column":1}}},"41":{"name":"length","decl":{"start":{"line":361,"column":9},"end":{"line":361,"column":15}},"loc":{"start":{"line":361,"column":20},"end":{"line":373,"column":1}}},"42":{"name":"isIR","decl":{"start":{"line":377,"column":9},"end":{"line":377,"column":13}},"loc":{"start":{"line":377,"column":19},"end":{"line":396,"column":1}}},"43":{"name":"isStatic","decl":{"start":{"line":398,"column":9},"end":{"line":398,"column":17}},"loc":{"start":{"line":398,"column":44},"end":{"line":404,"column":1}}},"44":{"name":"globMatches","decl":{"start":{"line":410,"column":9},"end":{"line":410,"column":20}},"loc":{"start":{"line":410,"column":33},"end":{"line":458,"column":1}}},"45":{"name":"scanChunk","decl":{"start":{"line":460,"column":9},"end":{"line":460,"column":18}},"loc":{"start":{"line":460,"column":26},"end":{"line":499,"column":1}}},"46":{"name":"matchChunk","decl":{"start":{"line":504,"column":9},"end":{"line":504,"column":19}},"loc":{"start":{"line":504,"column":30},"end":{"line":588,"column":1}}},"47":{"name":"getEsc","decl":{"start":{"line":591,"column":9},"end":{"line":591,"column":15}},"loc":{"start":{"line":591,"column":21},"end":{"line":620,"column":1}}}},"branchMap":{"0":{"loc":{"start":{"line":9,"column":2},"end":{"line":11,"column":null}},"type":"if","locations":[{"start":{"line":9,"column":2},"end":{"line":11,"column":null}}]},"1":{"loc":{"start":{"line":14,"column":4},"end":{"line":15,"column":null}},"type":"switch","locations":[{"start":{"line":14,"column":4},"end":{"line":15,"column":null}},{"start":{"line":16,"column":4},"end":{"line":17,"column":null}},{"start":{"line":18,"column":4},"end":{"line":19,"column":null}}]},"2":{"loc":{"start":{"line":28,"column":2},"end":{"line":30,"column":null}},"type":"if","locations":[{"start":{"line":28,"column":2},"end":{"line":30,"column":null}}]},"3":{"loc":{"start":{"line":39,"column":2},"end":{"line":41,"column":null}},"type":"if","locations":[{"start":{"line":39,"column":2},"end":{"line":41,"column":null}}]},"4":{"loc":{"start":{"line":46,"column":2},"end":{"line":48,"column":null}},"type":"if","locations":[{"start":{"line":46,"column":2},"end":{"line":48,"column":null}}]},"5":{"loc":{"start":{"line":57,"column":2},"end":{"line":59,"column":null}},"type":"if","locations":[{"start":{"line":57,"column":2},"end":{"line":59,"column":null}}]},"6":{"loc":{"start":{"line":75,"column":2},"end":{"line":77,"column":null}},"type":"if","locations":[{"start":{"line":75,"column":2},"end":{"line":77,"column":null}}]},"7":{"loc":{"start":{"line":84,"column":4},"end":{"line":92,"column":null}},"type":"switch","locations":[{"start":{"line":84,"column":4},"end":{"line":92,"column":null}},{"start":{"line":95,"column":4},"end":{"line":111,"column":null}},{"start":{"line":114,"column":4},"end":{"line":132,"column":null}},{"start":{"line":135,"column":4},"end":{"line":135,"column":13}},{"start":{"line":136,"column":4},"end":{"line":137,"column":null}},{"start":{"line":139,"column":4},"end":{"line":139,"column":14}},{"start":{"line":140,"column":4},"end":{"line":140,"column":13}},{"start":{"line":141,"column":4},"end":{"line":141,"column":13}},{"start":{"line":142,"column":4},"end":{"line":144,"column":null}},{"start":{"line":146,"column":4},"end":{"line":149,"column":null}},{"start":{"line":153,"column":4},"end":{"line":156,"column":null}},{"start":{"line":158,"column":4},"end":{"line":161,"column":null}},{"start":{"line":163,"column":4},"end":{"line":170,"column":null}},{"start":{"line":172,"column":4},"end":{"line":176,"column":null}},{"start":{"line":178,"column":4},"end":{"line":181,"column":null}},{"start":{"line":183,"column":4},"end":{"line":184,"column":null}}]},"8":{"loc":{"start":{"line":86,"column":6},"end":{"line":92,"column":null}},"type":"if","locations":[{"start":{"line":86,"column":6},"end":{"line":92,"column":null}},{"start":{"line":90,"column":13},"end":{"line":92,"column":null}}]},"9":{"loc":{"start":{"line":102,"column":10},"end":{"line":108,"column":null}},"type":"if","locations":[{"start":{"line":102,"column":10},"end":{"line":108,"column":null}},{"start":{"line":106,"column":17},"end":{"line":108,"column":null}}]},"10":{"loc":{"start":{"line":103,"column":12},"end":{"line":105,"column":null}},"type":"if","locations":[{"start":{"line":103,"column":12},"end":{"line":105,"column":null}}]},"11":{"loc":{"start":{"line":107,"column":12},"end":{"line":107,"column":null}},"type":"if","locations":[{"start":{"line":107,"column":12},"end":{"line":107,"column":null}}]},"12":{"loc":{"start":{"line":121,"column":10},"end":{"line":129,"column":null}},"type":"if","locations":[{"start":{"line":121,"column":10},"end":{"line":129,"column":null}},{"start":{"line":125,"column":17},"end":{"line":129,"column":null}}]},"13":{"loc":{"start":{"line":122,"column":12},"end":{"line":124,"column":null}},"type":"if","locations":[{"start":{"line":122,"column":12},"end":{"line":124,"column":null}}]},"14":{"loc":{"start":{"line":126,"column":12},"end":{"line":128,"column":null}},"type":"if","locations":[{"start":{"line":126,"column":12},"end":{"line":128,"column":null}}]},"15":{"loc":{"start":{"line":166,"column":8},"end":{"line":168,"column":null}},"type":"if","locations":[{"start":{"line":166,"column":8},"end":{"line":168,"column":null}}]},"16":{"loc":{"start":{"line":190,"column":2},"end":{"line":192,"column":null}},"type":"if","locations":[{"start":{"line":190,"column":2},"end":{"line":192,"column":null}}]},"17":{"loc":{"start":{"line":195,"column":2},"end":{"line":197,"column":null}},"type":"if","locations":[{"start":{"line":195,"column":2},"end":{"line":197,"column":null}}]},"18":{"loc":{"start":{"line":212,"column":2},"end":{"line":220,"column":null}},"type":"if","locations":[{"start":{"line":212,"column":2},"end":{"line":220,"column":null}},{"start":{"line":218,"column":9},"end":{"line":220,"column":null}}]},"19":{"loc":{"start":{"line":213,"column":4},"end":{"line":217,"column":null}},"type":"if","locations":[{"start":{"line":213,"column":4},"end":{"line":217,"column":null}},{"start":{"line":215,"column":11},"end":{"line":217,"column":null}}]},"20":{"loc":{"start":{"line":222,"column":2},"end":{"line":230,"column":null}},"type":"if","locations":[{"start":{"line":222,"column":2},"end":{"line":230,"column":null}},{"start":{"line":228,"column":9},"end":{"line":230,"column":null}}]},"21":{"loc":{"start":{"line":223,"column":4},"end":{"line":227,"column":null}},"type":"if","locations":[{"start":{"line":223,"column":4},"end":{"line":227,"column":null}},{"start":{"line":225,"column":11},"end":{"line":227,"column":null}}]},"22":{"loc":{"start":{"line":236,"column":4},"end":{"line":238,"column":11}},"type":"switch","locations":[{"start":{"line":236,"column":4},"end":{"line":238,"column":11}},{"start":{"line":240,"column":4},"end":{"line":242,"column":11}},{"start":{"line":244,"column":4},"end":{"line":246,"column":11}},{"start":{"line":248,"column":4},"end":{"line":250,"column":11}},{"start":{"line":251,"column":4},"end":{"line":252,"column":null}}]},"23":{"loc":{"start":{"line":258,"column":4},"end":{"line":262,"column":null}},"type":"if","locations":[{"start":{"line":258,"column":4},"end":{"line":262,"column":null}},{"start":{"line":260,"column":11},"end":{"line":262,"column":null}}]},"24":{"loc":{"start":{"line":264,"column":4},"end":{"line":268,"column":null}},"type":"if","locations":[{"start":{"line":264,"column":4},"end":{"line":268,"column":null}},{"start":{"line":266,"column":11},"end":{"line":268,"column":null}}]},"25":{"loc":{"start":{"line":270,"column":4},"end":{"line":272,"column":null}},"type":"if","locations":[{"start":{"line":270,"column":4},"end":{"line":272,"column":null}}]},"26":{"loc":{"start":{"line":270,"column":8},"end":{"line":270,"column":29}},"type":"binary-expr","locations":[{"start":{"line":270,"column":8},"end":{"line":270,"column":29}},{"start":{"line":270,"column":33},"end":{"line":270,"column":54}}]},"27":{"loc":{"start":{"line":283,"column":2},"end":{"line":291,"column":null}},"type":"if","locations":[{"start":{"line":283,"column":2},"end":{"line":291,"column":null}},{"start":{"line":289,"column":9},"end":{"line":291,"column":null}}]},"28":{"loc":{"start":{"line":284,"column":4},"end":{"line":288,"column":null}},"type":"if","locations":[{"start":{"line":284,"column":4},"end":{"line":288,"column":null}},{"start":{"line":286,"column":11},"end":{"line":288,"column":null}}]},"29":{"loc":{"start":{"line":293,"column":2},"end":{"line":301,"column":null}},"type":"if","locations":[{"start":{"line":293,"column":2},"end":{"line":301,"column":null}},{"start":{"line":299,"column":9},"end":{"line":301,"column":null}}]},"30":{"loc":{"start":{"line":294,"column":4},"end":{"line":298,"column":null}},"type":"if","locations":[{"start":{"line":294,"column":4},"end":{"line":298,"column":null}},{"start":{"line":296,"column":11},"end":{"line":298,"column":null}}]},"31":{"loc":{"start":{"line":310,"column":4},"end":{"line":312,"column":11}},"type":"switch","locations":[{"start":{"line":310,"column":4},"end":{"line":312,"column":11}},{"start":{"line":314,"column":4},"end":{"line":316,"column":11}},{"start":{"line":317,"column":4},"end":{"line":318,"column":null}}]},"32":{"loc":{"start":{"line":324,"column":4},"end":{"line":328,"column":null}},"type":"if","locations":[{"start":{"line":324,"column":4},"end":{"line":328,"column":null}},{"start":{"line":326,"column":11},"end":{"line":328,"column":null}}]},"33":{"loc":{"start":{"line":330,"column":4},"end":{"line":334,"column":null}},"type":"if","locations":[{"start":{"line":330,"column":4},"end":{"line":334,"column":null}},{"start":{"line":332,"column":11},"end":{"line":334,"column":null}}]},"34":{"loc":{"start":{"line":336,"column":4},"end":{"line":339,"column":null}},"type":"if","locations":[{"start":{"line":336,"column":4},"end":{"line":339,"column":null}}]},"35":{"loc":{"start":{"line":336,"column":8},"end":{"line":336,"column":29}},"type":"binary-expr","locations":[{"start":{"line":336,"column":8},"end":{"line":336,"column":29}},{"start":{"line":336,"column":33},"end":{"line":336,"column":54}}]},"36":{"loc":{"start":{"line":346,"column":2},"end":{"line":348,"column":null}},"type":"if","locations":[{"start":{"line":346,"column":2},"end":{"line":348,"column":null}}]},"37":{"loc":{"start":{"line":346,"column":6},"end":{"line":346,"column":31}},"type":"binary-expr","locations":[{"start":{"line":346,"column":6},"end":{"line":346,"column":31}},{"start":{"line":346,"column":35},"end":{"line":346,"column":61}}]},"38":{"loc":{"start":{"line":354,"column":2},"end":{"line":356,"column":null}},"type":"if","locations":[{"start":{"line":354,"column":2},"end":{"line":356,"column":null}}]},"39":{"loc":{"start":{"line":354,"column":6},"end":{"line":354,"column":29}},"type":"binary-expr","locations":[{"start":{"line":354,"column":6},"end":{"line":354,"column":29}},{"start":{"line":354,"column":33},"end":{"line":354,"column":57}}]},"40":{"loc":{"start":{"line":363,"column":2},"end":{"line":365,"column":null}},"type":"if","locations":[{"start":{"line":363,"column":2},"end":{"line":365,"column":null}}]},"41":{"loc":{"start":{"line":368,"column":2},"end":{"line":370,"column":null}},"type":"if","locations":[{"start":{"line":368,"column":2},"end":{"line":370,"column":null}}]},"42":{"loc":{"start":{"line":368,"column":6},"end":{"line":368,"column":26}},"type":"binary-expr","locations":[{"start":{"line":368,"column":6},"end":{"line":368,"column":26}},{"start":{"line":368,"column":30},"end":{"line":368,"column":54}}]},"43":{"loc":{"start":{"line":379,"column":2},"end":{"line":381,"column":null}},"type":"if","locations":[{"start":{"line":379,"column":2},"end":{"line":381,"column":null}}]},"44":{"loc":{"start":{"line":384,"column":2},"end":{"line":389,"column":null}},"type":"if","locations":[{"start":{"line":384,"column":2},"end":{"line":389,"column":null}}]},"45":{"loc":{"start":{"line":385,"column":5},"end":{"line":385,"column":29}},"type":"binary-expr","locations":[{"start":{"line":385,"column":5},"end":{"line":385,"column":29}},{"start":{"line":385,"column":33},"end":{"line":385,"column":54}},{"start":{"line":385,"column":58},"end":{"line":385,"column":79}},{"start":{"line":386,"column":4},"end":{"line":386,"column":22}}]},"46":{"loc":{"start":{"line":391,"column":2},"end":{"line":393,"column":null}},"type":"if","locations":[{"start":{"line":391,"column":2},"end":{"line":393,"column":null}}]},"47":{"loc":{"start":{"line":391,"column":7},"end":{"line":391,"column":30}},"type":"binary-expr","locations":[{"start":{"line":391,"column":7},"end":{"line":391,"column":30}},{"start":{"line":391,"column":34},"end":{"line":391,"column":54}},{"start":{"line":391,"column":59},"end":{"line":391,"column":77}}]},"48":{"loc":{"start":{"line":399,"column":2},"end":{"line":401,"column":null}},"type":"if","locations":[{"start":{"line":399,"column":2},"end":{"line":401,"column":null}}]},"49":{"loc":{"start":{"line":399,"column":6},"end":{"line":399,"column":23}},"type":"binary-expr","locations":[{"start":{"line":399,"column":6},"end":{"line":399,"column":23}},{"start":{"line":399,"column":27},"end":{"line":399,"column":49}}]},"50":{"loc":{"start":{"line":415,"column":4},"end":{"line":418,"column":null}},"type":"if","locations":[{"start":{"line":415,"column":4},"end":{"line":418,"column":null}}]},"51":{"loc":{"start":{"line":415,"column":8},"end":{"line":415,"column":12}},"type":"binary-expr","locations":[{"start":{"line":415,"column":8},"end":{"line":415,"column":12}},{"start":{"line":415,"column":16},"end":{"line":415,"column":28}}]},"52":{"loc":{"start":{"line":422,"column":4},"end":{"line":424,"column":null}},"type":"if","locations":[{"start":{"line":422,"column":4},"end":{"line":424,"column":null}}]},"53":{"loc":{"start":{"line":429,"column":4},"end":{"line":432,"column":null}},"type":"if","locations":[{"start":{"line":429,"column":4},"end":{"line":432,"column":null}}]},"54":{"loc":{"start":{"line":429,"column":8},"end":{"line":429,"column":10}},"type":"binary-expr","locations":[{"start":{"line":429,"column":8},"end":{"line":429,"column":10}},{"start":{"line":429,"column":15},"end":{"line":429,"column":29}},{"start":{"line":429,"column":33},"end":{"line":429,"column":51}}]},"55":{"loc":{"start":{"line":434,"column":4},"end":{"line":452,"column":null}},"type":"if","locations":[{"start":{"line":434,"column":4},"end":{"line":452,"column":null}}]},"56":{"loc":{"start":{"line":438,"column":8},"end":{"line":446,"column":null}},"type":"if","locations":[{"start":{"line":438,"column":8},"end":{"line":446,"column":null}}]},"57":{"loc":{"start":{"line":440,"column":10},"end":{"line":442,"column":null}},"type":"if","locations":[{"start":{"line":440,"column":10},"end":{"line":442,"column":null}}]},"58":{"loc":{"start":{"line":440,"column":14},"end":{"line":440,"column":34}},"type":"binary-expr","locations":[{"start":{"line":440,"column":14},"end":{"line":440,"column":34}},{"start":{"line":440,"column":38},"end":{"line":440,"column":50}}]},"59":{"loc":{"start":{"line":448,"column":8},"end":{"line":450,"column":null}},"type":"if","locations":[{"start":{"line":448,"column":8},"end":{"line":450,"column":null}}]},"60":{"loc":{"start":{"line":467,"column":9},"end":{"line":467,"column":27}},"type":"binary-expr","locations":[{"start":{"line":467,"column":9},"end":{"line":467,"column":27}},{"start":{"line":467,"column":31},"end":{"line":467,"column":49}}]},"61":{"loc":{"start":{"line":477,"column":6},"end":{"line":482,"column":13}},"type":"switch","locations":[{"start":{"line":477,"column":6},"end":{"line":482,"column":13}},{"start":{"line":483,"column":6},"end":{"line":485,"column":13}},{"start":{"line":486,"column":6},"end":{"line":488,"column":13}},{"start":{"line":489,"column":6},"end":{"line":492,"column":null}}]},"62":{"loc":{"start":{"line":479,"column":8},"end":{"line":481,"column":null}},"type":"if","locations":[{"start":{"line":479,"column":8},"end":{"line":481,"column":null}}]},"63":{"loc":{"start":{"line":490,"column":8},"end":{"line":492,"column":null}},"type":"if","locations":[{"start":{"line":490,"column":8},"end":{"line":492,"column":null}}]},"64":{"loc":{"start":{"line":512,"column":4},"end":{"line":514,"column":null}},"type":"if","locations":[{"start":{"line":512,"column":4},"end":{"line":514,"column":null}}]},"65":{"loc":{"start":{"line":517,"column":6},"end":{"line":563,"column":13}},"type":"switch","locations":[{"start":{"line":517,"column":6},"end":{"line":563,"column":13}},{"start":{"line":564,"column":6},"end":{"line":567,"column":13}},{"start":{"line":568,"column":6},"end":{"line":573,"column":null}},{"start":{"line":575,"column":6},"end":{"line":580,"column":null}}]},"66":{"loc":{"start":{"line":523,"column":8},"end":{"line":526,"column":null}},"type":"if","locations":[{"start":{"line":523,"column":8},"end":{"line":526,"column":null}}]},"67":{"loc":{"start":{"line":523,"column":12},"end":{"line":523,"column":28}},"type":"binary-expr","locations":[{"start":{"line":523,"column":12},"end":{"line":523,"column":28}},{"start":{"line":523,"column":32},"end":{"line":523,"column":48}}]},"68":{"loc":{"start":{"line":532,"column":10},"end":{"line":535,"column":null}},"type":"if","locations":[{"start":{"line":532,"column":10},"end":{"line":535,"column":null}}]},"69":{"loc":{"start":{"line":532,"column":14},"end":{"line":532,"column":30}},"type":"binary-expr","locations":[{"start":{"line":532,"column":14},"end":{"line":532,"column":30}},{"start":{"line":532,"column":34},"end":{"line":532,"column":50}},{"start":{"line":532,"column":54},"end":{"line":532,"column":64}}]},"70":{"loc":{"start":{"line":541,"column":10},"end":{"line":543,"column":null}},"type":"if","locations":[{"start":{"line":541,"column":10},"end":{"line":543,"column":null}}]},"71":{"loc":{"start":{"line":546,"column":10},"end":{"line":551,"column":null}},"type":"if","locations":[{"start":{"line":546,"column":10},"end":{"line":551,"column":null}}]},"72":{"loc":{"start":{"line":548,"column":12},"end":{"line":550,"column":null}},"type":"if","locations":[{"start":{"line":548,"column":12},"end":{"line":550,"column":null}}]},"73":{"loc":{"start":{"line":553,"column":10},"end":{"line":555,"column":null}},"type":"if","locations":[{"start":{"line":553,"column":10},"end":{"line":555,"column":null}}]},"74":{"loc":{"start":{"line":553,"column":14},"end":{"line":553,"column":24}},"type":"binary-expr","locations":[{"start":{"line":553,"column":14},"end":{"line":553,"column":24}},{"start":{"line":553,"column":28},"end":{"line":553,"column":38}}]},"75":{"loc":{"start":{"line":560,"column":8},"end":{"line":562,"column":null}},"type":"if","locations":[{"start":{"line":560,"column":8},"end":{"line":562,"column":null}}]},"76":{"loc":{"start":{"line":570,"column":8},"end":{"line":573,"column":null}},"type":"if","locations":[{"start":{"line":570,"column":8},"end":{"line":573,"column":null}}]},"77":{"loc":{"start":{"line":576,"column":8},"end":{"line":578,"column":null}},"type":"if","locations":[{"start":{"line":576,"column":8},"end":{"line":578,"column":null}}]},"78":{"loc":{"start":{"line":598,"column":2},"end":{"line":601,"column":null}},"type":"if","locations":[{"start":{"line":598,"column":2},"end":{"line":601,"column":null}}]},"79":{"loc":{"start":{"line":598,"column":6},"end":{"line":598,"column":24}},"type":"binary-expr","locations":[{"start":{"line":598,"column":6},"end":{"line":598,"column":24}},{"start":{"line":598,"column":28},"end":{"line":598,"column":44}},{"start":{"line":598,"column":48},"end":{"line":598,"column":64}}]},"80":{"loc":{"start":{"line":603,"column":2},"end":{"line":609,"column":null}},"type":"if","locations":[{"start":{"line":603,"column":2},"end":{"line":609,"column":null}}]},"81":{"loc":{"start":{"line":605,"column":4},"end":{"line":608,"column":null}},"type":"if","locations":[{"start":{"line":605,"column":4},"end":{"line":608,"column":null}}]},"82":{"loc":{"start":{"line":615,"column":2},"end":{"line":617,"column":null}},"type":"if","locations":[{"start":{"line":615,"column":2},"end":{"line":617,"column":null}}]}},"s":{"0":2,"1":113,"2":2,"3":113,"4":0,"5":113,"6":1,"7":111,"8":1,"9":2,"10":1,"11":111,"12":1,"13":1,"14":110,"15":110,"16":1,"17":109,"18":108,"19":108,"20":108,"21":0,"22":0,"23":1,"24":0,"25":0,"26":1,"27":1,"28":0,"29":1,"30":1,"31":1,"32":10001,"33":0,"34":0,"35":2,"36":140,"37":21,"38":21,"39":119,"40":119,"41":0,"42":0,"43":0,"44":0,"45":0,"46":4,"47":4,"48":4,"49":10,"50":4,"51":10004,"52":20008,"53":20010,"54":20010,"55":20010,"56":10003,"57":0,"58":0,"59":1,"60":4,"61":4,"62":4,"63":13,"64":4,"65":10004,"66":20008,"67":50013,"68":50013,"69":50013,"70":1,"71":0,"72":0,"73":10003,"74":20,"75":10,"76":9,"77":9,"78":5,"79":10005,"80":59,"81":10059,"82":3,"83":10003,"84":10003,"85":0,"86":10003,"87":2,"88":2,"89":2,"90":2,"91":1,"92":80193,"93":0,"94":80193,"95":20174,"96":60019,"97":9,"98":14,"99":10,"100":0,"101":0,"102":0,"103":0,"104":10,"105":10,"106":0,"107":0,"108":0,"109":0,"110":10,"111":10,"112":3,"113":3,"114":3,"115":3,"116":3,"117":3,"118":2,"119":2,"120":2,"121":2,"122":2,"123":2,"124":0,"125":10,"126":10,"127":0,"128":10,"129":10,"130":0,"131":10,"132":10,"133":0,"134":10,"135":20,"136":6,"137":1,"138":5,"139":30005,"140":14,"141":20,"142":6,"143":6,"144":0,"145":0,"146":14,"147":20,"148":18,"149":40018,"150":18,"151":2,"152":2,"153":2,"154":0,"155":20,"156":40020,"157":40006,"158":14,"159":40020,"160":6,"161":40014,"162":40020,"163":4,"164":4,"165":40020,"166":10005,"167":0,"168":10005,"169":10059,"170":0,"171":10059,"172":2,"173":0,"174":2,"175":0,"176":2,"177":12,"178":5,"179":7,"180":7,"181":0,"182":0,"183":0,"184":60,"185":12,"186":48,"187":10059,"188":10059,"189":20094,"190":20094,"191":20094,"192":20094,"193":10007,"194":10087,"195":10087,"196":10087,"197":10087,"198":10087,"199":1,"200":10086,"201":10033,"202":10033,"203":53,"204":31,"205":31,"206":75,"207":75,"208":30,"209":3,"210":27,"211":27,"212":45,"213":0,"214":26,"215":25,"216":20094,"217":20094,"218":10042,"219":10042,"220":20094,"221":20094,"222":20094,"223":40272,"224":12,"225":11,"226":12,"227":34,"228":34,"229":30,"230":30,"231":10035,"232":10035,"233":20094,"234":20094,"235":20094,"236":10162,"237":10162,"238":30228,"239":7,"240":30221,"241":32,"242":32,"243":32,"244":32,"245":32,"246":8,"247":8,"248":32,"249":32,"250":32,"251":60,"252":19,"253":19,"254":41,"255":41,"256":41,"257":41,"258":41,"259":10,"260":31,"261":31,"262":10,"263":10,"264":3,"265":28,"266":12,"267":28,"268":19,"269":6,"270":13,"271":14,"272":14,"273":14,"274":4,"275":4,"276":1,"277":1,"278":30174,"279":71,"280":30103,"281":30103,"282":10064,"283":10064,"284":10064,"285":10064,"286":51,"287":51,"288":12,"289":12,"290":39,"291":8,"292":8,"293":0,"294":0,"295":39,"296":39,"297":39,"298":1,"299":39},"f":{"0":113,"1":113,"2":1,"3":111,"4":1,"5":108,"6":0,"7":1,"8":0,"9":10001,"10":0,"11":140,"12":21,"13":0,"14":10004,"15":10004,"16":9,"17":10005,"18":10059,"19":10003,"20":2,"21":2,"22":80193,"23":9,"24":14,"25":10,"26":0,"27":0,"28":3,"29":3,"30":2,"31":2,"32":10,"33":20,"34":30005,"35":0,"36":40018,"37":2,"38":40020,"39":10005,"40":10059,"41":2,"42":12,"43":60,"44":10059,"45":20094,"46":10162,"47":51},"b":{"0":[0],"1":[1,111,1],"2":[1],"3":[108],"4":[0],"5":[1],"6":[21],"7":[0,4,4,18,20,3,5,7,10,9,5,59,3,2,2,1],"8":[0,0],"9":[20010,0],"10":[10003],"11":[0],"12":[50013,0],"13":[1],"14":[0],"15":[0],"16":[0],"17":[20174],"18":[0,10],"19":[0,0],"20":[0,10],"21":[0,0],"22":[3,3,2,2,0],"23":[0,10],"24":[0,10],"25":[0],"26":[10,10],"27":[6,14],"28":[1,5],"29":[6,14],"30":[6,0],"31":[18,2,0],"32":[40006,14],"33":[6,40014],"34":[4],"35":[40020,4],"36":[0],"37":[10005,10005],"38":[0],"39":[10059,10059],"40":[0],"41":[0],"42":[2,2],"43":[5],"44":[7],"45":[7,4,2,7],"46":[0],"47":[0,0,0],"48":[12],"49":[60,53],"50":[10007],"51":[20094,10042],"52":[1],"53":[10033],"54":[10086,10034,10016],"55":[31],"56":[30],"57":[3],"58":[30,12],"59":[0],"60":[30136,20129],"61":[12,34,30,10035],"62":[11],"63":[10035],"64":[7],"65":[32,14,4,30174],"66":[8],"67":[32,30],"68":[19],"69":[60,57,20],"70":[10],"71":[10],"72":[3],"73":[12],"74":[28,20],"75":[6],"76":[1],"77":[71],"78":[12],"79":[51,48,43],"80":[8],"81":[0],"82":[1]}} +,"/Users/oscb/Projects/segment/tsub-js/src/store.ts": {"path":"/Users/oscb/Projects/segment/tsub-js/src/store.ts","statementMap":{"0":{"start":{"line":21,"column":0},"end":{"line":21,"column":null}},"1":{"start":{"line":25,"column":14},"end":{"line":25,"column":null}},"2":{"start":{"line":22,"column":19},"end":{"line":22,"column":null}},"3":{"start":{"line":23,"column":19},"end":{"line":23,"column":null}},"4":{"start":{"line":27,"column":4},"end":{"line":38,"column":null}},"5":{"start":{"line":27,"column":23},"end":{"line":27,"column":28}},"6":{"start":{"line":27,"column":19},"end":{"line":27,"column":23}},"7":{"start":{"line":29,"column":6},"end":{"line":37,"column":null}},"8":{"start":{"line":30,"column":8},"end":{"line":32,"column":null}},"9":{"start":{"line":31,"column":10},"end":{"line":31,"column":null}},"10":{"start":{"line":34,"column":8},"end":{"line":34,"column":null}},"11":{"start":{"line":36,"column":8},"end":{"line":36,"column":null}},"12":{"start":{"line":41,"column":9},"end":{"line":50,"column":null}},"13":{"start":{"line":42,"column":15},"end":{"line":42,"column":47}},"14":{"start":{"line":44,"column":29},"end":{"line":44,"column":69}},"15":{"start":{"line":45,"column":4},"end":{"line":47,"column":null}},"16":{"start":{"line":46,"column":6},"end":{"line":46,"column":37}},"17":{"start":{"line":49,"column":4},"end":{"line":49,"column":null}},"18":{"start":{"line":51,"column":0},"end":{"line":51,"column":null}}},"fnMap":{"0":{"name":"(anonymous_1)","decl":{"start":{"line":21,"column":0},"end":{"line":21,"column":null}},"loc":{"start":{"line":21,"column":0},"end":{"line":51,"column":null}}},"1":{"name":"Store","decl":{"start":{"line":25,"column":2},"end":{"line":25,"column":14}},"loc":{"start":{"line":25,"column":32},"end":{"line":39,"column":3}}},"2":{"name":"(anonymous_3)","decl":{"start":{"line":41,"column":2},"end":{"line":41,"column":9}},"loc":{"start":{"line":41,"column":58},"end":{"line":50,"column":3}}}},"branchMap":{"0":{"loc":{"start":{"line":25,"column":14},"end":{"line":25,"column":null}},"type":"if","locations":[{"start":{"line":25,"column":14},"end":{"line":25,"column":null}}]},"1":{"loc":{"start":{"line":29,"column":6},"end":{"line":37,"column":null}},"type":"if","locations":[{"start":{"line":29,"column":6},"end":{"line":37,"column":null}},{"start":{"line":35,"column":13},"end":{"line":37,"column":null}}]},"2":{"loc":{"start":{"line":30,"column":8},"end":{"line":32,"column":null}},"type":"if","locations":[{"start":{"line":30,"column":8},"end":{"line":32,"column":null}}]},"3":{"loc":{"start":{"line":45,"column":4},"end":{"line":47,"column":null}},"type":"if","locations":[{"start":{"line":45,"column":4},"end":{"line":47,"column":null}}]},"4":{"loc":{"start":{"line":45,"column":8},"end":{"line":45,"column":38}},"type":"binary-expr","locations":[{"start":{"line":45,"column":8},"end":{"line":45,"column":38}},{"start":{"line":45,"column":42},"end":{"line":45,"column":69}}]}},"s":{"0":1,"1":2,"2":2,"3":2,"4":2,"5":4,"6":2,"7":2,"8":1,"9":1,"10":1,"11":1,"12":1,"13":3,"14":3,"15":3,"16":1,"17":3,"18":1},"f":{"0":1,"1":2,"2":3},"b":{"0":[0],"1":[1,1],"2":[1],"3":[1],"4":[3,1]}} +} diff --git a/coverage/lcov-report/base.css b/coverage/lcov-report/base.css new file mode 100644 index 0000000..f418035 --- /dev/null +++ b/coverage/lcov-report/base.css @@ -0,0 +1,224 @@ +body, html { + margin:0; padding: 0; + height: 100%; +} +body { + font-family: Helvetica Neue, Helvetica, Arial; + font-size: 14px; + color:#333; +} +.small { font-size: 12px; } +*, *:after, *:before { + -webkit-box-sizing:border-box; + -moz-box-sizing:border-box; + box-sizing:border-box; + } +h1 { font-size: 20px; margin: 0;} +h2 { font-size: 14px; } +pre { + font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; + margin: 0; + padding: 0; + -moz-tab-size: 2; + -o-tab-size: 2; + tab-size: 2; +} +a { color:#0074D9; text-decoration:none; } +a:hover { text-decoration:underline; } +.strong { font-weight: bold; } +.space-top1 { padding: 10px 0 0 0; } +.pad2y { padding: 20px 0; } +.pad1y { padding: 10px 0; } +.pad2x { padding: 0 20px; } +.pad2 { padding: 20px; } +.pad1 { padding: 10px; } +.space-left2 { padding-left:55px; } +.space-right2 { padding-right:20px; } +.center { text-align:center; } +.clearfix { display:block; } +.clearfix:after { + content:''; + display:block; + height:0; + clear:both; + visibility:hidden; + } +.fl { float: left; } +@media only screen and (max-width:640px) { + .col3 { width:100%; max-width:100%; } + .hide-mobile { display:none!important; } +} + +.quiet { + color: #7f7f7f; + color: rgba(0,0,0,0.5); +} +.quiet a { opacity: 0.7; } + +.fraction { + font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; + font-size: 10px; + color: #555; + background: #E8E8E8; + padding: 4px 5px; + border-radius: 3px; + vertical-align: middle; +} + +div.path a:link, div.path a:visited { color: #333; } +table.coverage { + border-collapse: collapse; + margin: 10px 0 0 0; + padding: 0; +} + +table.coverage td { + margin: 0; + padding: 0; + vertical-align: top; +} +table.coverage td.line-count { + text-align: right; + padding: 0 5px 0 20px; +} +table.coverage td.line-coverage { + text-align: right; + padding-right: 10px; + min-width:20px; +} + +table.coverage td span.cline-any { + display: inline-block; + padding: 0 5px; + width: 100%; +} +.missing-if-branch { + display: inline-block; + margin-right: 5px; + border-radius: 3px; + position: relative; + padding: 0 4px; + background: #333; + color: yellow; +} + +.skip-if-branch { + display: none; + margin-right: 10px; + position: relative; + padding: 0 4px; + background: #ccc; + color: white; +} +.missing-if-branch .typ, .skip-if-branch .typ { + color: inherit !important; +} +.coverage-summary { + border-collapse: collapse; + width: 100%; +} +.coverage-summary tr { border-bottom: 1px solid #bbb; } +.keyline-all { border: 1px solid #ddd; } +.coverage-summary td, .coverage-summary th { padding: 10px; } +.coverage-summary tbody { border: 1px solid #bbb; } +.coverage-summary td { border-right: 1px solid #bbb; } +.coverage-summary td:last-child { border-right: none; } +.coverage-summary th { + text-align: left; + font-weight: normal; + white-space: nowrap; +} +.coverage-summary th.file { border-right: none !important; } +.coverage-summary th.pct { } +.coverage-summary th.pic, +.coverage-summary th.abs, +.coverage-summary td.pct, +.coverage-summary td.abs { text-align: right; } +.coverage-summary td.file { white-space: nowrap; } +.coverage-summary td.pic { min-width: 120px !important; } +.coverage-summary tfoot td { } + +.coverage-summary .sorter { + height: 10px; + width: 7px; + display: inline-block; + margin-left: 0.5em; + background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; +} +.coverage-summary .sorted .sorter { + background-position: 0 -20px; +} +.coverage-summary .sorted-desc .sorter { + background-position: 0 -10px; +} +.status-line { height: 10px; } +/* yellow */ +.cbranch-no { background: yellow !important; color: #111; } +/* dark red */ +.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } +.low .chart { border:1px solid #C21F39 } +.highlighted, +.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{ + background: #C21F39 !important; +} +/* medium red */ +.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } +/* light red */ +.low, .cline-no { background:#FCE1E5 } +/* light green */ +.high, .cline-yes { background:rgb(230,245,208) } +/* medium green */ +.cstat-yes { background:rgb(161,215,106) } +/* dark green */ +.status-line.high, .high .cover-fill { background:rgb(77,146,33) } +.high .chart { border:1px solid rgb(77,146,33) } +/* dark yellow (gold) */ +.status-line.medium, .medium .cover-fill { background: #f9cd0b; } +.medium .chart { border:1px solid #f9cd0b; } +/* light yellow */ +.medium { background: #fff4c2; } + +.cstat-skip { background: #ddd; color: #111; } +.fstat-skip { background: #ddd; color: #111 !important; } +.cbranch-skip { background: #ddd !important; color: #111; } + +span.cline-neutral { background: #eaeaea; } + +.coverage-summary td.empty { + opacity: .5; + padding-top: 4px; + padding-bottom: 4px; + line-height: 1; + color: #888; +} + +.cover-fill, .cover-empty { + display:inline-block; + height: 12px; +} +.chart { + line-height: 0; +} +.cover-empty { + background: white; +} +.cover-full { + border-right: none !important; +} +pre.prettyprint { + border: none !important; + padding: 0 !important; + margin: 0 !important; +} +.com { color: #999 !important; } +.ignore-none { color: #999; font-weight: normal; } + +.wrapper { + min-height: 100%; + height: auto !important; + height: 100%; + margin: 0 auto -48px; +} +.footer, .push { + height: 48px; +} diff --git a/coverage/lcov-report/block-navigation.js b/coverage/lcov-report/block-navigation.js new file mode 100644 index 0000000..cc12130 --- /dev/null +++ b/coverage/lcov-report/block-navigation.js @@ -0,0 +1,87 @@ +/* eslint-disable */ +var jumpToCode = (function init() { + // Classes of code we would like to highlight in the file view + var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no']; + + // Elements to highlight in the file listing view + var fileListingElements = ['td.pct.low']; + + // We don't want to select elements that are direct descendants of another match + var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > ` + + // Selecter that finds elements on the page to which we can jump + var selector = + fileListingElements.join(', ') + + ', ' + + notSelector + + missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b` + + // The NodeList of matching elements + var missingCoverageElements = document.querySelectorAll(selector); + + var currentIndex; + + function toggleClass(index) { + missingCoverageElements + .item(currentIndex) + .classList.remove('highlighted'); + missingCoverageElements.item(index).classList.add('highlighted'); + } + + function makeCurrent(index) { + toggleClass(index); + currentIndex = index; + missingCoverageElements.item(index).scrollIntoView({ + behavior: 'smooth', + block: 'center', + inline: 'center' + }); + } + + function goToPrevious() { + var nextIndex = 0; + if (typeof currentIndex !== 'number' || currentIndex === 0) { + nextIndex = missingCoverageElements.length - 1; + } else if (missingCoverageElements.length > 1) { + nextIndex = currentIndex - 1; + } + + makeCurrent(nextIndex); + } + + function goToNext() { + var nextIndex = 0; + + if ( + typeof currentIndex === 'number' && + currentIndex < missingCoverageElements.length - 1 + ) { + nextIndex = currentIndex + 1; + } + + makeCurrent(nextIndex); + } + + return function jump(event) { + if ( + document.getElementById('fileSearch') === document.activeElement && + document.activeElement != null + ) { + // if we're currently focused on the search input, we don't want to navigate + return; + } + + switch (event.which) { + case 78: // n + case 74: // j + goToNext(); + break; + case 66: // b + case 75: // k + case 80: // p + goToPrevious(); + break; + } + }; +})(); +window.addEventListener('keydown', jumpToCode); diff --git a/coverage/lcov-report/favicon.png b/coverage/lcov-report/favicon.png new file mode 100644 index 0000000..6691817 Binary files /dev/null and b/coverage/lcov-report/favicon.png differ diff --git a/coverage/lcov-report/index.html b/coverage/lcov-report/index.html new file mode 100644 index 0000000..4d56634 --- /dev/null +++ b/coverage/lcov-report/index.html @@ -0,0 +1,146 @@ + + + + + + Code coverage report for All files + + + + + + + + + +
+
+

All files

+
+ +
+ 86.5% + Statements + 282/326 +
+ + +
+ 78.21% + Branches + 122/156 +
+ + +
+ 85.45% + Functions + 47/55 +
+ + +
+ 87.2% + Lines + 252/289 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
FileStatementsBranchesFunctionsLines
index.ts +
+
100%7/7100%0/075%3/4100%3/3
matchers.ts +
+
85.33%256/30077.85%116/14985.42%41/4886.25%232/269
store.ts +
+
100%19/1985.71%6/7100%3/3100%17/17
+
+
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/index.ts.html b/coverage/lcov-report/index.ts.html new file mode 100644 index 0000000..6c244d0 --- /dev/null +++ b/coverage/lcov-report/index.ts.html @@ -0,0 +1,94 @@ + + + + + + Code coverage report for index.ts + + + + + + + + + +
+
+

All files index.ts

+
+ +
+ 100% + Statements + 7/7 +
+ + +
+ 100% + Branches + 0/0 +
+ + +
+ 75% + Functions + 3/4 +
+ + +
+ 100% + Lines + 3/3 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +44x +6x +3x + 
export { default as transform } from './transformers'
+export { default as matches, getMatchFunction } from './matchers'
+export { default as Store } from './store'
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/matchers.ts.html b/coverage/lcov-report/matchers.ts.html new file mode 100644 index 0000000..bbba79b --- /dev/null +++ b/coverage/lcov-report/matchers.ts.html @@ -0,0 +1,1945 @@ + + + + + + Code coverage report for matchers.ts + + + + + + + + + +
+
+

All files matchers.ts

+
+ +
+ 85.33% + Statements + 256/300 +
+ + +
+ 77.85% + Branches + 116/149 +
+ + +
+ 85.42% + Functions + 41/48 +
+ + +
+ 86.25% + Lines + 232/269 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271 +272 +273 +274 +275 +276 +277 +278 +279 +280 +281 +282 +283 +284 +285 +286 +287 +288 +289 +290 +291 +292 +293 +294 +295 +296 +297 +298 +299 +300 +301 +302 +303 +304 +305 +306 +307 +308 +309 +310 +311 +312 +313 +314 +315 +316 +317 +318 +319 +320 +321 +322 +323 +324 +325 +326 +327 +328 +329 +330 +331 +332 +333 +334 +335 +336 +337 +338 +339 +340 +341 +342 +343 +344 +345 +346 +347 +348 +349 +350 +351 +352 +353 +354 +355 +356 +357 +358 +359 +360 +361 +362 +363 +364 +365 +366 +367 +368 +369 +370 +371 +372 +373 +374 +375 +376 +377 +378 +379 +380 +381 +382 +383 +384 +385 +386 +387 +388 +389 +390 +391 +392 +393 +394 +395 +396 +397 +398 +399 +400 +401 +402 +403 +404 +405 +406 +407 +408 +409 +410 +411 +412 +413 +414 +415 +416 +417 +418 +419 +420 +421 +422 +423 +424 +425 +426 +427 +428 +429 +430 +431 +432 +433 +434 +435 +436 +437 +438 +439 +440 +441 +442 +443 +444 +445 +446 +447 +448 +449 +450 +451 +452 +453 +454 +455 +456 +457 +458 +459 +460 +461 +462 +463 +464 +465 +466 +467 +468 +469 +470 +471 +472 +473 +474 +475 +476 +477 +478 +479 +480 +481 +482 +483 +484 +485 +486 +487 +488 +489 +490 +491 +492 +493 +494 +495 +496 +497 +498 +499 +500 +501 +502 +503 +504 +505 +506 +507 +508 +509 +510 +511 +512 +513 +514 +515 +516 +517 +518 +519 +520 +521 +522 +523 +524 +525 +526 +527 +528 +529 +530 +531 +532 +533 +534 +535 +536 +537 +538 +539 +540 +541 +542 +543 +544 +545 +546 +547 +548 +549 +550 +551 +552 +553 +554 +555 +556 +557 +558 +559 +560 +561 +562 +563 +564 +565 +566 +567 +568 +569 +570 +571 +572 +573 +574 +575 +576 +577 +578 +579 +580 +581 +582 +583 +584 +585 +586 +587 +588 +589 +590 +591 +592 +593 +594 +595 +596 +597 +598 +599 +600 +601 +602 +603 +604 +605 +606 +607 +608 +609 +610 +611 +612 +613 +614 +615 +616 +617 +618 +619 +620 +621  +2x +  +2x +113x +  +  +2x +113x +  +  +  +113x +  +1x +  +111x +  +1x +  +  +  +  +1x +  +  +  +111x +1x +  +  +110x +110x +  +1x +  +  +109x +108x +108x +  +  +  +  +2x +1x +  +  +  +1x +1x +  +  +  +  +1x +1x +10001x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +140x +21x +  +  +119x +  +119x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +4x +4x +10x +  +4x +20010x +20010x +20010x +10003x +  +  +  +  +  +1x +  +  +  +  +4x +4x +13x +  +4x +50013x +50013x +50013x +1x +  +  +  +  +  +  +  +10003x +  +  +  +  +  +20x +  +  +  +  +  +  +10x +  +  +9x +9x +  +  +  +  +  +5x +10005x +  +  +  +59x +10059x +  +  +  +3x +10003x +10003x +  +  +10003x +  +  +  +  +2x +2x +  +  +  +2x +2x +  +  +  +1x +  +  +  +  +  +80193x +  +  +  +  +80193x +20174x +  +  +  +60019x +  +  +  +14x +  +  +  +  +  +  +  +10x +  +  +  +  +  +  +10x +  +  +10x +  +  +  +  +  +  +10x +  +  +  +  +10x +  +  +3x +3x +  +  +3x +3x +  +  +2x +2x +  +  +2x +2x +  +  +  +  +10x +  +  +10x +  +  +10x +  +  +10x +  +  +10x +  +  +10x +  +  +  +10x +  +  +  +  +  +  +  +  +20x +6x +1x +  +30005x +  +  +14x +  +  +20x +6x +6x +  +  +  +  +14x +  +  +  +  +  +  +  +20x +  +  +40018x +18x +  +  +2x +2x +  +  +  +  +20x +  +  +40020x +40006x +  +14x +  +  +40020x +6x +  +40014x +  +  +40020x +4x +4x +  +  +40020x +  +  +  +  +10005x +  +  +  +10005x +  +  +  +10059x +  +  +  +10059x +  +  +  +  +2x +  +  +  +  +2x +  +  +  +2x +  +  +  +  +  +  +12x +5x +  +  +  +7x +  +  +  +7x +  +  +  +  +  +  +  +  +  +  +60x +12x +  +  +48x +  +  +  +  +  +  +  +10059x +20094x +20094x +20094x +20094x +  +10007x +  +  +  +10087x +10087x +1x +  +  +  +  +  +10086x +10033x +10033x +  +  +53x +  +31x +75x +75x +  +30x +3x +  +  +27x +27x +  +  +45x +  +  +  +  +  +26x +  +  +25x +  +  +  +20094x +  +  +  +  +  +20094x +10042x +10042x +  +  +20094x +  +  +20094x +40272x +  +  +12x +11x +  +12x +  +34x +34x +  +30x +30x +  +10035x +10035x +  +  +  +  +20094x +20094x +20094x +  +  +  +  +  +  +10162x +  +  +  +  +  +10162x +30228x +7x +  +  +30221x +  +32x +32x +32x +  +32x +32x +8x +8x +  +  +  +32x +32x +32x +60x +19x +19x +  +  +41x +41x +41x +41x +41x +10x +  +  +31x +31x +10x +10x +3x +  +  +  +28x +12x +  +  +28x +  +  +19x +6x +  +13x +  +14x +14x +14x +  +4x +4x +1x +1x +  +  +  +30174x +71x +  +30103x +30103x +  +  +  +10064x +10064x +10064x +10064x +  +  +  +  +51x +  +  +  +  +  +51x +12x +12x +  +  +39x +8x +8x +  +  +  +  +  +  +  +39x +39x +39x +1x +  +  +39x +  + 
import * as Store from './store'
+import get from 'dlv'
+ 
+export default function matches(event: unknown, matcher: Store.Matcher): boolean {
+  return getMatchFunction(matcher)(event)
+}
+ 
+export function getMatchFunction(matcher: Store.Matcher): (event: unknown) => boolean {
+  Iif (!matcher) {
+    throw new Error('No matcher supplied!')
+  }
+ 
+  switch (matcher.type) {
+    case 'all':
+      return all
+    case 'fql':
+      return fql(matcher.ir)
+    default:
+      throw new Error(`Matcher of type ${matcher.type} unsupported.`)
+  }
+}
+ 
+function all(): boolean {
+  return true
+}
+ 
+function fql(ir: Store.Matcher['ir']): (event: unknown) => boolean {
+  if (!ir) {
+    return () => false
+  }
+ 
+  try {
+    ir = JSON.parse(ir)
+  } catch (e) {
+    throw new Error(`Failed to JSON.parse FQL intermediate representation "${ir}": ${e}`)
+  }
+ 
+  const evaluator = generateEvaluator(ir)
+  if (typeof evaluator === 'function') {
+    return (event) => !!evaluator(event)
+  }
+  return () => !!evaluator
+}
+ 
+export function generateFQLEval(ir: Store.Matcher['ir']): (event: unknown) => boolean {
+  Iif (!ir) {
+    return () => false
+  }
+ 
+  try {
+    ir = JSON.parse(ir)
+  } catch (e) {
+    throw new Error(`Failed to JSON.parse FQL intermediate representation "${ir}": ${e}`)
+  }
+ 
+  const evaluator = generateEvaluator(ir)
+  if (typeof evaluator === 'function') {
+    return (event) => !!evaluator(event)
+  }
+  return () => !!evaluator
+}
+ 
+type FQLEvaluator =
+  | ((event: any) => boolean)
+  | ((event: any) => string)
+  | ((event: any) => number)
+  | string
+  | number
+  | boolean
+  | Array<String | boolean | number>
+ 
+// Creates a function for evaluating a given FQL
+function generateEvaluator(ir: string | string[]): FQLEvaluator {
+  // If the given ir chunk is not an array, then we should check the single given path or value for literally `true`.
+  if (!Array.isArray(ir)) {
+    return (event: any) => getValue(ir, event) === true
+  }
+ 
+  const item = ir[0]
+ 
+  switch (item) {
+    /*** Unary cases ***/
+    // '!' => Invert the result
+    case '!':
+      const op = generateEvaluator(ir[1])
+      if (typeof op === 'function') {
+        return (event: any) => {
+          return !op(event)
+        }
+      } else {
+        return !op
+      }
+    /*** Binary cases ***/
+    // 'or' => Any condition being true returns true
+    case 'or':
+      const orOps: FQLEvaluator[] = []
+      for (let i = 1; i < ir.length; i++) {
+        orOps.push(generateEvaluator(ir[i]))
+      }
+      return (event: any) => {
+        for (const op of orOps) {
+          if (typeof op === 'function') {
+            if (op(event)) {
+              return true
+            }
+          } else E{
+            Iif (op) return true
+          }
+        }
+        return false
+      }
+ 
+    // 'and' => Any condition being false returns false
+    case 'and':
+      const andOps: FQLEvaluator[] = []
+      for (let i = 1; i < ir.length; i++) {
+        andOps.push(generateEvaluator(ir[i]))
+      }
+      return (event: any) => {
+        for (const op of andOps) {
+          if (typeof op === 'function') {
+            if (!op(event)) {
+              return false
+            }
+          } else E{
+            Iif (!op) {
+              return false
+            }
+          }
+        }
+        return true
+      }
+ 
+    // Equivalence comparisons
+    case '=':
+    case '!=':
+      return compareItemsGenerator(ir[1], ir[2], item)
+    // Numerical comparisons
+    case '<=':
+    case '<':
+    case '>':
+    case '>=':
+      // Compare the two values with the given operator.
+      return compareNumbersGenerator(ir[1], ir[2], item)
+    // item in [list]' => Checks whether item is in list
+    case 'in':
+      return (event) => {
+        return checkInList(getValue(ir[1], event), getValue(ir[2], event), event)
+      }
+ 
+    /*** Functions ***/
+    // 'contains(str1, str2)' => The first string has a substring of the second string
+    case 'contains':
+      return (event) => {
+        return contains(getValue(ir[1], event), getValue(ir[2], event))
+      }
+    // 'match(str, match)' => The given string matches the provided glob matcher
+    case 'match':
+      return (event) => {
+        return match(getValue(ir[1], event), getValue(ir[2], event))
+      }
+    // 'lowercase(str)' => Returns a lowercased string, null if the item is not a string
+    case 'lowercase':
+      return (event) => {
+        const target = getValue(ir[1], event)
+        Iif (typeof target !== 'string') {
+          return null
+        }
+        return target.toLowerCase()
+      }
+    // 'typeof(val)' => Returns the FQL type of the value
+    case 'typeof':
+      // TODO: Do we need mapping to allow for universal comparisons? e.g. Object -> JSON, Array -> List, Floats?
+      return (event) => {
+        return typeof getValue(ir[1], event)
+      }
+    // 'length(val)' => Returns the length of an array or string, NaN if neither
+    case 'length':
+      return (event) => {
+        return length(getValue(ir[1], event))
+      }
+    // If nothing hit, we or the IR messed up somewhere.
+    default:
+      throw new Error(`FQL IR could not evaluate for token: ${item}`)
+  }
+}
+ 
+function getValue(item, event) {
+  // If item is an array, leave it as-is.
+  Iif (Array.isArray(item)) {
+    return item
+  }
+ 
+  // If item is an object, it has the form of `{"value": VAL}`
+  if (typeof item === 'object') {
+    return item.value
+  }
+ 
+  // Otherwise, it's an event path, e.g. "properties.email"
+  return get(event, item)
+}
+ 
+function checkInList(item, list, event): boolean {
+  return list.find((it) => getValue(it, event) === item) !== undefined
+}
+ 
+function compareNumbersGenerator(first, second, operator): (event) => boolean {
+  // Check if it's more IR (such as a length() function)
+  let firstEval: FQLEvaluator
+  let secondEval: FQLEvaluator
+ 
+  Iif (!isStatic(first)) {
+    if (isIR(first)) {
+      firstEval = generateEvaluator(first)
+    } else {
+      firstEval = (event) => getValue(first, event)
+    }
+  } else {
+    firstEval = first.value
+  }
+ 
+  Iif (!isStatic(second)) {
+    if (isIR(second)) {
+      secondEval = generateEvaluator(second)
+    } else {
+      secondEval = (event) => getValue(second, event)
+    }
+  } else {
+    secondEval = second.value
+  }
+ 
+  // Reminder: NaN is not comparable to any other number (including NaN) and will always return false as desired.
+  let op: (a: number, b: number) => boolean
+  switch (operator) {
+    // '<=' => The first number is less than or equal to the second.
+    case '<=':
+      op = (a, b) => a <= b
+      break
+    // '>=' => The first number is greater than or equal to the second
+    case '>=':
+      op = (a, b) => a >= b
+      break
+    // '<' The first number is less than the second.
+    case '<':
+      op = (a, b) => a < b
+      break
+    // '>' The first number is greater than the second.
+    case '>':
+      op = (a, b) => a > b
+      break
+    default:
+      throw new Error(`Invalid operator in compareNumbers: ${operator}`)
+  }
+ 
+  return (event) => {
+    let a, b
+ 
+    Iif (typeof firstEval === 'function') {
+      a = firstEval(event)
+    } else {
+      a = firstEval
+    }
+ 
+    Iif (typeof secondEval === 'function') {
+      b = secondEval(event)
+    } else {
+      b = secondEval
+    }
+ 
+    Iif (typeof a !== 'number' || typeof b !== 'number') {
+      return false
+    }
+ 
+    return op(a, b)
+  }
+}
+ 
+function compareItemsGenerator(first, second, operator): FQLEvaluator {
+  let firstEval: FQLEvaluator
+  let secondEval: FQLEvaluator
+ 
+  // Check if it's more IR (such as a lowercase() function)
+  if (!isStatic(first)) {
+    if (isIR(first)) {
+      firstEval = generateEvaluator(first)
+    } else {
+      firstEval = (event) => getValue(first, event)
+    }
+  } else {
+    firstEval = first.value
+  }
+ 
+  if (!isStatic(second)) {
+    if (isIR(second)) {
+      secondEval = generateEvaluator(second)
+    } else E{
+      secondEval = (event) => getValue(second, event)
+    }
+  } else {
+    secondEval = second.value
+  }
+ 
+  // Objects with the exact same contents AND order ARE considered identical. (Don't compare by reference)
+  // Even in Go, this MUST be the same byte order.
+  // e.g. {a: 1, b:2} === {a: 1, b:2} BUT {a:1, b:2} !== {b:2, a:1}
+  // Maybe later we'll use a stable stringifier, but we're matching server-side behavior for now.
+  let compareOp: (a: unknown, b: unknown) => boolean
+  switch (operator) {
+    // '=' => The two following items are exactly identical
+    case '=':
+      compareOp = (a, b) => a === b
+      break
+    // '!=' => The two following items are NOT exactly identical.
+    case '!=':
+      compareOp = (a, b) => a !== b
+      break
+    default:
+      throw new Error(`Invalid operator in compareItems: ${operator}`)
+  }
+ 
+  return (event) => {
+    let a, b
+ 
+    if (typeof firstEval === 'function') {
+      a = firstEval(event)
+    } else {
+      a = firstEval
+    }
+ 
+    if (typeof secondEval === 'function') {
+      b = secondEval(event)
+    } else {
+      b = secondEval
+    }
+ 
+    if (typeof a === 'object' && typeof b === 'object') {
+      a = JSON.stringify(a)
+      b = JSON.stringify(b)
+    }
+ 
+    return compareOp(a, b)
+  }
+}
+ 
+function contains(first, second): boolean {
+  Iif (typeof first !== 'string' || typeof second !== 'string') {
+    return false
+  }
+ 
+  return first.indexOf(second) !== -1
+}
+ 
+function match(str, glob): boolean {
+  Iif (typeof str !== 'string' || typeof glob !== 'string') {
+    return false
+  }
+ 
+  return globMatches(glob, str)
+}
+ 
+function length(item) {
+  // Match server-side behavior.
+  Iif (item === null) {
+    return 0
+  }
+ 
+  // Type-check to avoid returning .length of an object
+  Iif (!Array.isArray(item) && typeof item !== 'string') {
+    return NaN
+  }
+ 
+  return item.length
+}
+ 
+// This is a heuristic technically speaking, but should be close enough. The odds of someone trying to test
+// a func with identical IR notation is pretty low.
+function isIR(value): boolean {
+  // TODO: This can be better checked by checking if this is a {"value": THIS}
+  if (!Array.isArray(value)) {
+    return false
+  }
+ 
+  // Function checks
+  if (
+    (value[0] === 'lowercase' || value[0] === 'length' || value[0] === 'typeof') &&
+    value.length === 2
+  ) {
+    return true
+  }
+ 
+  Iif ((value[0] === 'contains' || value[0] === 'match') && value.length === 3) {
+    return true
+  }
+ 
+  return false
+}
+ 
+function isStatic(ir: Store.Matcher | string): boolean {
+  if (Array.isArray(ir) || typeof ir !== 'object') {
+    return false
+  }
+ 
+  return true
+}
+ 
+// Any reputable glob matcher is designed to work on filesystems and doesn't allow the override of the separator
+// character "/". This is problematic since our server-side representation e.g. evaluates "match('ab/c', 'a*)"
+// as TRUE, whereas any glob matcher for JS available does false. So we're rewriting it here.
+// See: https://github.com/segmentio/glob/blob/master/glob.go
+function globMatches(pattern, str): boolean {
+  Pattern: while (pattern.length > 0) {
+    let star
+    let chunk
+    ;({ star, chunk, pattern } = scanChunk(pattern))
+    if (star && chunk === '') {
+      // Trailing * matches rest of string
+      return true
+    }
+ 
+    // Look for match at current position
+    let { t, ok, err } = matchChunk(chunk, str)
+    if (err) {
+      return false
+    }
+ 
+    // If we're the last chunk, make sure we've exhausted the str
+    // otherwise we'll give a false result even if we could still match
+    // using the star
+    if (ok && (t.length === 0 || pattern.length > 0)) {
+      str = t
+      continue
+    }
+ 
+    if (star) {
+      // Look for match, skipping i+1 bytes.
+      for (let i = 0; i < str.length; i++) {
+        ;({ t, ok, err } = matchChunk(chunk, str.slice(i + 1)))
+        if (ok) {
+          // If we're the last chunk, make sure we exhausted the str.
+          if (pattern.length === 0 && t.length > 0) {
+            continue
+          }
+ 
+          str = t
+          continue Pattern
+        }
+ 
+        Iif (err) {
+          return false
+        }
+      }
+    }
+ 
+    return false
+  }
+ 
+  return str.length === 0
+}
+ 
+function scanChunk(pattern): any {
+  const result = {
+    star: false,
+    chunk: '',
+    pattern: '',
+  }
+ 
+  while (pattern.length > 0 && pattern[0] === '*') {
+    pattern = pattern.slice(1)
+    result.star = true
+  }
+ 
+  let inRange = false
+  let i
+ 
+  Scan: for (i = 0; i < pattern.length; i++) {
+    switch (pattern[i]) {
+      case '\\':
+        // Error check handled in matchChunk: bad pattern.
+        if (i + 1 < pattern.length) {
+          i++
+        }
+        break
+      case '[':
+        inRange = true
+        break
+      case ']':
+        inRange = false
+        break
+      case '*':
+        if (!inRange) {
+          break Scan
+        }
+    }
+  }
+ 
+  result.chunk = pattern.slice(0, i)
+  result.pattern = pattern.slice(i)
+  return result
+}
+ 
+// matchChunk checks whether chunk matches the beginning of s.
+// If so, it returns the remainder of s (after the match).
+// Chunk is all single-character operators: literals, char classes, and ?.
+function matchChunk(chunk, str): any {
+  const result = {
+    t: '',
+    ok: false,
+    err: false,
+  }
+ 
+  while (chunk.length > 0) {
+    if (str.length === 0) {
+      return result
+    }
+ 
+    switch (chunk[0]) {
+      case '[':
+        const char = str[0]
+        str = str.slice(1)
+        chunk = chunk.slice(1)
+ 
+        let notNegated = true
+        if (chunk.length > 0 && chunk[0] === '^') {
+          notNegated = false
+          chunk = chunk.slice(1)
+        }
+ 
+        // Parse all ranges
+        let foundMatch = false
+        let nRange = 0
+        while (true) {
+          if (chunk.length > 0 && chunk[0] === ']' && nRange > 0) {
+            chunk = chunk.slice(1)
+            break
+          }
+ 
+          let lo = ''
+          let hi = ''
+          let err
+          ;({ char: lo, newChunk: chunk, err } = getEsc(chunk))
+          if (err) {
+            return result
+          }
+ 
+          hi = lo
+          if (chunk[0] === '-') {
+            ;({ char: hi, newChunk: chunk, err } = getEsc(chunk.slice(1)))
+            if (err) {
+              return result
+            }
+          }
+ 
+          if (lo <= char && char <= hi) {
+            foundMatch = true
+          }
+ 
+          nRange++
+        }
+ 
+        if (foundMatch !== notNegated) {
+          return result
+        }
+        break
+      case '?':
+        str = str.slice(1)
+        chunk = chunk.slice(1)
+        break
+      case '\\':
+        chunk = chunk.slice(1)
+        if (chunk.length === 0) {
+          result.err = true
+          return result
+        }
+      // Fallthrough, missing break intentional.
+      default:
+        if (chunk[0] !== str[0]) {
+          return result
+        }
+        str = str.slice(1)
+        chunk = chunk.slice(1)
+    }
+  }
+ 
+  result.t = str
+  result.ok = true
+  result.err = false
+  return result
+}
+ 
+// getEsc gets a possibly-escaped character from chunk, for a character class.
+function getEsc(chunk): any {
+  const result = {
+    char: '',
+    newChunk: '',
+    err: false,
+  }
+ 
+  if (chunk.length === 0 || chunk[0] === '-' || chunk[0] === ']') {
+    result.err = true
+    return result
+  }
+ 
+  if (chunk[0] === '\\') {
+    chunk = chunk.slice(1)
+    Iif (chunk.length === 0) {
+      result.err = true
+      return result
+    }
+  }
+ 
+  // Unlike Go, JS strings operate on characters instead of bytes.
+  // This is why we aren't copying over the GetRuneFromString stuff.
+  result.char = chunk[0]
+  result.newChunk = chunk.slice(1)
+  if (result.newChunk.length === 0) {
+    result.err = true
+  }
+ 
+  return result
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/prettify.css b/coverage/lcov-report/prettify.css new file mode 100644 index 0000000..b317a7c --- /dev/null +++ b/coverage/lcov-report/prettify.css @@ -0,0 +1 @@ +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} diff --git a/coverage/lcov-report/prettify.js b/coverage/lcov-report/prettify.js new file mode 100644 index 0000000..b322523 --- /dev/null +++ b/coverage/lcov-report/prettify.js @@ -0,0 +1,2 @@ +/* eslint-disable */ +window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); diff --git a/coverage/lcov-report/sort-arrow-sprite.png b/coverage/lcov-report/sort-arrow-sprite.png new file mode 100644 index 0000000..03f704a Binary files /dev/null and b/coverage/lcov-report/sort-arrow-sprite.png differ diff --git a/coverage/lcov-report/sorter.js b/coverage/lcov-report/sorter.js new file mode 100644 index 0000000..2bb296a --- /dev/null +++ b/coverage/lcov-report/sorter.js @@ -0,0 +1,196 @@ +/* eslint-disable */ +var addSorting = (function() { + 'use strict'; + var cols, + currentSort = { + index: 0, + desc: false + }; + + // returns the summary table element + function getTable() { + return document.querySelector('.coverage-summary'); + } + // returns the thead element of the summary table + function getTableHeader() { + return getTable().querySelector('thead tr'); + } + // returns the tbody element of the summary table + function getTableBody() { + return getTable().querySelector('tbody'); + } + // returns the th element for nth column + function getNthColumn(n) { + return getTableHeader().querySelectorAll('th')[n]; + } + + function onFilterInput() { + const searchValue = document.getElementById('fileSearch').value; + const rows = document.getElementsByTagName('tbody')[0].children; + for (let i = 0; i < rows.length; i++) { + const row = rows[i]; + if ( + row.textContent + .toLowerCase() + .includes(searchValue.toLowerCase()) + ) { + row.style.display = ''; + } else { + row.style.display = 'none'; + } + } + } + + // loads the search box + function addSearchBox() { + var template = document.getElementById('filterTemplate'); + var templateClone = template.content.cloneNode(true); + templateClone.getElementById('fileSearch').oninput = onFilterInput; + template.parentElement.appendChild(templateClone); + } + + // loads all columns + function loadColumns() { + var colNodes = getTableHeader().querySelectorAll('th'), + colNode, + cols = [], + col, + i; + + for (i = 0; i < colNodes.length; i += 1) { + colNode = colNodes[i]; + col = { + key: colNode.getAttribute('data-col'), + sortable: !colNode.getAttribute('data-nosort'), + type: colNode.getAttribute('data-type') || 'string' + }; + cols.push(col); + if (col.sortable) { + col.defaultDescSort = col.type === 'number'; + colNode.innerHTML = + colNode.innerHTML + ''; + } + } + return cols; + } + // attaches a data attribute to every tr element with an object + // of data values keyed by column name + function loadRowData(tableRow) { + var tableCols = tableRow.querySelectorAll('td'), + colNode, + col, + data = {}, + i, + val; + for (i = 0; i < tableCols.length; i += 1) { + colNode = tableCols[i]; + col = cols[i]; + val = colNode.getAttribute('data-value'); + if (col.type === 'number') { + val = Number(val); + } + data[col.key] = val; + } + return data; + } + // loads all row data + function loadData() { + var rows = getTableBody().querySelectorAll('tr'), + i; + + for (i = 0; i < rows.length; i += 1) { + rows[i].data = loadRowData(rows[i]); + } + } + // sorts the table using the data for the ith column + function sortByIndex(index, desc) { + var key = cols[index].key, + sorter = function(a, b) { + a = a.data[key]; + b = b.data[key]; + return a < b ? -1 : a > b ? 1 : 0; + }, + finalSorter = sorter, + tableBody = document.querySelector('.coverage-summary tbody'), + rowNodes = tableBody.querySelectorAll('tr'), + rows = [], + i; + + if (desc) { + finalSorter = function(a, b) { + return -1 * sorter(a, b); + }; + } + + for (i = 0; i < rowNodes.length; i += 1) { + rows.push(rowNodes[i]); + tableBody.removeChild(rowNodes[i]); + } + + rows.sort(finalSorter); + + for (i = 0; i < rows.length; i += 1) { + tableBody.appendChild(rows[i]); + } + } + // removes sort indicators for current column being sorted + function removeSortIndicators() { + var col = getNthColumn(currentSort.index), + cls = col.className; + + cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); + col.className = cls; + } + // adds sort indicators for current column being sorted + function addSortIndicators() { + getNthColumn(currentSort.index).className += currentSort.desc + ? ' sorted-desc' + : ' sorted'; + } + // adds event listeners for all sorter widgets + function enableUI() { + var i, + el, + ithSorter = function ithSorter(i) { + var col = cols[i]; + + return function() { + var desc = col.defaultDescSort; + + if (currentSort.index === i) { + desc = !currentSort.desc; + } + sortByIndex(i, desc); + removeSortIndicators(); + currentSort.index = i; + currentSort.desc = desc; + addSortIndicators(); + }; + }; + for (i = 0; i < cols.length; i += 1) { + if (cols[i].sortable) { + // add the click event handler on the th so users + // dont have to click on those tiny arrows + el = getNthColumn(i).querySelector('.sorter').parentElement; + if (el.addEventListener) { + el.addEventListener('click', ithSorter(i)); + } else { + el.attachEvent('onclick', ithSorter(i)); + } + } + } + } + // adds sorting functionality to the UI + return function() { + if (!getTable()) { + return; + } + cols = loadColumns(); + loadData(); + addSearchBox(); + addSortIndicators(); + enableUI(); + }; +})(); + +window.addEventListener('load', addSorting); diff --git a/coverage/lcov-report/store.ts.html b/coverage/lcov-report/store.ts.html new file mode 100644 index 0000000..25bc0b7 --- /dev/null +++ b/coverage/lcov-report/store.ts.html @@ -0,0 +1,238 @@ + + + + + + Code coverage report for store.ts + + + + + + + + + +
+
+

All files store.ts

+
+ +
+ 100% + Statements + 19/19 +
+ + +
+ 85.71% + Branches + 6/7 +
+ + +
+ 100% + Functions + 3/3 +
+ + +
+ 100% + Lines + 17/17 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +1x +2x +2x +  +2x +  +4x +  +2x +1x +1x +  +  +1x +  +1x +  +  +  +  +1x +3x +  +3x +3x +1x +  +  +3x +  +1x + 
import { TransformerConfig } from './transformers'
+ 
+export interface Rule {
+  scope: string
+  target_type: string
+  matchers: Matcher[]
+  transformers: Transformer[][]
+  destinationName?: string
+}
+ 
+export interface Matcher {
+  type: string
+  ir: string
+}
+ 
+export interface Transformer {
+  type: string
+  config?: TransformerConfig
+}
+ 
+export default class Store {
+  private readonly rulesByDestination: { [key: string]: Rule[] } = {}
+  private readonly globalRules: Rule[] = []
+ 
+  constructor(Irules: Rule[] = []) {
+    // Initialize the maps
+    for (const rule of rules) {
+      // Rules with no destinationName are global (workspace || workspace::source)
+      if (rule.destinationName !== undefined) {
+        if (this.rulesByDestination[rule.destinationName] === undefined) {
+          this.rulesByDestination[rule.destinationName] = []
+        }
+ 
+        this.rulesByDestination[rule.destinationName].push(rule)
+      } else {
+        this.globalRules.push(rule)
+      }
+    }
+  }
+ 
+  public getRulesByDestinationName(destinationName: string): Rule[] {
+    const rules: Rule[] = [...this.globalRules]
+ 
+    const destinationRules = this.rulesByDestination[destinationName]
+    if (destinationRules !== undefined && destinationRules.length > 0) {
+      rules.push(...destinationRules)
+    }
+ 
+    return rules
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/transformers.ts.html b/coverage/lcov-report/transformers.ts.html new file mode 100644 index 0000000..3e3112f --- /dev/null +++ b/coverage/lcov-report/transformers.ts.html @@ -0,0 +1,895 @@ + + + + + + Code coverage report for transformers.ts + + + + + + + + + +
+
+

All files transformers.ts

+
+ +
+ 89.47% + Statements + 102/114 +
+ + +
+ 80% + Branches + 40/50 +
+ + +
+ 87.5% + Functions + 7/8 +
+ + +
+ 88.68% + Lines + 94/106 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +15 +16 +17 +18 +19 +20 +21 +22 +23 +24 +25 +26 +27 +28 +29 +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +51 +52 +53 +54 +55 +56 +57 +58 +59 +60 +61 +62 +63 +64 +65 +66 +67 +68 +69 +70 +71 +72 +73 +74 +75 +76 +77 +78 +79 +80 +81 +82 +83 +84 +85 +86 +87 +88 +89 +90 +91 +92 +93 +94 +95 +96 +97 +98 +99 +100 +101 +102 +103 +104 +105 +106 +107 +108 +109 +110 +111 +112 +113 +114 +115 +116 +117 +118 +119 +120 +121 +122 +123 +124 +125 +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136 +137 +138 +139 +140 +141 +142 +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161 +162 +163 +164 +165 +166 +167 +168 +169 +170 +171 +172 +173 +174 +175 +176 +177 +178 +179 +180 +181 +182 +183 +184 +185 +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212 +213 +214 +215 +216 +217 +218 +219 +220 +221 +222 +223 +224 +225 +226 +227 +228 +229 +230 +231 +232 +233 +234 +235 +236 +237 +238 +239 +240 +241 +242 +243 +244 +245 +246 +247 +248 +249 +250 +251 +252 +253 +254 +255 +256 +257 +258 +259 +260 +261 +262 +263 +264 +265 +266 +267 +268 +269 +270 +271  +2x +2x +2x +2x +2x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +2x +22238x +  +44476x +22238x +  +6x +  +6x +5x +  +5x +4x +  +22202x +4498x +  +17703x +  +18x +18x +  +  +  +  +1x +  +  +  +4525x +  +  +  +  +6x +5x +  +  +  +  +5x +  +  +5x +  +  +  +6x +6x +  +  +  +  +  +  +  +5x +4x +  +  +  +  +4x +  +  +4x +  +  +  +  +  +4x +23x +  +  +  +23x +20x +  +  +  +  +  +  +  +  +  +  +  +  +18x +  +18x +18x +  +  +  +18x +  +  +  +18x +18x +18x +  +  +  +18x +  +  +18x +  +  +  +  +18x +2x +2x +1x +  +16x +2x +2x +1x +  +  +2x +  +  +14x +7x +  +  +  +18x +7x +  +  +7x +  +  +  +3x +  +  +  +4x +3x +  +  +1x +  +  +  +  +  +  +22202x +1100x +21101x +1100x +  +  +  +20001x +  +  +  +  +20001x +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +  +20001x +  +  +20001x +20001x +  +  +20001x +  +  +20001x +  +20001x +20001x +284720x +19900x +  +  +264820x +  +  +20001x +  +20001x +20001x +  +20001x +  +20001x +  +  +20001x +20001x +  +  +  +20001x +  +  +20001x +  +  +  +  +40002x +320016x +320016x +2560128x +269770x +269770x +  +2290358x +  +  +  +  + 
import { Transformer } from './store'
+import MD5 from 'tiny-hashes/md5'
+import get from 'dlv'
+import ldexp from '@stdlib/math-base-special-ldexp'
+import { dset } from 'dset';
+import { unset } from './unset'
+ 
+export interface TransformerConfig {
+  allow?: Record<string, string[]>
+  drop?: Record<string, string[]>
+  sample?: TransformerConfigSample
+  map?: Record<string, TransformerConfigMap>
+}
+ 
+export interface TransformerConfigSample {
+  percent: number
+  path: string
+}
+ 
+export interface TransformerConfigMap {
+  set?: any
+  copy?: string
+  move?: string
+  to_string?: boolean
+}
+ 
+export default function transform(payload: any, transformers: Transformer[]): any {
+  const transformedPayload: any = payload
+ 
+  for (const transformer of transformers) {
+    switch (transformer.type) {
+      case 'drop':
+        return null
+      case 'drop_properties':
+        dropProperties(transformedPayload, transformer.config)
+        break
+      case 'allow_properties':
+        allowProperties(transformedPayload, transformer.config)
+        break
+      case 'sample_event':
+        if (sampleEvent(transformedPayload, transformer.config)) {
+          break
+        }
+        return null
+      case 'map_properties':
+        mapProperties(transformedPayload, transformer.config)
+        break
+      case 'hash_properties':
+        // Not yet supported, but don't throw an error. Just ignore.
+        break
+      default:
+        throw new Error(`Transformer of type "${transformer.type}" is unsupported.`)
+    }
+  }
+ 
+  return transformedPayload
+}
+ 
+// dropProperties removes all specified props from the object.
+function dropProperties(payload: any, config: TransformerConfig) {
+  for (const key in config.drop) {
+    Iif (!config.drop.hasOwnProperty(key)) {
+      continue
+    }
+ 
+    // If key is empty, it refers to the top-level object.
+    const field = key === '' ? payload : get(payload, key)
+ 
+    // Can only drop props off of arrays and objects.
+    Iif (typeof field !== 'object' || field === null) {
+      continue
+    }
+ 
+    for (const target of config.drop[key]) {
+      delete field[target]
+    }
+  }
+}
+ 
+// allowProperties ONLY allows the specific targets within the keys. (e.g. "a.foo": ["bar", "baz"]
+// on {a: {foo: {bar: 1, baz: 2}, other: 3}} will not have any drops, as it only looks inside a.foo
+function allowProperties(payload: any, config: TransformerConfig) {
+  for (const key in config.allow) {
+    Iif (!config.allow.hasOwnProperty(key)) {
+      continue
+    }
+ 
+    // If key is empty, it refers to the top-level object.
+    const field = key === '' ? payload : get(payload, key)
+ 
+    // Can only drop props off of arrays and objects.
+    Iif (typeof field !== 'object' || field === null) {
+      continue
+    }
+ 
+    // Execution order fortunately doesn't really matter (e.g. if someone filtered off of foo.bar, then foo.bar.baz)
+    // except for micro-optimization.
+    for (const k in field) {
+      Iif (!field.hasOwnProperty(k)) {
+        continue
+      }
+ 
+      if (config.allow[key].indexOf(k) === -1) {
+        delete field[k]
+      }
+    }
+  }
+}
+ 
+function mapProperties(payload: any, config: TransformerConfig) {
+  // Some configs might try to modify or read from a field multiple times. We will only ever read
+  // values as they were before any modifications began. Thus, if you try to override e.g.
+  // {a: {b: 1}} with set(a, 'b', 2) (which results in {a: {b: 2}}) and then try to copy a.b into
+  // a.c, you will get {a: {b: 2, c:1}} and NOT {a: {b:2, c:2}}. This prevents map evaluation
+  // order from mattering, and === what server-side does.
+  // See: https://github.com/segmentio/tsub/blob/661695a63b60b90471796e667458f076af788c19/transformers/map_properties.go#L179-L200
+  const initialPayload = JSON.parse(JSON.stringify(payload))
+ 
+  for (const key in config.map) {
+    Iif (!config.map.hasOwnProperty(key)) {
+      continue
+    }
+ 
+    const actionMap: TransformerConfigMap = config.map[key]
+ 
+    // Can't manipulate non-objects. Check that the parent is one. Strip the last .field
+    // from the string.
+    const splitKey = key.split('.')
+    let parent
+    Iif (splitKey.length > 1) {
+      splitKey.pop()
+      parent = get(initialPayload, splitKey.join('.'))
+    } else {
+      parent = payload
+    }
+ 
+    Iif (typeof parent !== 'object') {
+      continue
+    }
+ 
+    // These actions are exclusive to each other.
+    if (actionMap.copy) {
+      const valueToCopy = get(initialPayload, actionMap.copy)
+      if (valueToCopy !== undefined) {
+        dset(payload, key, valueToCopy)
+      }
+    } else if (actionMap.move) {
+      const valueToMove = get(initialPayload, actionMap.move)
+      if (valueToMove !== undefined) {
+        dset(payload, key, valueToMove)
+      }
+ 
+      unset(payload, actionMap.move)
+    }
+    // Have to check only if property exists, as null, undefined, and other vals could be explicitly set.
+    else if (actionMap.hasOwnProperty('set')) {
+      dset(payload, key, actionMap.set)
+    }
+ 
+    // to_string is not exclusive and can be paired with other actions. Final action.
+    if (actionMap.to_string) {
+      const valueToString = get(payload, key)
+ 
+      // Do not string arrays and objects. Do not double-encode strings.
+      if (
+        typeof valueToString === 'string' ||
+        (typeof valueToString === 'object' && valueToString !== null)
+      ) {
+        continue
+      }
+ 
+      // TODO: Check stringifier in Golang for parity.
+      if (valueToString !== undefined) {
+        dset(payload, key, JSON.stringify(valueToString))
+      } else {
+        // TODO: Check this behavior.
+        dset(payload, key, 'undefined')
+      }
+    }
+  }
+}
+ 
+function sampleEvent(payload: any, config: TransformerConfig): boolean {
+  if (config.sample.percent <= 0) {
+    return false
+  } else if (config.sample.percent >= 1) {
+    return true
+  }
+ 
+  // If we're not filtering deterministically, just use raw percentage.
+  Iif (!config.sample.path) {
+    return samplePercent(config.sample.percent)
+  }
+ 
+  // Otherwise, use a deterministic hash.
+  return sampleConsistentPercent(payload, config)
+}
+ 
+function samplePercent(percent: number): boolean {
+  // Math.random returns [0, 1) => 0.0<>0.9999...
+  return Math.random() <= percent
+}
+ 
+// sampleConsistentPercent converts an input string of bytes into a consistent uniform
+// continuous distribution of [0.0, 1.0]. This is based on
+// http://mumble.net/~campbell/tmp/random_real.c, but using the digest
+// result of the input value as the random information.
+ 
+// IMPORTANT - This function needs to === the Golang implementation to ensure that the two return the same vals!
+// See: https://github.com/segmentio/sampler/blob/65cb04132305a04fcd4bcaef67d57fbe40c30241/sampler.go#L13-L38
+ 
+// Since AJS supports IE9+ (typed arrays were introduced in IE10) we're doing some manual array math.
+// This could be done directly with strings, but arrays are easier to reason about/have better function support.
+function sampleConsistentPercent(payload: any, config: TransformerConfig): boolean {
+  const field = get(payload, config.sample.path)
+ 
+  // Operate off of JSON bytes. TODO: Validate all type behavior, esp. strings.
+  const digest: number[] = MD5(JSON.stringify(field))
+  let exponent = -64
+ 
+  // Manually maintain 64-bit int as an array.
+  let significand: number[] = []
+ 
+  // Left-shift and OR for first 8 bytes of digest. (8 bytes * 8 = 64 bits)
+  consumeDigest(digest.slice(0, 8), significand)
+ 
+  let leadingZeros = 0
+  for (let i = 0; i < 64; i++) {
+    if (significand[i] === 1) {
+      break
+    }
+ 
+    leadingZeros++
+  }
+ 
+  if (leadingZeros !== 0) {
+    // Use the last 8 bytes of the digest, same as before.
+    const val: number[] = []
+    consumeDigest(digest.slice(9, 16), val)
+ 
+    exponent -= leadingZeros
+    // Left-shift away leading zeros in significand.
+    significand.splice(0, leadingZeros)
+ 
+    // Right-shift val by 64 minus leading zeros and push into significand.
+    val.splice(64 - leadingZeros)
+    significand = significand.concat(val)
+  }
+ 
+  // Flip 64th bit
+  significand[63] = significand[63] === 0 ? 1 : 0
+ 
+  // Convert our manual binary into a JS num (binary arr => binary string => psuedo-int) and run the ldexp!
+  return ldexp(parseInt(significand.join(''), 2), exponent) < config.sample.percent
+}
+ 
+// Array byte filler helper
+function consumeDigest(digest: number[], arr: number[]) {
+  for (let i = 0; i < 8; i++) {
+    let remainder = digest[i]
+    for (let binary = 128; binary >= 1; binary /= 2) {
+      if (remainder - binary >= 0) {
+        remainder -= binary
+        arr.push(1)
+      } else {
+        arr.push(0)
+      }
+    }
+  }
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov-report/unset.ts.html b/coverage/lcov-report/unset.ts.html new file mode 100644 index 0000000..09f03ab --- /dev/null +++ b/coverage/lcov-report/unset.ts.html @@ -0,0 +1,127 @@ + + + + + + Code coverage report for unset.ts + + + + + + + + + +
+
+

All files unset.ts

+
+ +
+ 81.82% + Statements + 9/11 +
+ + +
+ 66.67% + Branches + 2/3 +
+ + +
+ 100% + Functions + 1/1 +
+ + +
+ 90% + Lines + 9/10 +
+ + +
+

+ Press n or j to go to the next uncovered block, b, p or k for the previous block. +

+ +
+
+

+
1 +2 +3 +4 +5 +6 +7 +8 +9 +10 +11 +12 +13 +14 +152x +  +2x +2x +1x +1x +1x +  +  +1x +1x +  +1x +  + 
import get from 'dlv'
+ 
+export function unset(obj, prop) {
+  if (get(obj, prop)) {
+    var segs = prop.split('.')
+    var last = segs.pop()
+    while (segs.length && segs[segs.length - 1].slice(-1) === '\\') {
+      last = segs.pop().slice(0, -1) + '.' + last
+    }
+    while (segs.length) obj = obj[(prop = segs.shift())]
+    return delete obj[last]
+  }
+  return true
+}
+ 
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/coverage/lcov.info b/coverage/lcov.info new file mode 100644 index 0000000..d414a9f --- /dev/null +++ b/coverage/lcov.info @@ -0,0 +1,582 @@ +TN: +SF:src/index.ts +FN:1,(anonymous_1) +FN:2,(anonymous_2) +FN:2,(anonymous_3) +FN:3,(anonymous_4) +FNF:4 +FNH:3 +FNDA:3,(anonymous_1) +FNDA:5,(anonymous_2) +FNDA:0,(anonymous_3) +FNDA:2,(anonymous_4) +DA:1,4 +DA:2,6 +DA:3,3 +LF:3 +LH:3 +BRF:0 +BRH:0 +end_of_record +TN: +SF:src/matchers.ts +FN:4,matches +FN:8,getMatchFunction +FN:23,all +FN:27,fql +FN:29,(anonymous_5) +FN:40,(anonymous_6) +FN:42,(anonymous_7) +FN:45,generateFQLEval +FN:47,(anonymous_9) +FN:58,(anonymous_10) +FN:60,(anonymous_11) +FN:73,generateEvaluator +FN:76,(anonymous_13) +FN:87,(anonymous_14) +FN:100,(anonymous_15) +FN:119,(anonymous_16) +FN:147,(anonymous_17) +FN:154,(anonymous_18) +FN:159,(anonymous_19) +FN:164,(anonymous_20) +FN:174,(anonymous_21) +FN:179,(anonymous_22) +FN:188,getValue +FN:203,checkInList +FN:204,(anonymous_25) +FN:207,compareNumbersGenerator +FN:216,(anonymous_27) +FN:226,(anonymous_28) +FN:237,(anonymous_29) +FN:241,(anonymous_30) +FN:245,(anonymous_31) +FN:249,(anonymous_32) +FN:255,(anonymous_33) +FN:278,compareItemsGenerator +FN:287,(anonymous_35) +FN:297,(anonymous_36) +FN:311,(anonymous_37) +FN:315,(anonymous_38) +FN:321,(anonymous_39) +FN:345,contains +FN:353,match +FN:361,length +FN:377,isIR +FN:398,isStatic +FN:410,globMatches +FN:460,scanChunk +FN:504,matchChunk +FN:591,getEsc +FNF:48 +FNH:41 +FNDA:113,matches +FNDA:113,getMatchFunction +FNDA:1,all +FNDA:111,fql +FNDA:1,(anonymous_5) +FNDA:108,(anonymous_6) +FNDA:0,(anonymous_7) +FNDA:1,generateFQLEval +FNDA:0,(anonymous_9) +FNDA:10001,(anonymous_10) +FNDA:0,(anonymous_11) +FNDA:140,generateEvaluator +FNDA:21,(anonymous_13) +FNDA:0,(anonymous_14) +FNDA:10004,(anonymous_15) +FNDA:10004,(anonymous_16) +FNDA:9,(anonymous_17) +FNDA:10005,(anonymous_18) +FNDA:10059,(anonymous_19) +FNDA:10003,(anonymous_20) +FNDA:2,(anonymous_21) +FNDA:2,(anonymous_22) +FNDA:80193,getValue +FNDA:9,checkInList +FNDA:14,(anonymous_25) +FNDA:10,compareNumbersGenerator +FNDA:0,(anonymous_27) +FNDA:0,(anonymous_28) +FNDA:3,(anonymous_29) +FNDA:3,(anonymous_30) +FNDA:2,(anonymous_31) +FNDA:2,(anonymous_32) +FNDA:10,(anonymous_33) +FNDA:20,compareItemsGenerator +FNDA:30005,(anonymous_35) +FNDA:0,(anonymous_36) +FNDA:40018,(anonymous_37) +FNDA:2,(anonymous_38) +FNDA:40020,(anonymous_39) +FNDA:10005,contains +FNDA:10059,match +FNDA:2,length +FNDA:12,isIR +FNDA:60,isStatic +FNDA:10059,globMatches +FNDA:20094,scanChunk +FNDA:10162,matchChunk +FNDA:51,getEsc +DA:2,2 +DA:4,2 +DA:5,113 +DA:8,2 +DA:9,113 +DA:10,0 +DA:13,113 +DA:15,1 +DA:17,111 +DA:19,1 +DA:24,1 +DA:28,111 +DA:29,1 +DA:32,110 +DA:33,110 +DA:35,1 +DA:38,109 +DA:39,108 +DA:40,108 +DA:42,0 +DA:45,2 +DA:46,1 +DA:47,0 +DA:50,1 +DA:51,1 +DA:53,0 +DA:56,1 +DA:57,1 +DA:58,10001 +DA:60,0 +DA:75,140 +DA:76,21 +DA:79,119 +DA:81,119 +DA:85,0 +DA:86,0 +DA:87,0 +DA:88,0 +DA:91,0 +DA:96,4 +DA:97,4 +DA:98,10 +DA:100,4 +DA:101,20010 +DA:102,20010 +DA:103,20010 +DA:104,10003 +DA:107,0 +DA:110,1 +DA:115,4 +DA:116,4 +DA:117,13 +DA:119,4 +DA:120,50013 +DA:121,50013 +DA:122,50013 +DA:123,1 +DA:126,0 +DA:127,0 +DA:131,10003 +DA:137,20 +DA:144,10 +DA:147,9 +DA:148,9 +DA:154,5 +DA:155,10005 +DA:159,59 +DA:160,10059 +DA:164,3 +DA:165,10003 +DA:166,10003 +DA:167,0 +DA:169,10003 +DA:174,2 +DA:175,2 +DA:179,2 +DA:180,2 +DA:184,1 +DA:190,80193 +DA:191,0 +DA:195,80193 +DA:196,20174 +DA:200,60019 +DA:204,14 +DA:212,10 +DA:213,0 +DA:214,0 +DA:216,0 +DA:219,10 +DA:222,10 +DA:223,0 +DA:224,0 +DA:226,0 +DA:229,10 +DA:234,10 +DA:237,3 +DA:238,3 +DA:241,3 +DA:242,3 +DA:245,2 +DA:246,2 +DA:249,2 +DA:250,2 +DA:252,0 +DA:255,10 +DA:258,10 +DA:259,0 +DA:261,10 +DA:264,10 +DA:265,0 +DA:267,10 +DA:270,10 +DA:271,0 +DA:274,10 +DA:283,20 +DA:284,6 +DA:285,1 +DA:287,30005 +DA:290,14 +DA:293,20 +DA:294,6 +DA:295,6 +DA:297,0 +DA:300,14 +DA:308,20 +DA:311,40018 +DA:312,18 +DA:315,2 +DA:316,2 +DA:318,0 +DA:321,20 +DA:324,40020 +DA:325,40006 +DA:327,14 +DA:330,40020 +DA:331,6 +DA:333,40014 +DA:336,40020 +DA:337,4 +DA:338,4 +DA:341,40020 +DA:346,10005 +DA:347,0 +DA:350,10005 +DA:354,10059 +DA:355,0 +DA:358,10059 +DA:363,2 +DA:364,0 +DA:368,2 +DA:369,0 +DA:372,2 +DA:379,12 +DA:380,5 +DA:384,7 +DA:388,7 +DA:391,0 +DA:392,0 +DA:395,0 +DA:399,60 +DA:400,12 +DA:403,48 +DA:411,10059 +DA:412,20094 +DA:413,20094 +DA:414,20094 +DA:415,20094 +DA:417,10007 +DA:421,10087 +DA:422,10087 +DA:423,1 +DA:429,10086 +DA:430,10033 +DA:431,10033 +DA:434,53 +DA:436,31 +DA:437,75 +DA:438,75 +DA:440,30 +DA:441,3 +DA:444,27 +DA:445,27 +DA:448,45 +DA:449,0 +DA:454,26 +DA:457,25 +DA:461,20094 +DA:467,20094 +DA:468,10042 +DA:469,10042 +DA:472,20094 +DA:475,20094 +DA:476,40272 +DA:479,12 +DA:480,11 +DA:482,12 +DA:484,34 +DA:485,34 +DA:487,30 +DA:488,30 +DA:490,10035 +DA:491,10035 +DA:496,20094 +DA:497,20094 +DA:498,20094 +DA:505,10162 +DA:511,10162 +DA:512,30228 +DA:513,7 +DA:516,30221 +DA:518,32 +DA:519,32 +DA:520,32 +DA:522,32 +DA:523,32 +DA:524,8 +DA:525,8 +DA:529,32 +DA:530,32 +DA:531,32 +DA:532,60 +DA:533,19 +DA:534,19 +DA:537,41 +DA:538,41 +DA:539,41 +DA:540,41 +DA:541,41 +DA:542,10 +DA:545,31 +DA:546,31 +DA:547,10 +DA:548,10 +DA:549,3 +DA:553,28 +DA:554,12 +DA:557,28 +DA:560,19 +DA:561,6 +DA:563,13 +DA:565,14 +DA:566,14 +DA:567,14 +DA:569,4 +DA:570,4 +DA:571,1 +DA:572,1 +DA:576,30174 +DA:577,71 +DA:579,30103 +DA:580,30103 +DA:584,10064 +DA:585,10064 +DA:586,10064 +DA:587,10064 +DA:592,51 +DA:598,51 +DA:599,12 +DA:600,12 +DA:603,39 +DA:604,8 +DA:605,8 +DA:606,0 +DA:607,0 +DA:613,39 +DA:614,39 +DA:615,39 +DA:616,1 +DA:619,39 +LF:269 +LH:232 +BRDA:9,0,0,0 +BRDA:14,1,0,1 +BRDA:14,1,1,111 +BRDA:14,1,2,1 +BRDA:28,2,0,1 +BRDA:39,3,0,108 +BRDA:46,4,0,0 +BRDA:57,5,0,1 +BRDA:75,6,0,21 +BRDA:84,7,0,0 +BRDA:84,7,1,4 +BRDA:84,7,2,4 +BRDA:84,7,3,18 +BRDA:84,7,4,20 +BRDA:84,7,5,3 +BRDA:84,7,6,5 +BRDA:84,7,7,7 +BRDA:84,7,8,10 +BRDA:84,7,9,9 +BRDA:84,7,10,5 +BRDA:84,7,11,59 +BRDA:84,7,12,3 +BRDA:84,7,13,2 +BRDA:84,7,14,2 +BRDA:84,7,15,1 +BRDA:86,8,0,0 +BRDA:86,8,1,0 +BRDA:102,9,0,20010 +BRDA:102,9,1,0 +BRDA:103,10,0,10003 +BRDA:107,11,0,0 +BRDA:121,12,0,50013 +BRDA:121,12,1,0 +BRDA:122,13,0,1 +BRDA:126,14,0,0 +BRDA:166,15,0,0 +BRDA:190,16,0,0 +BRDA:195,17,0,20174 +BRDA:212,18,0,0 +BRDA:212,18,1,10 +BRDA:213,19,0,0 +BRDA:213,19,1,0 +BRDA:222,20,0,0 +BRDA:222,20,1,10 +BRDA:223,21,0,0 +BRDA:223,21,1,0 +BRDA:236,22,0,3 +BRDA:236,22,1,3 +BRDA:236,22,2,2 +BRDA:236,22,3,2 +BRDA:236,22,4,0 +BRDA:258,23,0,0 +BRDA:258,23,1,10 +BRDA:264,24,0,0 +BRDA:264,24,1,10 +BRDA:270,25,0,0 +BRDA:270,26,0,10 +BRDA:270,26,1,10 +BRDA:283,27,0,6 +BRDA:283,27,1,14 +BRDA:284,28,0,1 +BRDA:284,28,1,5 +BRDA:293,29,0,6 +BRDA:293,29,1,14 +BRDA:294,30,0,6 +BRDA:294,30,1,0 +BRDA:310,31,0,18 +BRDA:310,31,1,2 +BRDA:310,31,2,0 +BRDA:324,32,0,40006 +BRDA:324,32,1,14 +BRDA:330,33,0,6 +BRDA:330,33,1,40014 +BRDA:336,34,0,4 +BRDA:336,35,0,40020 +BRDA:336,35,1,4 +BRDA:346,36,0,0 +BRDA:346,37,0,10005 +BRDA:346,37,1,10005 +BRDA:354,38,0,0 +BRDA:354,39,0,10059 +BRDA:354,39,1,10059 +BRDA:363,40,0,0 +BRDA:368,41,0,0 +BRDA:368,42,0,2 +BRDA:368,42,1,2 +BRDA:379,43,0,5 +BRDA:384,44,0,7 +BRDA:385,45,0,7 +BRDA:385,45,1,4 +BRDA:385,45,2,2 +BRDA:385,45,3,7 +BRDA:391,46,0,0 +BRDA:391,47,0,0 +BRDA:391,47,1,0 +BRDA:391,47,2,0 +BRDA:399,48,0,12 +BRDA:399,49,0,60 +BRDA:399,49,1,53 +BRDA:415,50,0,10007 +BRDA:415,51,0,20094 +BRDA:415,51,1,10042 +BRDA:422,52,0,1 +BRDA:429,53,0,10033 +BRDA:429,54,0,10086 +BRDA:429,54,1,10034 +BRDA:429,54,2,10016 +BRDA:434,55,0,31 +BRDA:438,56,0,30 +BRDA:440,57,0,3 +BRDA:440,58,0,30 +BRDA:440,58,1,12 +BRDA:448,59,0,0 +BRDA:467,60,0,30136 +BRDA:467,60,1,20129 +BRDA:477,61,0,12 +BRDA:477,61,1,34 +BRDA:477,61,2,30 +BRDA:477,61,3,10035 +BRDA:479,62,0,11 +BRDA:490,63,0,10035 +BRDA:512,64,0,7 +BRDA:517,65,0,32 +BRDA:517,65,1,14 +BRDA:517,65,2,4 +BRDA:517,65,3,30174 +BRDA:523,66,0,8 +BRDA:523,67,0,32 +BRDA:523,67,1,30 +BRDA:532,68,0,19 +BRDA:532,69,0,60 +BRDA:532,69,1,57 +BRDA:532,69,2,20 +BRDA:541,70,0,10 +BRDA:546,71,0,10 +BRDA:548,72,0,3 +BRDA:553,73,0,12 +BRDA:553,74,0,28 +BRDA:553,74,1,20 +BRDA:560,75,0,6 +BRDA:570,76,0,1 +BRDA:576,77,0,71 +BRDA:598,78,0,12 +BRDA:598,79,0,51 +BRDA:598,79,1,48 +BRDA:598,79,2,43 +BRDA:603,80,0,8 +BRDA:605,81,0,0 +BRDA:615,82,0,1 +BRF:149 +BRH:116 +end_of_record +TN: +SF:src/store.ts +FN:21,(anonymous_1) +FN:25,Store +FN:41,(anonymous_3) +FNF:3 +FNH:3 +FNDA:1,(anonymous_1) +FNDA:2,Store +FNDA:3,(anonymous_3) +DA:21,1 +DA:22,2 +DA:23,2 +DA:25,2 +DA:27,4 +DA:29,2 +DA:30,1 +DA:31,1 +DA:34,1 +DA:36,1 +DA:41,1 +DA:42,3 +DA:44,3 +DA:45,3 +DA:46,1 +DA:49,3 +DA:51,1 +LF:17 +LH:17 +BRDA:25,0,0,0 +BRDA:29,1,0,1 +BRDA:29,1,1,1 +BRDA:30,2,0,1 +BRDA:45,3,0,1 +BRDA:45,4,0,3 +BRDA:45,4,1,1 +BRF:7 +BRH:6 +end_of_record diff --git a/src/__tests__/matchers.test.ts b/src/__tests__/matchers.test.ts index be6f928..4161f46 100644 --- a/src/__tests__/matchers.test.ts +++ b/src/__tests__/matchers.test.ts @@ -1,4 +1,4 @@ -import matches from '../matchers' +import matches, { generateFQLEval } from '../matchers' import * as Store from '../store' import * as simple from '../../fixtures/simple.json' @@ -18,7 +18,7 @@ beforeEach(() => { describe('error handling and basic checks', () => { test('throws on a bad IR', () => { - ; (matcher.ir = 'Invalid//**[]""""json'), + ;(matcher.ir = 'Invalid//**[]""""json'), expect(() => { matches({}, matcher) }).toThrow() @@ -373,3 +373,37 @@ const matcherTests = [ ['a[', 'ab', false], ['*x', 'xxx', true], ] + +describe('performance', () => { + test('throws on a bad IR', () => { + performance.mark('Start') + // Initial request + matcher.ir = ` + ["and", + ["=", "context.library.name", {"value": "analytics.js"}], + ["contains", "context.page.path", {"value": "academy"}], + ["or", + ["=", "event", { "value": "Course Not Clicked" }], + ["=", "event", { "value": "Course Clicked" }] + ], + ["=", ["lowercase", "event"], { "value": "course clicked" }], + ["match", "context.ip", { "value": "108*" }] + ] + ` + + const evaluator = generateFQLEval(matcher.ir) + expect(evaluator(manyPropertiesEvent)).toBe(true) + + performance.measure('First', 'Start') + performance.mark('First') + + for (let index = 0; index < 10000; index++) { + manyPropertiesEvent.messageId = index + expect(evaluator(manyPropertiesEvent)).toBe(true) + } + + performance.measure('10000x runs', 'First') + + console.log(performance.getEntries()) + }) +}) diff --git a/src/index.ts b/src/index.ts index ba0b793..a8b1d25 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,3 @@ export { default as transform } from './transformers' -export { default as matches } from './matchers' +export { default as matches, getMatchFunction } from './matchers' export { default as Store } from './store' diff --git a/src/matchers.ts b/src/matchers.ts index 618ce61..45a6109 100644 --- a/src/matchers.ts +++ b/src/matchers.ts @@ -1,16 +1,20 @@ import * as Store from './store' import get from 'dlv' -export default function matches(event, matcher: Store.Matcher): boolean { +export default function matches(event: unknown, matcher: Store.Matcher): boolean { + return getMatchFunction(matcher)(event) +} + +export function getMatchFunction(matcher: Store.Matcher): (event: unknown) => boolean { if (!matcher) { throw new Error('No matcher supplied!') } switch (matcher.type) { case 'all': - return all() + return all case 'fql': - return fql(matcher.ir, event) + return fql(matcher.ir) default: throw new Error(`Matcher of type ${matcher.type} unsupported.`) } @@ -20,9 +24,9 @@ function all(): boolean { return true } -function fql(ir: Store.Matcher['ir'], event): boolean { +function fql(ir: Store.Matcher['ir']): (event: unknown) => boolean { if (!ir) { - return false + return () => false } try { @@ -31,83 +35,150 @@ function fql(ir: Store.Matcher['ir'], event): boolean { throw new Error(`Failed to JSON.parse FQL intermediate representation "${ir}": ${e}`) } - const result = fqlEvaluate(ir, event) - if (typeof result !== 'boolean') { - // An error was returned, or a lowercase, typeof, or similar function was run alone. Nothing to evaluate. - return false + const evaluator = generateEvaluator(ir) + if (typeof evaluator === 'function') { + return (event) => !!evaluator(event) + } + return () => !!evaluator +} + +export function generateFQLEval(ir: Store.Matcher['ir']): (event: unknown) => boolean { + if (!ir) { + return () => false } - return result + try { + ir = JSON.parse(ir) + } catch (e) { + throw new Error(`Failed to JSON.parse FQL intermediate representation "${ir}": ${e}`) + } + + const evaluator = generateEvaluator(ir) + if (typeof evaluator === 'function') { + return (event) => !!evaluator(event) + } + return () => !!evaluator } -// FQL is 100% type strict in Go. Show no mercy to types which do not comply. -function fqlEvaluate(ir, event) { +type FQLEvaluator = + | ((event: any) => boolean) + | ((event: any) => string) + | ((event: any) => number) + | string + | number + | boolean + | Array + +// Creates a function for evaluating a given FQL +function generateEvaluator(ir: string | string[]): FQLEvaluator { // If the given ir chunk is not an array, then we should check the single given path or value for literally `true`. if (!Array.isArray(ir)) { - return getValue(ir, event) === true + return (event: any) => getValue(ir, event) === true } - // Otherwise, it is a sequence of ordered steps to follow to reach our solution! const item = ir[0] + switch (item) { /*** Unary cases ***/ // '!' => Invert the result case '!': - return !fqlEvaluate(ir[1], event) - + const op = generateEvaluator(ir[1]) + if (typeof op === 'function') { + return (event: any) => { + return !op(event) + } + } else { + return !op + } /*** Binary cases ***/ // 'or' => Any condition being true returns true case 'or': + const orOps: FQLEvaluator[] = [] for (let i = 1; i < ir.length; i++) { - if (fqlEvaluate(ir[i], event)) { - return true + orOps.push(generateEvaluator(ir[i])) + } + return (event: any) => { + for (const op of orOps) { + if (typeof op === 'function') { + if (op(event)) { + return true + } + } else { + if (op) return true + } } + return false } - return false + // 'and' => Any condition being false returns false case 'and': + const andOps: FQLEvaluator[] = [] for (let i = 1; i < ir.length; i++) { - if (!fqlEvaluate(ir[i], event)) { - return false + andOps.push(generateEvaluator(ir[i])) + } + return (event: any) => { + for (const op of andOps) { + if (typeof op === 'function') { + if (!op(event)) { + return false + } + } else { + if (!op) { + return false + } + } } + return true } - return true + // Equivalence comparisons case '=': case '!=': - return compareItems(getValue(ir[1], event), getValue(ir[2], event), item, event) + return compareItemsGenerator(ir[1], ir[2], item) // Numerical comparisons case '<=': case '<': case '>': case '>=': // Compare the two values with the given operator. - return compareNumbers(getValue(ir[1], event), getValue(ir[2], event), item, event) + return compareNumbersGenerator(ir[1], ir[2], item) // item in [list]' => Checks whether item is in list case 'in': - return checkInList(getValue(ir[1], event), getValue(ir[2], event), event) + return (event) => { + return checkInList(getValue(ir[1], event), getValue(ir[2], event), event) + } /*** Functions ***/ // 'contains(str1, str2)' => The first string has a substring of the second string case 'contains': - return contains(getValue(ir[1], event), getValue(ir[2], event)) + return (event) => { + return contains(getValue(ir[1], event), getValue(ir[2], event)) + } // 'match(str, match)' => The given string matches the provided glob matcher case 'match': - return match(getValue(ir[1], event), getValue(ir[2], event)) + return (event) => { + return match(getValue(ir[1], event), getValue(ir[2], event)) + } // 'lowercase(str)' => Returns a lowercased string, null if the item is not a string case 'lowercase': - const target = getValue(ir[1], event) - if (typeof target !== 'string') { - return null + return (event) => { + const target = getValue(ir[1], event) + if (typeof target !== 'string') { + return null + } + return target.toLowerCase() } - return target.toLowerCase() // 'typeof(val)' => Returns the FQL type of the value case 'typeof': // TODO: Do we need mapping to allow for universal comparisons? e.g. Object -> JSON, Array -> List, Floats? - return typeof getValue(ir[1], event) + return (event) => { + return typeof getValue(ir[1], event) + } // 'length(val)' => Returns the length of an array or string, NaN if neither case 'length': - return length(getValue(ir[1], event)) + return (event) => { + return length(getValue(ir[1], event)) + } // If nothing hit, we or the IR messed up somewhere. default: throw new Error(`FQL IR could not evaluate for token: ${item}`) @@ -130,71 +201,145 @@ function getValue(item, event) { } function checkInList(item, list, event): boolean { - return list.find(it => getValue(it, event) === item) !== undefined + return list.find((it) => getValue(it, event) === item) !== undefined } -function compareNumbers(first, second, operator, event): boolean { +function compareNumbersGenerator(first, second, operator): (event) => boolean { // Check if it's more IR (such as a length() function) - if (isIR(first)) { - first = fqlEvaluate(first, event) - } - - if (isIR(second)) { - second = fqlEvaluate(second, event) + let firstEval: FQLEvaluator + let secondEval: FQLEvaluator + + if (!isStatic(first)) { + if (isIR(first)) { + firstEval = generateEvaluator(first) + } else { + firstEval = (event) => getValue(first, event) + } + } else { + firstEval = first.value } - if (typeof first !== 'number' || typeof second !== 'number') { - return false + if (!isStatic(second)) { + if (isIR(second)) { + secondEval = generateEvaluator(second) + } else { + secondEval = (event) => getValue(second, event) + } + } else { + secondEval = second.value } // Reminder: NaN is not comparable to any other number (including NaN) and will always return false as desired. + let op: (a: number, b: number) => boolean switch (operator) { // '<=' => The first number is less than or equal to the second. case '<=': - return first <= second + op = (a, b) => a <= b + break // '>=' => The first number is greater than or equal to the second case '>=': - return first >= second + op = (a, b) => a >= b + break // '<' The first number is less than the second. case '<': - return first < second + op = (a, b) => a < b + break // '>' The first number is greater than the second. case '>': - return first > second + op = (a, b) => a > b + break default: throw new Error(`Invalid operator in compareNumbers: ${operator}`) } -} -function compareItems(first, second, operator, event): boolean { - // Check if it's more IR (such as a lowercase() function) - if (isIR(first)) { - first = fqlEvaluate(first, event) + return (event) => { + let a, b + + if (typeof firstEval === 'function') { + a = firstEval(event) + } else { + a = firstEval + } + + if (typeof secondEval === 'function') { + b = secondEval(event) + } else { + b = secondEval + } + + if (typeof a !== 'number' || typeof b !== 'number') { + return false + } + + return op(a, b) } +} + +function compareItemsGenerator(first, second, operator): FQLEvaluator { + let firstEval: FQLEvaluator + let secondEval: FQLEvaluator - if (isIR(second)) { - second = fqlEvaluate(second, event) + // Check if it's more IR (such as a lowercase() function) + if (!isStatic(first)) { + if (isIR(first)) { + firstEval = generateEvaluator(first) + } else { + firstEval = (event) => getValue(first, event) + } + } else { + firstEval = first.value } - if (typeof first === 'object' && typeof second === 'object') { - first = JSON.stringify(first) - second = JSON.stringify(second) + if (!isStatic(second)) { + if (isIR(second)) { + secondEval = generateEvaluator(second) + } else { + secondEval = (event) => getValue(second, event) + } + } else { + secondEval = second.value } // Objects with the exact same contents AND order ARE considered identical. (Don't compare by reference) // Even in Go, this MUST be the same byte order. // e.g. {a: 1, b:2} === {a: 1, b:2} BUT {a:1, b:2} !== {b:2, a:1} // Maybe later we'll use a stable stringifier, but we're matching server-side behavior for now. + let compareOp: (a: unknown, b: unknown) => boolean switch (operator) { // '=' => The two following items are exactly identical case '=': - return first === second + compareOp = (a, b) => a === b + break // '!=' => The two following items are NOT exactly identical. case '!=': - return first !== second + compareOp = (a, b) => a !== b + break default: throw new Error(`Invalid operator in compareItems: ${operator}`) } + + return (event) => { + let a, b + + if (typeof firstEval === 'function') { + a = firstEval(event) + } else { + a = firstEval + } + + if (typeof secondEval === 'function') { + b = secondEval(event) + } else { + b = secondEval + } + + if (typeof a === 'object' && typeof b === 'object') { + a = JSON.stringify(a) + b = JSON.stringify(b) + } + + return compareOp(a, b) + } } function contains(first, second): boolean { @@ -250,6 +395,14 @@ function isIR(value): boolean { return false } +function isStatic(ir: Store.Matcher | string): boolean { + if (Array.isArray(ir) || typeof ir !== 'object') { + return false + } + + return true +} + // Any reputable glob matcher is designed to work on filesystems and doesn't allow the override of the separator // character "/". This is problematic since our server-side representation e.g. evaluates "match('ab/c', 'a*)" // as TRUE, whereas any glob matcher for JS available does false. So we're rewriting it here. diff --git a/src/store.ts b/src/store.ts index 99885ae..b16a0db 100644 --- a/src/store.ts +++ b/src/store.ts @@ -19,19 +19,31 @@ export interface Transformer { } export default class Store { - private readonly rules = [] + private readonly rulesByDestination: { [key: string]: Rule[] } = {} + private readonly globalRules: Rule[] = [] - constructor(rules?: Rule[]) { - this.rules = rules || [] + constructor(rules: Rule[] = []) { + // Initialize the maps + for (const rule of rules) { + // Rules with no destinationName are global (workspace || workspace::source) + if (rule.destinationName !== undefined) { + if (this.rulesByDestination[rule.destinationName] === undefined) { + this.rulesByDestination[rule.destinationName] = [] + } + + this.rulesByDestination[rule.destinationName].push(rule) + } else { + this.globalRules.push(rule) + } + } } public getRulesByDestinationName(destinationName: string): Rule[] { - const rules: Rule[] = [] - for (const rule of this.rules) { - // Rules with no destinationName are global (workspace || workspace::source) - if (rule.destinationName === destinationName || rule.destinationName === undefined) { - rules.push(rule) - } + const rules: Rule[] = [...this.globalRules] + + const destinationRules = this.rulesByDestination[destinationName] + if (destinationRules !== undefined && destinationRules.length > 0) { + rules.push(...destinationRules) } return rules diff --git a/src/test.json b/src/test.json new file mode 100644 index 0000000..930b222 --- /dev/null +++ b/src/test.json @@ -0,0 +1,10 @@ +{ + "traces": [ + { + "p": "IDFAPlugin", + "e": 500, + "t": 1665074180, + "v": 011 + } + ] +}