Comparing version 2.2.6 to 2.3.0
# Awilix Changelog | ||
## 2.3.0 | ||
* **[NEW]**: Classic dependency resolution mode using parameter name matching implemented, thanks to [@cjhoward92](https://github.com/jeffijoe/awilix/pull/21)! This is an alternative to the default proxy mechanism. | ||
* **[BREAKING]**: The `registerX({ name: [value, options]})` pattern is not needed for `registerValue` because it is so simple is requires no configuration. It was causing trouble when attempting to register an array as a value, because the `register` function would think it was the value-options-array pattern when it shouldn't be. **This change is breaking in the sense that it solves the unexpected behavior, but it breaks existing registrations that would register arrays by using `registerValue({ name: [[1, 2]] })` (multi-dimensional array to work around the pre-2.3.0 behavior)** | ||
* [chore]: Updated packages. | ||
## 2.2.6 | ||
* Pass in the module descriptor to `formatName` - thanks @anasinnyk! | ||
* Fixed some issues with TypeScript definitions. | ||
@@ -7,0 +14,0 @@ ## 2.2.5 |
@@ -1,1 +0,1 @@ | ||
{"/Users/jeff/Projects/awilix/lib/awilix.js":{"path":"/Users/jeff/Projects/awilix/lib/awilix.js","s":{"1":1,"2":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":2,"column":0},"end":{"line":7,"column":1}},"2":{"start":{"line":10,"column":0},"end":{"line":10,"column":57}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/createContainer.js":{"path":"/Users/jeff/Projects/awilix/lib/createContainer.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":59,"11":59,"12":59,"13":59,"14":59,"15":63,"16":2,"17":59,"18":59,"19":59,"20":59,"21":8,"22":59,"23":61,"24":1,"25":59,"26":59,"27":120,"28":59,"29":17,"30":59,"31":59,"32":72,"33":72,"34":76,"35":76,"36":72,"37":59,"38":59,"39":177,"40":24,"41":24,"42":36,"43":36,"44":36,"45":5,"46":5,"47":36,"48":24,"49":59,"50":59,"51":59,"52":59,"53":85,"54":57,"55":85,"56":85,"57":85,"58":85,"59":1,"60":84,"61":5,"62":79,"63":79,"64":79,"65":47,"66":33,"67":6,"68":6,"69":2,"70":2,"71":4,"72":6,"73":25,"74":38,"75":38,"76":14,"77":14,"78":25,"79":11,"80":11,"81":25,"82":1,"83":64,"84":64,"85":21,"86":21,"87":85,"88":71,"89":59,"90":59,"91":3,"92":3,"93":59,"94":59},"b":{"1":[1,1],"2":[17,42],"3":[59,59],"4":[120,37],"5":[5,31],"6":[57,28],"7":[1,84],"8":[5,79],"9":[47,6,25,1],"10":[2,4],"11":[14,24],"12":[11,14],"13":[71,14]},"f":{"1":59,"2":63,"3":8},"fnMap":{"1":{"name":"createContainer","line":24,"loc":{"start":{"line":24,"column":17},"end":{"line":24,"column":71}}},"2":{"name":"(anonymous_2)","line":47,"loc":{"start":{"line":47,"column":22},"end":{"line":47,"column":25}}},"3":{"name":"(anonymous_3)","line":81,"loc":{"start":{"line":81,"column":32},"end":{"line":81,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":44}},"3":{"start":{"line":3,"column":0},"end":{"line":3,"column":67}},"4":{"start":{"line":4,"column":0},"end":{"line":4,"column":64}},"5":{"start":{"line":5,"column":0},"end":{"line":5,"column":56}},"6":{"start":{"line":6,"column":0},"end":{"line":6,"column":38}},"7":{"start":{"line":7,"column":0},"end":{"line":7,"column":30}},"8":{"start":{"line":13,"column":0},"end":{"line":13,"column":40}},"9":{"start":{"line":24,"column":0},"end":{"line":348,"column":1}},"10":{"start":{"line":25,"column":2},"end":{"line":25,"column":38}},"11":{"start":{"line":31,"column":2},"end":{"line":31,"column":26}},"12":{"start":{"line":35,"column":2},"end":{"line":35,"column":32}},"13":{"start":{"line":38,"column":2},"end":{"line":38,"column":26}},"14":{"start":{"line":41,"column":2},"end":{"line":57,"column":3}},"15":{"start":{"line":48,"column":6},"end":{"line":48,"column":34}},"16":{"start":{"line":55,"column":6},"end":{"line":55,"column":134}},"17":{"start":{"line":60,"column":2},"end":{"line":62,"column":17}},"18":{"start":{"line":70,"column":2},"end":{"line":70,"column":37}},"19":{"start":{"line":77,"column":2},"end":{"line":77,"column":22}},"20":{"start":{"line":80,"column":2},"end":{"line":84,"column":3}},"21":{"start":{"line":81,"column":49},"end":{"line":81,"column":69}},"22":{"start":{"line":91,"column":2},"end":{"line":115,"column":4}},"23":{"start":{"line":104,"column":27},"end":{"line":104,"column":40}},"24":{"start":{"line":113,"column":6},"end":{"line":113,"column":104}},"25":{"start":{"line":117,"column":2},"end":{"line":117,"column":27}},"26":{"start":{"line":125,"column":2},"end":{"line":131,"column":3}},"27":{"start":{"line":126,"column":4},"end":{"line":130,"column":5}},"28":{"start":{"line":139,"column":2},"end":{"line":141,"column":3}},"29":{"start":{"line":140,"column":4},"end":{"line":140,"column":46}},"30":{"start":{"line":143,"column":2},"end":{"line":143,"column":37}},"31":{"start":{"line":154,"column":2},"end":{"line":162,"column":3}},"32":{"start":{"line":155,"column":4},"end":{"line":155,"column":53}},"33":{"start":{"line":156,"column":4},"end":{"line":159,"column":5}},"34":{"start":{"line":157,"column":6},"end":{"line":157,"column":28}},"35":{"start":{"line":158,"column":6},"end":{"line":158,"column":32}},"36":{"start":{"line":161,"column":4},"end":{"line":161,"column":20}},"37":{"start":{"line":164,"column":2},"end":{"line":164,"column":31}},"38":{"start":{"line":169,"column":2},"end":{"line":189,"column":3}},"39":{"start":{"line":169,"column":31},"end":{"line":189,"column":3}},"40":{"start":{"line":171,"column":4},"end":{"line":171,"column":46}},"41":{"start":{"line":173,"column":4},"end":{"line":185,"column":5}},"42":{"start":{"line":174,"column":6},"end":{"line":174,"column":36}},"43":{"start":{"line":177,"column":6},"end":{"line":177,"column":36}},"44":{"start":{"line":178,"column":6},"end":{"line":182,"column":7}},"45":{"start":{"line":180,"column":8},"end":{"line":180,"column":58}},"46":{"start":{"line":181,"column":8},"end":{"line":181,"column":44}},"47":{"start":{"line":184,"column":6},"end":{"line":184,"column":46}},"48":{"start":{"line":188,"column":4},"end":{"line":188,"column":20}},"49":{"start":{"line":203,"column":2},"end":{"line":203,"column":55}},"50":{"start":{"line":217,"column":2},"end":{"line":217,"column":49}},"51":{"start":{"line":231,"column":2},"end":{"line":231,"column":49}},"52":{"start":{"line":242,"column":2},"end":{"line":321,"column":3}},"53":{"start":{"line":243,"column":4},"end":{"line":245,"column":5}},"54":{"start":{"line":244,"column":6},"end":{"line":244,"column":49}},"55":{"start":{"line":249,"column":4},"end":{"line":249,"column":33}},"56":{"start":{"line":251,"column":4},"end":{"line":320,"column":5}},"57":{"start":{"line":253,"column":6},"end":{"line":253,"column":52}},"58":{"start":{"line":254,"column":6},"end":{"line":256,"column":7}},"59":{"start":{"line":255,"column":8},"end":{"line":255,"column":95}},"60":{"start":{"line":258,"column":6},"end":{"line":260,"column":7}},"61":{"start":{"line":259,"column":8},"end":{"line":259,"column":62}},"62":{"start":{"line":263,"column":6},"end":{"line":263,"column":32}},"63":{"start":{"line":266,"column":6},"end":{"line":266,"column":26}},"64":{"start":{"line":267,"column":6},"end":{"line":306,"column":7}},"65":{"start":{"line":270,"column":10},"end":{"line":270,"column":52}},"66":{"start":{"line":271,"column":10},"end":{"line":271,"column":15}},"67":{"start":{"line":274,"column":10},"end":{"line":274,"column":35}},"68":{"start":{"line":275,"column":10},"end":{"line":280,"column":11}},"69":{"start":{"line":276,"column":12},"end":{"line":276,"column":54}},"70":{"start":{"line":277,"column":12},"end":{"line":277,"column":39}},"71":{"start":{"line":279,"column":12},"end":{"line":279,"column":29}},"72":{"start":{"line":281,"column":10},"end":{"line":281,"column":15}},"73":{"start":{"line":289,"column":10},"end":{"line":296,"column":11}},"74":{"start":{"line":290,"column":12},"end":{"line":290,"column":34}},"75":{"start":{"line":291,"column":12},"end":{"line":295,"column":13}},"76":{"start":{"line":293,"column":14},"end":{"line":293,"column":31}},"77":{"start":{"line":294,"column":14},"end":{"line":294,"column":19}},"78":{"start":{"line":299,"column":10},"end":{"line":302,"column":11}},"79":{"start":{"line":300,"column":12},"end":{"line":300,"column":54}},"80":{"start":{"line":301,"column":12},"end":{"line":301,"column":44}},"81":{"start":{"line":303,"column":10},"end":{"line":303,"column":15}},"82":{"start":{"line":305,"column":10},"end":{"line":305,"column":111}},"83":{"start":{"line":308,"column":6},"end":{"line":308,"column":27}},"84":{"start":{"line":309,"column":6},"end":{"line":309,"column":21}},"85":{"start":{"line":312,"column":6},"end":{"line":312,"column":26}},"86":{"start":{"line":313,"column":6},"end":{"line":313,"column":15}},"87":{"start":{"line":317,"column":6},"end":{"line":319,"column":7}},"88":{"start":{"line":318,"column":8},"end":{"line":318,"column":34}},"89":{"start":{"line":323,"column":2},"end":{"line":323,"column":29}},"90":{"start":{"line":334,"column":2},"end":{"line":337,"column":3}},"91":{"start":{"line":335,"column":4},"end":{"line":335,"column":53}},"92":{"start":{"line":336,"column":4},"end":{"line":336,"column":20}},"93":{"start":{"line":344,"column":2},"end":{"line":344,"column":37}},"94":{"start":{"line":347,"column":2},"end":{"line":347,"column":18}}},"branchMap":{"1":{"line":55,"type":"cond-expr","locations":[{"start":{"line":55,"column":54},"end":{"line":55,"column":64}},{"start":{"line":55,"column":67},"end":{"line":55,"column":69}}]},"2":{"line":60,"type":"cond-expr","locations":[{"start":{"line":61,"column":6},"end":{"line":61,"column":56}},{"start":{"line":62,"column":6},"end":{"line":62,"column":17}}]},"3":{"line":81,"type":"binary-expr","locations":[{"start":{"line":81,"column":13},"end":{"line":81,"column":28}},{"start":{"line":81,"column":32},"end":{"line":81,"column":70}}]},"4":{"line":128,"type":"binary-expr","locations":[{"start":{"line":128,"column":6},"end":{"line":128,"column":23}},{"start":{"line":128,"column":27},"end":{"line":128,"column":58}}]},"5":{"line":178,"type":"if","locations":[{"start":{"line":178,"column":6},"end":{"line":178,"column":6}},{"start":{"line":178,"column":6},"end":{"line":178,"column":6}}]},"6":{"line":243,"type":"if","locations":[{"start":{"line":243,"column":4},"end":{"line":243,"column":4}},{"start":{"line":243,"column":4},"end":{"line":243,"column":4}}]},"7":{"line":254,"type":"if","locations":[{"start":{"line":254,"column":6},"end":{"line":254,"column":6}},{"start":{"line":254,"column":6},"end":{"line":254,"column":6}}]},"8":{"line":258,"type":"if","locations":[{"start":{"line":258,"column":6},"end":{"line":258,"column":6}},{"start":{"line":258,"column":6},"end":{"line":258,"column":6}}]},"9":{"line":267,"type":"switch","locations":[{"start":{"line":268,"column":8},"end":{"line":271,"column":15}},{"start":{"line":272,"column":8},"end":{"line":281,"column":15}},{"start":{"line":282,"column":8},"end":{"line":303,"column":15}},{"start":{"line":304,"column":8},"end":{"line":305,"column":111}}]},"10":{"line":275,"type":"if","locations":[{"start":{"line":275,"column":10},"end":{"line":275,"column":10}},{"start":{"line":275,"column":10},"end":{"line":275,"column":10}}]},"11":{"line":291,"type":"if","locations":[{"start":{"line":291,"column":12},"end":{"line":291,"column":12}},{"start":{"line":291,"column":12},"end":{"line":291,"column":12}}]},"12":{"line":299,"type":"if","locations":[{"start":{"line":299,"column":10},"end":{"line":299,"column":10}},{"start":{"line":299,"column":10},"end":{"line":299,"column":10}}]},"13":{"line":317,"type":"if","locations":[{"start":{"line":317,"column":6},"end":{"line":317,"column":6}},{"start":{"line":317,"column":6},"end":{"line":317,"column":6}}]}}},"/Users/jeff/Projects/awilix/lib/loadModules.js":{"path":"/Users/jeff/Projects/awilix/lib/loadModules.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":10,"10":10,"11":10,"12":10,"13":10,"14":20,"15":20,"16":1,"17":19,"18":5,"19":3,"20":2,"21":14,"22":10,"23":20,"24":17,"25":17,"26":17,"27":3,"28":2,"29":3,"30":2,"31":17,"32":17,"33":17,"34":17,"35":5,"36":17,"37":17,"38":10},"b":{"1":[10,2],"2":[1,19],"3":[5,14],"4":[3,2],"5":[5,3],"6":[3,14],"7":[2,1],"8":[2,1],"9":[1,16],"10":[17,17,1],"11":[5,12]},"f":{"1":10},"fnMap":{"1":{"name":"loadModules","line":38,"loc":{"start":{"line":38,"column":17},"end":{"line":38,"column":73}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":35}},"3":{"start":{"line":3,"column":0},"end":{"line":3,"column":37}},"4":{"start":{"line":4,"column":0},"end":{"line":4,"column":42}},"5":{"start":{"line":5,"column":0},"end":{"line":5,"column":38}},"6":{"start":{"line":6,"column":0},"end":{"line":6,"column":48}},"7":{"start":{"line":8,"column":0},"end":{"line":10,"column":1}},"8":{"start":{"line":38,"column":0},"end":{"line":107,"column":1}},"9":{"start":{"line":39,"column":2},"end":{"line":39,"column":19}},"10":{"start":{"line":40,"column":2},"end":{"line":44,"column":10}},"11":{"start":{"line":45,"column":2},"end":{"line":45,"column":42}},"12":{"start":{"line":46,"column":2},"end":{"line":46,"column":62}},"13":{"start":{"line":48,"column":2},"end":{"line":76,"column":4}},"14":{"start":{"line":49,"column":4},"end":{"line":49,"column":47}},"15":{"start":{"line":52,"column":4},"end":{"line":54,"column":5}},"16":{"start":{"line":53,"column":6},"end":{"line":53,"column":22}},"17":{"start":{"line":56,"column":4},"end":{"line":68,"column":5}},"18":{"start":{"line":57,"column":6},"end":{"line":65,"column":7}},"19":{"start":{"line":59,"column":8},"end":{"line":64,"column":9}},"20":{"start":{"line":67,"column":6},"end":{"line":67,"column":22}},"21":{"start":{"line":70,"column":4},"end":{"line":75,"column":5}},"22":{"start":{"line":77,"column":2},"end":{"line":103,"column":4}},"23":{"start":{"line":77,"column":21},"end":{"line":77,"column":22}},"24":{"start":{"line":78,"column":4},"end":{"line":78,"column":36}},"25":{"start":{"line":79,"column":4},"end":{"line":79,"column":35}},"26":{"start":{"line":80,"column":4},"end":{"line":88,"column":5}},"27":{"start":{"line":81,"column":6},"end":{"line":83,"column":7}},"28":{"start":{"line":82,"column":8},"end":{"line":82,"column":45}},"29":{"start":{"line":85,"column":6},"end":{"line":87,"column":7}},"30":{"start":{"line":86,"column":8},"end":{"line":86,"column":48}},"31":{"start":{"line":90,"column":4},"end":{"line":90,"column":98}},"32":{"start":{"line":91,"column":4},"end":{"line":91,"column":106}},"33":{"start":{"line":92,"column":4},"end":{"line":92,"column":52}},"34":{"start":{"line":94,"column":4},"end":{"line":96,"column":5}},"35":{"start":{"line":95,"column":6},"end":{"line":95,"column":63}},"36":{"start":{"line":98,"column":4},"end":{"line":98,"column":79}},"37":{"start":{"line":99,"column":4},"end":{"line":102,"column":5}},"38":{"start":{"line":104,"column":2},"end":{"line":106,"column":3}}},"branchMap":{"1":{"line":39,"type":"binary-expr","locations":[{"start":{"line":39,"column":9},"end":{"line":39,"column":13}},{"start":{"line":39,"column":17},"end":{"line":39,"column":19}}]},"2":{"line":52,"type":"if","locations":[{"start":{"line":52,"column":4},"end":{"line":52,"column":4}},{"start":{"line":52,"column":4},"end":{"line":52,"column":4}}]},"3":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":4},"end":{"line":56,"column":4}},{"start":{"line":56,"column":4},"end":{"line":56,"column":4}}]},"4":{"line":57,"type":"if","locations":[{"start":{"line":57,"column":6},"end":{"line":57,"column":6}},{"start":{"line":57,"column":6},"end":{"line":57,"column":6}}]},"5":{"line":57,"type":"binary-expr","locations":[{"start":{"line":57,"column":10},"end":{"line":57,"column":24}},{"start":{"line":57,"column":28},"end":{"line":57,"column":54}}]},"6":{"line":80,"type":"if","locations":[{"start":{"line":80,"column":4},"end":{"line":80,"column":4}},{"start":{"line":80,"column":4},"end":{"line":80,"column":4}}]},"7":{"line":81,"type":"if","locations":[{"start":{"line":81,"column":6},"end":{"line":81,"column":6}},{"start":{"line":81,"column":6},"end":{"line":81,"column":6}}]},"8":{"line":85,"type":"if","locations":[{"start":{"line":85,"column":6},"end":{"line":85,"column":6}},{"start":{"line":85,"column":6},"end":{"line":85,"column":6}}]},"9":{"line":90,"type":"cond-expr","locations":[{"start":{"line":90,"column":50},"end":{"line":90,"column":71}},{"start":{"line":90,"column":74},"end":{"line":90,"column":98}}]},"10":{"line":91,"type":"binary-expr","locations":[{"start":{"line":91,"column":22},"end":{"line":91,"column":46}},{"start":{"line":91,"column":50},"end":{"line":91,"column":83}},{"start":{"line":91,"column":88},"end":{"line":91,"column":106}}]},"11":{"line":94,"type":"if","locations":[{"start":{"line":94,"column":4},"end":{"line":94,"column":4}},{"start":{"line":94,"column":4},"end":{"line":94,"column":4}}]}}},"/Users/jeff/Projects/awilix/lib/isFunction.js":{"path":"/Users/jeff/Projects/awilix/lib/isFunction.js","s":{"1":1,"2":29},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":10,"column":0},"end":{"line":10,"column":49}},"2":{"start":{"line":10,"column":24},"end":{"line":10,"column":49}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/Lifetime.js":{"path":"/Users/jeff/Projects/awilix/lib/Lifetime.js","s":{"1":1,"2":1,"3":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":5,"column":38}},"2":{"start":{"line":11,"column":0},"end":{"line":11,"column":38}},"3":{"start":{"line":17,"column":0},"end":{"line":17,"column":32}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/registrations.js":{"path":"/Users/jeff/Projects/awilix/lib/registrations.js","s":{"1":1,"2":1,"3":66,"4":1,"5":66,"6":15,"7":15,"8":66,"9":4,"10":5,"11":4,"12":1,"13":17,"14":9,"15":17,"16":1,"17":1,"18":52,"19":52,"20":52,"21":49,"22":52,"23":52,"24":52,"25":1,"26":1,"27":14,"28":14,"29":14,"30":5,"31":14,"32":14,"33":14,"34":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},"2":{"start":{"line":14,"column":0},"end":{"line":16,"column":1}},"3":{"start":{"line":15,"column":2},"end":{"line":15,"column":43}},"4":{"start":{"line":31,"column":0},"end":{"line":43,"column":1}},"5":{"start":{"line":32,"column":2},"end":{"line":35,"column":3}},"6":{"start":{"line":33,"column":4},"end":{"line":33,"column":24}},"7":{"start":{"line":34,"column":4},"end":{"line":34,"column":14}},"8":{"start":{"line":37,"column":2},"end":{"line":42,"column":3}},"9":{"start":{"line":39,"column":21},"end":{"line":39,"column":52}},"10":{"start":{"line":40,"column":18},"end":{"line":40,"column":46}},"11":{"start":{"line":41,"column":21},"end":{"line":41,"column":52}},"12":{"start":{"line":57,"column":0},"end":{"line":66,"column":1}},"13":{"start":{"line":58,"column":2},"end":{"line":60,"column":3}},"14":{"start":{"line":59,"column":4},"end":{"line":59,"column":16}},"15":{"start":{"line":62,"column":2},"end":{"line":65,"column":3}},"16":{"start":{"line":68,"column":0},"end":{"line":68,"column":32}},"17":{"start":{"line":86,"column":0},"end":{"line":101,"column":1}},"18":{"start":{"line":87,"column":2},"end":{"line":89,"column":3}},"19":{"start":{"line":91,"column":2},"end":{"line":91,"column":36}},"20":{"start":{"line":93,"column":2},"end":{"line":93,"column":53}},"21":{"start":{"line":93,"column":33},"end":{"line":93,"column":53}},"22":{"start":{"line":95,"column":2},"end":{"line":98,"column":3}},"23":{"start":{"line":99,"column":2},"end":{"line":99,"column":51}},"24":{"start":{"line":100,"column":2},"end":{"line":100,"column":15}},"25":{"start":{"line":103,"column":0},"end":{"line":103,"column":38}},"26":{"start":{"line":120,"column":0},"end":{"line":136,"column":1}},"27":{"start":{"line":121,"column":2},"end":{"line":123,"column":3}},"28":{"start":{"line":125,"column":2},"end":{"line":125,"column":36}},"29":{"start":{"line":127,"column":2},"end":{"line":127,"column":59}},"30":{"start":{"line":127,"column":33},"end":{"line":127,"column":59}},"31":{"start":{"line":129,"column":2},"end":{"line":132,"column":3}},"32":{"start":{"line":134,"column":2},"end":{"line":134,"column":51}},"33":{"start":{"line":135,"column":2},"end":{"line":135,"column":15}},"34":{"start":{"line":138,"column":0},"end":{"line":138,"column":32}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/listModules.js":{"path":"/Users/jeff/Projects/awilix/lib/listModules.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":12,"7":12,"8":12,"9":3,"10":3,"11":12,"12":12,"13":79,"14":12,"15":1,"16":9,"17":5,"18":8,"19":4},"b":{"1":[3,9],"2":[5,4]},"f":{"1":12,"2":9},"fnMap":{"1":{"name":"_listModules","line":23,"loc":{"start":{"line":23,"column":0},"end":{"line":23,"column":42}}},"2":{"name":"listModules","line":55,"loc":{"start":{"line":55,"column":17},"end":{"line":55,"column":59}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":28}},"3":{"start":{"line":3,"column":0},"end":{"line":3,"column":36}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":28}},"5":{"start":{"line":23,"column":0},"end":{"line":38,"column":1}},"6":{"start":{"line":24,"column":2},"end":{"line":24,"column":69}},"7":{"start":{"line":25,"column":2},"end":{"line":25,"column":24}},"8":{"start":{"line":26,"column":2},"end":{"line":29,"column":3}},"9":{"start":{"line":27,"column":4},"end":{"line":27,"column":32}},"10":{"start":{"line":28,"column":4},"end":{"line":28,"column":32}},"11":{"start":{"line":31,"column":2},"end":{"line":31,"column":58}},"12":{"start":{"line":32,"column":2},"end":{"line":36,"column":5}},"13":{"start":{"line":32,"column":34},"end":{"line":36,"column":3}},"14":{"start":{"line":37,"column":2},"end":{"line":37,"column":15}},"15":{"start":{"line":55,"column":0},"end":{"line":65,"column":1}},"16":{"start":{"line":56,"column":2},"end":{"line":62,"column":3}},"17":{"start":{"line":57,"column":4},"end":{"line":61,"column":5}},"18":{"start":{"line":59,"column":13},"end":{"line":59,"column":34}},"19":{"start":{"line":64,"column":2},"end":{"line":64,"column":41}}},"branchMap":{"1":{"line":26,"type":"if","locations":[{"start":{"line":26,"column":2},"end":{"line":26,"column":2}},{"start":{"line":26,"column":2},"end":{"line":26,"column":2}}]},"2":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":2},"end":{"line":56,"column":2}},{"start":{"line":56,"column":2},"end":{"line":56,"column":2}}]}}},"/Users/jeff/Projects/awilix/lib/flatten.js":{"path":"/Users/jeff/Projects/awilix/lib/flatten.js","s":{"1":1,"2":6,"3":6,"4":10,"5":37,"6":6},"b":{},"f":{"1":6},"fnMap":{"1":{"name":"flatten","line":10,"loc":{"start":{"line":10,"column":17},"end":{"line":10,"column":42}}}},"statementMap":{"1":{"start":{"line":10,"column":0},"end":{"line":19,"column":1}},"2":{"start":{"line":11,"column":2},"end":{"line":11,"column":19}},"3":{"start":{"line":12,"column":2},"end":{"line":16,"column":4}},"4":{"start":{"line":13,"column":4},"end":{"line":15,"column":6}},"5":{"start":{"line":14,"column":6},"end":{"line":14,"column":23}},"6":{"start":{"line":18,"column":2},"end":{"line":18,"column":15}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/AwilixResolutionError.js":{"path":"/Users/jeff/Projects/awilix/lib/AwilixResolutionError.js","s":{"1":1,"2":1,"3":1,"4":7,"5":7,"6":7,"7":7,"8":7,"9":2,"10":7,"11":7,"12":7,"13":7,"14":1},"b":{"1":[2,5]},"f":{"1":7},"fnMap":{"1":{"name":"(anonymous_1)","line":45,"loc":{"start":{"line":45,"column":14},"end":{"line":45,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":52}},"3":{"start":{"line":16,"column":0},"end":{"line":29,"column":1}},"4":{"start":{"line":17,"column":2},"end":{"line":17,"column":43}},"5":{"start":{"line":18,"column":2},"end":{"line":18,"column":28}},"6":{"start":{"line":19,"column":2},"end":{"line":19,"column":59}},"7":{"start":{"line":20,"column":2},"end":{"line":20,"column":42}},"8":{"start":{"line":21,"column":2},"end":{"line":23,"column":3}},"9":{"start":{"line":22,"column":4},"end":{"line":22,"column":24}},"10":{"start":{"line":25,"column":2},"end":{"line":25,"column":18}},"11":{"start":{"line":26,"column":2},"end":{"line":26,"column":51}},"12":{"start":{"line":28,"column":2},"end":{"line":28,"column":12}},"13":{"start":{"line":46,"column":4},"end":{"line":46,"column":61}},"14":{"start":{"line":50,"column":0},"end":{"line":50,"column":38}}},"branchMap":{"1":{"line":21,"type":"if","locations":[{"start":{"line":21,"column":2},"end":{"line":21,"column":2}},{"start":{"line":21,"column":2},"end":{"line":21,"column":2}}]}}},"/Users/jeff/Projects/awilix/lib/ExtendableError.js":{"path":"/Users/jeff/Projects/awilix/lib/ExtendableError.js","s":{"1":7,"2":7,"3":7,"4":7,"5":1},"b":{},"f":{"1":7},"fnMap":{"1":{"name":"(anonymous_1)","line":12,"loc":{"start":{"line":12,"column":14},"end":{"line":12,"column":24}}}},"statementMap":{"1":{"start":{"line":13,"column":4},"end":{"line":13,"column":18}},"2":{"start":{"line":16,"column":4},"end":{"line":19,"column":6}},"3":{"start":{"line":21,"column":4},"end":{"line":24,"column":6}},"4":{"start":{"line":26,"column":4},"end":{"line":26,"column":51}},"5":{"start":{"line":30,"column":0},"end":{"line":30,"column":32}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/nameValueToObject.js":{"path":"/Users/jeff/Projects/awilix/lib/nameValueToObject.js","s":{"1":1,"2":1,"3":98,"4":98,"5":65,"6":98,"7":1},"b":{"1":[65,33]},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":48}},"2":{"start":{"line":14,"column":0},"end":{"line":21,"column":1}},"3":{"start":{"line":15,"column":2},"end":{"line":15,"column":16}},"4":{"start":{"line":16,"column":2},"end":{"line":18,"column":3}},"5":{"start":{"line":17,"column":4},"end":{"line":17,"column":42}},"6":{"start":{"line":20,"column":2},"end":{"line":20,"column":12}},"7":{"start":{"line":23,"column":0},"end":{"line":23,"column":34}}},"branchMap":{"1":{"line":16,"type":"if","locations":[{"start":{"line":16,"column":2},"end":{"line":16,"column":2}},{"start":{"line":16,"column":2},"end":{"line":16,"column":2}}]}}},"/Users/jeff/Projects/awilix/lib/last.js":{"path":"/Users/jeff/Projects/awilix/lib/last.js","s":{"1":1,"2":86},"b":{},"f":{"1":86},"fnMap":{"1":{"name":"last","line":10,"loc":{"start":{"line":10,"column":17},"end":{"line":10,"column":37}}}},"statementMap":{"1":{"start":{"line":10,"column":0},"end":{"line":12,"column":1}},"2":{"start":{"line":11,"column":2},"end":{"line":11,"column":28}}},"branchMap":{}}} | ||
{"/Users/jeff/Projects/awilix/lib/awilix.js":{"path":"/Users/jeff/Projects/awilix/lib/awilix.js","s":{"1":1,"2":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":2,"column":0},"end":{"line":8,"column":1}},"2":{"start":{"line":11,"column":0},"end":{"line":11,"column":57}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/createContainer.js":{"path":"/Users/jeff/Projects/awilix/lib/createContainer.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":1,"10":1,"11":69,"12":69,"13":69,"14":69,"15":69,"16":65,"17":2,"18":69,"19":69,"20":69,"21":69,"22":8,"23":69,"24":67,"25":1,"26":69,"27":69,"28":133,"29":69,"30":17,"31":69,"32":69,"33":86,"34":86,"35":92,"36":92,"37":86,"38":69,"39":69,"40":207,"41":32,"42":32,"43":45,"44":45,"45":45,"46":5,"47":5,"48":45,"49":32,"50":69,"51":69,"52":69,"53":69,"54":101,"55":68,"56":101,"57":101,"58":101,"59":101,"60":1,"61":100,"62":5,"63":95,"64":95,"65":95,"66":63,"67":49,"68":6,"69":6,"70":2,"71":2,"72":4,"73":6,"74":25,"75":38,"76":38,"77":14,"78":14,"79":25,"80":11,"81":11,"82":25,"83":1,"84":80,"85":80,"86":21,"87":21,"88":101,"89":82,"90":69,"91":69,"92":3,"93":3,"94":69,"95":69},"b":{"1":[1,1],"2":[17,52],"3":[69,69],"4":[133,37],"5":[5,40],"6":[45,34],"7":[68,33],"8":[1,100],"9":[5,95],"10":[63,6,25,1],"11":[2,4],"12":[14,24],"13":[11,14],"14":[82,19]},"f":{"1":69,"2":65,"3":8,"4":32},"fnMap":{"1":{"name":"createContainer","line":28,"loc":{"start":{"line":28,"column":17},"end":{"line":28,"column":71}}},"2":{"name":"(anonymous_2)","line":57,"loc":{"start":{"line":57,"column":22},"end":{"line":57,"column":25}}},"3":{"name":"(anonymous_3)","line":91,"loc":{"start":{"line":91,"column":32},"end":{"line":91,"column":47}}},"4":{"name":"registerShortcut","line":186,"loc":{"start":{"line":186,"column":46},"end":{"line":186,"column":92}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":44}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":44}},"3":{"start":{"line":3,"column":0},"end":{"line":3,"column":67}},"4":{"start":{"line":4,"column":0},"end":{"line":4,"column":50}},"5":{"start":{"line":5,"column":0},"end":{"line":5,"column":64}},"6":{"start":{"line":6,"column":0},"end":{"line":6,"column":56}},"7":{"start":{"line":7,"column":0},"end":{"line":7,"column":38}},"8":{"start":{"line":8,"column":0},"end":{"line":8,"column":30}},"9":{"start":{"line":14,"column":0},"end":{"line":14,"column":40}},"10":{"start":{"line":28,"column":0},"end":{"line":366,"column":1}},"11":{"start":{"line":29,"column":2},"end":{"line":31,"column":13}},"12":{"start":{"line":37,"column":2},"end":{"line":37,"column":26}},"13":{"start":{"line":41,"column":2},"end":{"line":41,"column":32}},"14":{"start":{"line":44,"column":2},"end":{"line":44,"column":26}},"15":{"start":{"line":47,"column":2},"end":{"line":67,"column":3}},"16":{"start":{"line":58,"column":6},"end":{"line":58,"column":34}},"17":{"start":{"line":65,"column":6},"end":{"line":65,"column":134}},"18":{"start":{"line":70,"column":2},"end":{"line":72,"column":17}},"19":{"start":{"line":80,"column":2},"end":{"line":80,"column":37}},"20":{"start":{"line":87,"column":2},"end":{"line":87,"column":22}},"21":{"start":{"line":90,"column":2},"end":{"line":94,"column":3}},"22":{"start":{"line":91,"column":49},"end":{"line":91,"column":69}},"23":{"start":{"line":101,"column":2},"end":{"line":125,"column":4}},"24":{"start":{"line":114,"column":27},"end":{"line":114,"column":40}},"25":{"start":{"line":123,"column":6},"end":{"line":123,"column":104}},"26":{"start":{"line":127,"column":2},"end":{"line":127,"column":27}},"27":{"start":{"line":135,"column":2},"end":{"line":141,"column":3}},"28":{"start":{"line":136,"column":4},"end":{"line":140,"column":5}},"29":{"start":{"line":149,"column":2},"end":{"line":151,"column":3}},"30":{"start":{"line":150,"column":4},"end":{"line":150,"column":46}},"31":{"start":{"line":153,"column":2},"end":{"line":153,"column":37}},"32":{"start":{"line":164,"column":2},"end":{"line":172,"column":3}},"33":{"start":{"line":165,"column":4},"end":{"line":165,"column":53}},"34":{"start":{"line":166,"column":4},"end":{"line":169,"column":5}},"35":{"start":{"line":167,"column":6},"end":{"line":167,"column":28}},"36":{"start":{"line":168,"column":6},"end":{"line":168,"column":32}},"37":{"start":{"line":171,"column":4},"end":{"line":171,"column":20}},"38":{"start":{"line":174,"column":2},"end":{"line":174,"column":31}},"39":{"start":{"line":186,"column":2},"end":{"line":207,"column":3}},"40":{"start":{"line":186,"column":46},"end":{"line":207,"column":3}},"41":{"start":{"line":188,"column":4},"end":{"line":188,"column":46}},"42":{"start":{"line":190,"column":4},"end":{"line":203,"column":5}},"43":{"start":{"line":191,"column":6},"end":{"line":191,"column":36}},"44":{"start":{"line":194,"column":6},"end":{"line":194,"column":36}},"45":{"start":{"line":196,"column":6},"end":{"line":200,"column":7}},"46":{"start":{"line":198,"column":8},"end":{"line":198,"column":58}},"47":{"start":{"line":199,"column":8},"end":{"line":199,"column":44}},"48":{"start":{"line":202,"column":6},"end":{"line":202,"column":46}},"49":{"start":{"line":206,"column":4},"end":{"line":206,"column":20}},"50":{"start":{"line":221,"column":2},"end":{"line":221,"column":55}},"51":{"start":{"line":235,"column":2},"end":{"line":235,"column":49}},"52":{"start":{"line":249,"column":2},"end":{"line":249,"column":76}},"53":{"start":{"line":260,"column":2},"end":{"line":339,"column":3}},"54":{"start":{"line":261,"column":4},"end":{"line":263,"column":5}},"55":{"start":{"line":262,"column":6},"end":{"line":262,"column":49}},"56":{"start":{"line":267,"column":4},"end":{"line":267,"column":33}},"57":{"start":{"line":269,"column":4},"end":{"line":338,"column":5}},"58":{"start":{"line":271,"column":6},"end":{"line":271,"column":52}},"59":{"start":{"line":272,"column":6},"end":{"line":274,"column":7}},"60":{"start":{"line":273,"column":8},"end":{"line":273,"column":95}},"61":{"start":{"line":276,"column":6},"end":{"line":278,"column":7}},"62":{"start":{"line":277,"column":8},"end":{"line":277,"column":62}},"63":{"start":{"line":281,"column":6},"end":{"line":281,"column":32}},"64":{"start":{"line":284,"column":6},"end":{"line":284,"column":26}},"65":{"start":{"line":285,"column":6},"end":{"line":324,"column":7}},"66":{"start":{"line":288,"column":10},"end":{"line":288,"column":52}},"67":{"start":{"line":289,"column":10},"end":{"line":289,"column":15}},"68":{"start":{"line":292,"column":10},"end":{"line":292,"column":35}},"69":{"start":{"line":293,"column":10},"end":{"line":298,"column":11}},"70":{"start":{"line":294,"column":12},"end":{"line":294,"column":54}},"71":{"start":{"line":295,"column":12},"end":{"line":295,"column":39}},"72":{"start":{"line":297,"column":12},"end":{"line":297,"column":29}},"73":{"start":{"line":299,"column":10},"end":{"line":299,"column":15}},"74":{"start":{"line":307,"column":10},"end":{"line":314,"column":11}},"75":{"start":{"line":308,"column":12},"end":{"line":308,"column":34}},"76":{"start":{"line":309,"column":12},"end":{"line":313,"column":13}},"77":{"start":{"line":311,"column":14},"end":{"line":311,"column":31}},"78":{"start":{"line":312,"column":14},"end":{"line":312,"column":19}},"79":{"start":{"line":317,"column":10},"end":{"line":320,"column":11}},"80":{"start":{"line":318,"column":12},"end":{"line":318,"column":54}},"81":{"start":{"line":319,"column":12},"end":{"line":319,"column":44}},"82":{"start":{"line":321,"column":10},"end":{"line":321,"column":15}},"83":{"start":{"line":323,"column":10},"end":{"line":323,"column":111}},"84":{"start":{"line":326,"column":6},"end":{"line":326,"column":27}},"85":{"start":{"line":327,"column":6},"end":{"line":327,"column":21}},"86":{"start":{"line":330,"column":6},"end":{"line":330,"column":26}},"87":{"start":{"line":331,"column":6},"end":{"line":331,"column":15}},"88":{"start":{"line":335,"column":6},"end":{"line":337,"column":7}},"89":{"start":{"line":336,"column":8},"end":{"line":336,"column":34}},"90":{"start":{"line":341,"column":2},"end":{"line":341,"column":29}},"91":{"start":{"line":352,"column":2},"end":{"line":355,"column":3}},"92":{"start":{"line":353,"column":4},"end":{"line":353,"column":53}},"93":{"start":{"line":354,"column":4},"end":{"line":354,"column":20}},"94":{"start":{"line":362,"column":2},"end":{"line":362,"column":37}},"95":{"start":{"line":365,"column":2},"end":{"line":365,"column":18}}},"branchMap":{"1":{"line":65,"type":"cond-expr","locations":[{"start":{"line":65,"column":54},"end":{"line":65,"column":64}},{"start":{"line":65,"column":67},"end":{"line":65,"column":69}}]},"2":{"line":70,"type":"cond-expr","locations":[{"start":{"line":71,"column":6},"end":{"line":71,"column":56}},{"start":{"line":72,"column":6},"end":{"line":72,"column":17}}]},"3":{"line":91,"type":"binary-expr","locations":[{"start":{"line":91,"column":13},"end":{"line":91,"column":28}},{"start":{"line":91,"column":32},"end":{"line":91,"column":70}}]},"4":{"line":138,"type":"binary-expr","locations":[{"start":{"line":138,"column":6},"end":{"line":138,"column":23}},{"start":{"line":138,"column":27},"end":{"line":138,"column":58}}]},"5":{"line":196,"type":"if","locations":[{"start":{"line":196,"column":6},"end":{"line":196,"column":6}},{"start":{"line":196,"column":6},"end":{"line":196,"column":6}}]},"6":{"line":196,"type":"binary-expr","locations":[{"start":{"line":196,"column":10},"end":{"line":196,"column":24}},{"start":{"line":196,"column":28},"end":{"line":196,"column":58}}]},"7":{"line":261,"type":"if","locations":[{"start":{"line":261,"column":4},"end":{"line":261,"column":4}},{"start":{"line":261,"column":4},"end":{"line":261,"column":4}}]},"8":{"line":272,"type":"if","locations":[{"start":{"line":272,"column":6},"end":{"line":272,"column":6}},{"start":{"line":272,"column":6},"end":{"line":272,"column":6}}]},"9":{"line":276,"type":"if","locations":[{"start":{"line":276,"column":6},"end":{"line":276,"column":6}},{"start":{"line":276,"column":6},"end":{"line":276,"column":6}}]},"10":{"line":285,"type":"switch","locations":[{"start":{"line":286,"column":8},"end":{"line":289,"column":15}},{"start":{"line":290,"column":8},"end":{"line":299,"column":15}},{"start":{"line":300,"column":8},"end":{"line":321,"column":15}},{"start":{"line":322,"column":8},"end":{"line":323,"column":111}}]},"11":{"line":293,"type":"if","locations":[{"start":{"line":293,"column":10},"end":{"line":293,"column":10}},{"start":{"line":293,"column":10},"end":{"line":293,"column":10}}]},"12":{"line":309,"type":"if","locations":[{"start":{"line":309,"column":12},"end":{"line":309,"column":12}},{"start":{"line":309,"column":12},"end":{"line":309,"column":12}}]},"13":{"line":317,"type":"if","locations":[{"start":{"line":317,"column":10},"end":{"line":317,"column":10}},{"start":{"line":317,"column":10},"end":{"line":317,"column":10}}]},"14":{"line":335,"type":"if","locations":[{"start":{"line":335,"column":6},"end":{"line":335,"column":6}},{"start":{"line":335,"column":6},"end":{"line":335,"column":6}}]}}},"/Users/jeff/Projects/awilix/lib/loadModules.js":{"path":"/Users/jeff/Projects/awilix/lib/loadModules.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":1,"9":11,"10":11,"11":11,"12":11,"13":11,"14":22,"15":22,"16":1,"17":21,"18":5,"19":3,"20":2,"21":16,"22":11,"23":22,"24":19,"25":19,"26":19,"27":3,"28":2,"29":3,"30":2,"31":19,"32":19,"33":5,"34":19,"35":19,"36":19,"37":11},"b":{"1":[11,2],"2":[11,11],"3":[1,21],"4":[5,16],"5":[3,2],"6":[5,3],"7":[3,16],"8":[2,1],"9":[2,1],"10":[5,14],"11":[1,18]},"f":{"1":11},"fnMap":{"1":{"name":"loadModules","line":38,"loc":{"start":{"line":38,"column":17},"end":{"line":38,"column":73}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":39}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":35}},"3":{"start":{"line":3,"column":0},"end":{"line":3,"column":37}},"4":{"start":{"line":4,"column":0},"end":{"line":4,"column":42}},"5":{"start":{"line":5,"column":0},"end":{"line":5,"column":38}},"6":{"start":{"line":6,"column":0},"end":{"line":6,"column":48}},"7":{"start":{"line":8,"column":0},"end":{"line":10,"column":1}},"8":{"start":{"line":38,"column":0},"end":{"line":108,"column":1}},"9":{"start":{"line":39,"column":2},"end":{"line":39,"column":42}},"10":{"start":{"line":40,"column":2},"end":{"line":40,"column":19}},"11":{"start":{"line":41,"column":2},"end":{"line":47,"column":10}},"12":{"start":{"line":48,"column":2},"end":{"line":48,"column":62}},"13":{"start":{"line":50,"column":2},"end":{"line":78,"column":4}},"14":{"start":{"line":51,"column":4},"end":{"line":51,"column":47}},"15":{"start":{"line":54,"column":4},"end":{"line":56,"column":5}},"16":{"start":{"line":55,"column":6},"end":{"line":55,"column":22}},"17":{"start":{"line":58,"column":4},"end":{"line":70,"column":5}},"18":{"start":{"line":59,"column":6},"end":{"line":67,"column":7}},"19":{"start":{"line":61,"column":8},"end":{"line":66,"column":9}},"20":{"start":{"line":69,"column":6},"end":{"line":69,"column":22}},"21":{"start":{"line":72,"column":4},"end":{"line":77,"column":5}},"22":{"start":{"line":79,"column":2},"end":{"line":104,"column":4}},"23":{"start":{"line":79,"column":21},"end":{"line":79,"column":22}},"24":{"start":{"line":80,"column":4},"end":{"line":80,"column":36}},"25":{"start":{"line":81,"column":4},"end":{"line":81,"column":35}},"26":{"start":{"line":82,"column":4},"end":{"line":90,"column":5}},"27":{"start":{"line":83,"column":6},"end":{"line":85,"column":7}},"28":{"start":{"line":84,"column":8},"end":{"line":84,"column":45}},"29":{"start":{"line":87,"column":6},"end":{"line":89,"column":7}},"30":{"start":{"line":88,"column":8},"end":{"line":88,"column":48}},"31":{"start":{"line":92,"column":4},"end":{"line":92,"column":52}},"32":{"start":{"line":94,"column":4},"end":{"line":96,"column":5}},"33":{"start":{"line":95,"column":6},"end":{"line":95,"column":63}},"34":{"start":{"line":98,"column":4},"end":{"line":98,"column":98}},"35":{"start":{"line":99,"column":4},"end":{"line":99,"column":85}},"36":{"start":{"line":100,"column":4},"end":{"line":103,"column":5}},"37":{"start":{"line":105,"column":2},"end":{"line":107,"column":3}}},"branchMap":{"1":{"line":40,"type":"binary-expr","locations":[{"start":{"line":40,"column":9},"end":{"line":40,"column":13}},{"start":{"line":40,"column":17},"end":{"line":40,"column":19}}]},"2":{"line":46,"type":"binary-expr","locations":[{"start":{"line":46,"column":7},"end":{"line":46,"column":11}},{"start":{"line":46,"column":15},"end":{"line":46,"column":39}}]},"3":{"line":54,"type":"if","locations":[{"start":{"line":54,"column":4},"end":{"line":54,"column":4}},{"start":{"line":54,"column":4},"end":{"line":54,"column":4}}]},"4":{"line":58,"type":"if","locations":[{"start":{"line":58,"column":4},"end":{"line":58,"column":4}},{"start":{"line":58,"column":4},"end":{"line":58,"column":4}}]},"5":{"line":59,"type":"if","locations":[{"start":{"line":59,"column":6},"end":{"line":59,"column":6}},{"start":{"line":59,"column":6},"end":{"line":59,"column":6}}]},"6":{"line":59,"type":"binary-expr","locations":[{"start":{"line":59,"column":10},"end":{"line":59,"column":24}},{"start":{"line":59,"column":28},"end":{"line":59,"column":54}}]},"7":{"line":82,"type":"if","locations":[{"start":{"line":82,"column":4},"end":{"line":82,"column":4}},{"start":{"line":82,"column":4},"end":{"line":82,"column":4}}]},"8":{"line":83,"type":"if","locations":[{"start":{"line":83,"column":6},"end":{"line":83,"column":6}},{"start":{"line":83,"column":6},"end":{"line":83,"column":6}}]},"9":{"line":87,"type":"if","locations":[{"start":{"line":87,"column":6},"end":{"line":87,"column":6}},{"start":{"line":87,"column":6},"end":{"line":87,"column":6}}]},"10":{"line":94,"type":"if","locations":[{"start":{"line":94,"column":4},"end":{"line":94,"column":4}},{"start":{"line":94,"column":4},"end":{"line":94,"column":4}}]},"11":{"line":98,"type":"cond-expr","locations":[{"start":{"line":98,"column":50},"end":{"line":98,"column":71}},{"start":{"line":98,"column":74},"end":{"line":98,"column":98}}]}}},"/Users/jeff/Projects/awilix/lib/isFunction.js":{"path":"/Users/jeff/Projects/awilix/lib/isFunction.js","s":{"1":1,"2":31},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":10,"column":0},"end":{"line":10,"column":49}},"2":{"start":{"line":10,"column":24},"end":{"line":10,"column":49}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/Lifetime.js":{"path":"/Users/jeff/Projects/awilix/lib/Lifetime.js","s":{"1":1,"2":1,"3":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":5,"column":0},"end":{"line":5,"column":38}},"2":{"start":{"line":11,"column":0},"end":{"line":11,"column":38}},"3":{"start":{"line":17,"column":0},"end":{"line":17,"column":32}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/registrations.js":{"path":"/Users/jeff/Projects/awilix/lib/registrations.js","s":{"1":1,"2":1,"3":1,"4":84,"5":1,"6":84,"7":15,"8":15,"9":84,"10":5,"11":5,"12":84,"13":4,"14":5,"15":4,"16":2,"17":3,"18":1,"19":20,"20":12,"21":20,"22":1,"23":1,"24":58,"25":58,"26":58,"27":58,"28":58,"29":58,"30":58,"31":1,"32":1,"33":26,"34":26,"35":26,"36":19,"37":26,"38":26,"39":26,"40":26,"41":26,"42":1,"43":84,"44":58,"45":84,"46":84,"47":72,"48":72,"49":63,"50":9,"51":5,"52":5,"53":7,"54":5,"55":4,"56":1,"57":1,"58":84,"59":84,"60":27,"61":57,"62":1},"b":{"1":[58,26],"2":[72,50,1],"3":[63,9],"4":[5,4],"5":[27,57],"6":[84,62,39,27]},"f":{"1":19,"2":84,"3":72,"4":84},"fnMap":{"1":{"name":"(anonymous_1)","line":138,"loc":{"start":{"line":138,"column":19},"end":{"line":138,"column":31}}},"2":{"name":"generateResolve","line":172,"loc":{"start":{"line":172,"column":0},"end":{"line":172,"column":53}}},"3":{"name":"resolve","line":182,"loc":{"start":{"line":182,"column":9},"end":{"line":182,"column":38}}},"4":{"name":"parseDependencies","line":215,"loc":{"start":{"line":215,"column":0},"end":{"line":215,"column":34}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":38}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":50}},"3":{"start":{"line":15,"column":0},"end":{"line":17,"column":1}},"4":{"start":{"line":16,"column":2},"end":{"line":16,"column":43}},"5":{"start":{"line":32,"column":0},"end":{"line":52,"column":1}},"6":{"start":{"line":33,"column":2},"end":{"line":36,"column":3}},"7":{"start":{"line":34,"column":4},"end":{"line":34,"column":24}},"8":{"start":{"line":35,"column":4},"end":{"line":35,"column":14}},"9":{"start":{"line":38,"column":2},"end":{"line":41,"column":3}},"10":{"start":{"line":39,"column":4},"end":{"line":39,"column":30}},"11":{"start":{"line":40,"column":4},"end":{"line":40,"column":14}},"12":{"start":{"line":43,"column":2},"end":{"line":51,"column":3}},"13":{"start":{"line":45,"column":21},"end":{"line":45,"column":52}},"14":{"start":{"line":46,"column":18},"end":{"line":46,"column":46}},"15":{"start":{"line":47,"column":21},"end":{"line":47,"column":52}},"16":{"start":{"line":49,"column":17},"end":{"line":49,"column":56}},"17":{"start":{"line":50,"column":19},"end":{"line":50,"column":60}},"18":{"start":{"line":66,"column":0},"end":{"line":75,"column":1}},"19":{"start":{"line":67,"column":2},"end":{"line":69,"column":3}},"20":{"start":{"line":68,"column":4},"end":{"line":68,"column":16}},"21":{"start":{"line":71,"column":2},"end":{"line":74,"column":3}},"22":{"start":{"line":77,"column":0},"end":{"line":77,"column":32}},"23":{"start":{"line":95,"column":0},"end":{"line":111,"column":1}},"24":{"start":{"line":96,"column":2},"end":{"line":98,"column":3}},"25":{"start":{"line":100,"column":2},"end":{"line":100,"column":36}},"26":{"start":{"line":102,"column":2},"end":{"line":102,"column":37}},"27":{"start":{"line":103,"column":2},"end":{"line":107,"column":3}},"28":{"start":{"line":108,"column":2},"end":{"line":108,"column":39}},"29":{"start":{"line":109,"column":2},"end":{"line":109,"column":51}},"30":{"start":{"line":110,"column":2},"end":{"line":110,"column":15}},"31":{"start":{"line":113,"column":0},"end":{"line":113,"column":38}},"32":{"start":{"line":130,"column":0},"end":{"line":152,"column":1}},"33":{"start":{"line":131,"column":2},"end":{"line":133,"column":3}},"34":{"start":{"line":135,"column":2},"end":{"line":135,"column":36}},"35":{"start":{"line":138,"column":2},"end":{"line":140,"column":3}},"36":{"start":{"line":139,"column":4},"end":{"line":139,"column":33}},"37":{"start":{"line":142,"column":2},"end":{"line":142,"column":71}},"38":{"start":{"line":143,"column":2},"end":{"line":147,"column":3}},"39":{"start":{"line":148,"column":2},"end":{"line":148,"column":39}},"40":{"start":{"line":149,"column":2},"end":{"line":149,"column":51}},"41":{"start":{"line":151,"column":2},"end":{"line":151,"column":15}},"42":{"start":{"line":172,"column":0},"end":{"line":199,"column":1}},"43":{"start":{"line":174,"column":2},"end":{"line":176,"column":3}},"44":{"start":{"line":175,"column":4},"end":{"line":175,"column":30}},"45":{"start":{"line":179,"column":2},"end":{"line":179,"column":63}},"46":{"start":{"line":182,"column":2},"end":{"line":198,"column":3}},"47":{"start":{"line":185,"column":4},"end":{"line":185,"column":108}},"48":{"start":{"line":186,"column":4},"end":{"line":189,"column":5}},"49":{"start":{"line":188,"column":6},"end":{"line":188,"column":33}},"50":{"start":{"line":192,"column":4},"end":{"line":196,"column":5}},"51":{"start":{"line":193,"column":6},"end":{"line":193,"column":25}},"52":{"start":{"line":194,"column":6},"end":{"line":194,"column":70}},"53":{"start":{"line":194,"column":34},"end":{"line":194,"column":69}},"54":{"start":{"line":195,"column":6},"end":{"line":195,"column":28}},"55":{"start":{"line":197,"column":4},"end":{"line":197,"column":15}},"56":{"start":{"line":204,"column":0},"end":{"line":204,"column":45}},"57":{"start":{"line":215,"column":0},"end":{"line":221,"column":1}},"58":{"start":{"line":216,"column":2},"end":{"line":216,"column":46}},"59":{"start":{"line":217,"column":2},"end":{"line":219,"column":3}},"60":{"start":{"line":218,"column":4},"end":{"line":218,"column":35}},"61":{"start":{"line":220,"column":2},"end":{"line":220,"column":11}},"62":{"start":{"line":223,"column":0},"end":{"line":223,"column":32}}},"branchMap":{"1":{"line":174,"type":"if","locations":[{"start":{"line":174,"column":2},"end":{"line":174,"column":2}},{"start":{"line":174,"column":2},"end":{"line":174,"column":2}}]},"2":{"line":185,"type":"binary-expr","locations":[{"start":{"line":185,"column":28},"end":{"line":185,"column":47}},{"start":{"line":185,"column":51},"end":{"line":185,"column":83}},{"start":{"line":185,"column":87},"end":{"line":185,"column":107}}]},"3":{"line":186,"type":"if","locations":[{"start":{"line":186,"column":4},"end":{"line":186,"column":4}},{"start":{"line":186,"column":4},"end":{"line":186,"column":4}}]},"4":{"line":192,"type":"if","locations":[{"start":{"line":192,"column":4},"end":{"line":192,"column":4}},{"start":{"line":192,"column":4},"end":{"line":192,"column":4}}]},"5":{"line":217,"type":"if","locations":[{"start":{"line":217,"column":2},"end":{"line":217,"column":2}},{"start":{"line":217,"column":2},"end":{"line":217,"column":2}}]},"6":{"line":217,"type":"binary-expr","locations":[{"start":{"line":217,"column":6},"end":{"line":217,"column":10}},{"start":{"line":217,"column":14},"end":{"line":217,"column":21}},{"start":{"line":217,"column":25},"end":{"line":217,"column":47}},{"start":{"line":217,"column":51},"end":{"line":217,"column":73}}]}}},"/Users/jeff/Projects/awilix/lib/ResolutionMode.js":{"path":"/Users/jeff/Projects/awilix/lib/ResolutionMode.js","s":{"1":1,"2":1},"b":{},"f":{},"fnMap":{},"statementMap":{"1":{"start":{"line":6,"column":0},"end":{"line":6,"column":30}},"2":{"start":{"line":13,"column":0},"end":{"line":13,"column":34}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/listModules.js":{"path":"/Users/jeff/Projects/awilix/lib/listModules.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":12,"7":12,"8":12,"9":3,"10":3,"11":12,"12":12,"13":84,"14":12,"15":1,"16":9,"17":5,"18":8,"19":4},"b":{"1":[3,9],"2":[5,4]},"f":{"1":12,"2":9},"fnMap":{"1":{"name":"_listModules","line":23,"loc":{"start":{"line":23,"column":0},"end":{"line":23,"column":42}}},"2":{"name":"listModules","line":55,"loc":{"start":{"line":55,"column":17},"end":{"line":55,"column":59}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":28}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":28}},"3":{"start":{"line":3,"column":0},"end":{"line":3,"column":36}},"4":{"start":{"line":6,"column":0},"end":{"line":6,"column":28}},"5":{"start":{"line":23,"column":0},"end":{"line":38,"column":1}},"6":{"start":{"line":24,"column":2},"end":{"line":24,"column":69}},"7":{"start":{"line":25,"column":2},"end":{"line":25,"column":24}},"8":{"start":{"line":26,"column":2},"end":{"line":29,"column":3}},"9":{"start":{"line":27,"column":4},"end":{"line":27,"column":32}},"10":{"start":{"line":28,"column":4},"end":{"line":28,"column":32}},"11":{"start":{"line":31,"column":2},"end":{"line":31,"column":58}},"12":{"start":{"line":32,"column":2},"end":{"line":36,"column":5}},"13":{"start":{"line":32,"column":34},"end":{"line":36,"column":3}},"14":{"start":{"line":37,"column":2},"end":{"line":37,"column":15}},"15":{"start":{"line":55,"column":0},"end":{"line":65,"column":1}},"16":{"start":{"line":56,"column":2},"end":{"line":62,"column":3}},"17":{"start":{"line":57,"column":4},"end":{"line":61,"column":5}},"18":{"start":{"line":59,"column":13},"end":{"line":59,"column":34}},"19":{"start":{"line":64,"column":2},"end":{"line":64,"column":41}}},"branchMap":{"1":{"line":26,"type":"if","locations":[{"start":{"line":26,"column":2},"end":{"line":26,"column":2}},{"start":{"line":26,"column":2},"end":{"line":26,"column":2}}]},"2":{"line":56,"type":"if","locations":[{"start":{"line":56,"column":2},"end":{"line":56,"column":2}},{"start":{"line":56,"column":2},"end":{"line":56,"column":2}}]}}},"/Users/jeff/Projects/awilix/lib/flatten.js":{"path":"/Users/jeff/Projects/awilix/lib/flatten.js","s":{"1":1,"2":6,"3":6,"4":10,"5":39,"6":6},"b":{},"f":{"1":6},"fnMap":{"1":{"name":"flatten","line":10,"loc":{"start":{"line":10,"column":17},"end":{"line":10,"column":42}}}},"statementMap":{"1":{"start":{"line":10,"column":0},"end":{"line":19,"column":1}},"2":{"start":{"line":11,"column":2},"end":{"line":11,"column":19}},"3":{"start":{"line":12,"column":2},"end":{"line":16,"column":4}},"4":{"start":{"line":13,"column":4},"end":{"line":15,"column":6}},"5":{"start":{"line":14,"column":6},"end":{"line":14,"column":23}},"6":{"start":{"line":18,"column":2},"end":{"line":18,"column":15}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/AwilixResolutionError.js":{"path":"/Users/jeff/Projects/awilix/lib/AwilixResolutionError.js","s":{"1":1,"2":1,"3":1,"4":7,"5":7,"6":7,"7":7,"8":7,"9":2,"10":7,"11":7,"12":7,"13":7,"14":1},"b":{"1":[2,5]},"f":{"1":7},"fnMap":{"1":{"name":"(anonymous_1)","line":45,"loc":{"start":{"line":45,"column":14},"end":{"line":45,"column":47}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":29}},"2":{"start":{"line":2,"column":0},"end":{"line":2,"column":52}},"3":{"start":{"line":16,"column":0},"end":{"line":29,"column":1}},"4":{"start":{"line":17,"column":2},"end":{"line":17,"column":43}},"5":{"start":{"line":18,"column":2},"end":{"line":18,"column":28}},"6":{"start":{"line":19,"column":2},"end":{"line":19,"column":59}},"7":{"start":{"line":20,"column":2},"end":{"line":20,"column":42}},"8":{"start":{"line":21,"column":2},"end":{"line":23,"column":3}},"9":{"start":{"line":22,"column":4},"end":{"line":22,"column":24}},"10":{"start":{"line":25,"column":2},"end":{"line":25,"column":18}},"11":{"start":{"line":26,"column":2},"end":{"line":26,"column":51}},"12":{"start":{"line":28,"column":2},"end":{"line":28,"column":12}},"13":{"start":{"line":46,"column":4},"end":{"line":46,"column":61}},"14":{"start":{"line":50,"column":0},"end":{"line":50,"column":38}}},"branchMap":{"1":{"line":21,"type":"if","locations":[{"start":{"line":21,"column":2},"end":{"line":21,"column":2}},{"start":{"line":21,"column":2},"end":{"line":21,"column":2}}]}}},"/Users/jeff/Projects/awilix/lib/ExtendableError.js":{"path":"/Users/jeff/Projects/awilix/lib/ExtendableError.js","s":{"1":7,"2":7,"3":7,"4":7,"5":1},"b":{},"f":{"1":7},"fnMap":{"1":{"name":"(anonymous_1)","line":12,"loc":{"start":{"line":12,"column":14},"end":{"line":12,"column":24}}}},"statementMap":{"1":{"start":{"line":13,"column":4},"end":{"line":13,"column":18}},"2":{"start":{"line":16,"column":4},"end":{"line":19,"column":6}},"3":{"start":{"line":21,"column":4},"end":{"line":24,"column":6}},"4":{"start":{"line":26,"column":4},"end":{"line":26,"column":51}},"5":{"start":{"line":30,"column":0},"end":{"line":30,"column":32}}},"branchMap":{}},"/Users/jeff/Projects/awilix/lib/nameValueToObject.js":{"path":"/Users/jeff/Projects/awilix/lib/nameValueToObject.js","s":{"1":1,"2":1,"3":120,"4":120,"5":79,"6":120},"b":{"1":[79,41]},"f":{"1":120},"fnMap":{"1":{"name":"nameValueToObject","line":14,"loc":{"start":{"line":14,"column":17},"end":{"line":14,"column":58}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":1,"column":48}},"2":{"start":{"line":14,"column":0},"end":{"line":21,"column":1}},"3":{"start":{"line":15,"column":2},"end":{"line":15,"column":16}},"4":{"start":{"line":16,"column":2},"end":{"line":18,"column":3}},"5":{"start":{"line":17,"column":4},"end":{"line":17,"column":42}},"6":{"start":{"line":20,"column":2},"end":{"line":20,"column":12}}},"branchMap":{"1":{"line":16,"type":"if","locations":[{"start":{"line":16,"column":2},"end":{"line":16,"column":2}},{"start":{"line":16,"column":2},"end":{"line":16,"column":2}}]}}},"/Users/jeff/Projects/awilix/lib/last.js":{"path":"/Users/jeff/Projects/awilix/lib/last.js","s":{"1":1,"2":102},"b":{},"f":{"1":102},"fnMap":{"1":{"name":"last","line":10,"loc":{"start":{"line":10,"column":17},"end":{"line":10,"column":37}}}},"statementMap":{"1":{"start":{"line":10,"column":0},"end":{"line":12,"column":1}},"2":{"start":{"line":11,"column":2},"end":{"line":11,"column":28}}},"branchMap":{}}} |
@@ -68,3 +68,4 @@ // Type definitions for Awilix v2.2.6 | ||
export interface ContainerOptions { | ||
require?: (id: string) => any | ||
require?: (id: string) => any, | ||
resolutionMode?: ResolutionMode | ||
} | ||
@@ -87,5 +88,16 @@ | ||
transient(): this | ||
proxy(): this | ||
classic(): this | ||
} | ||
/** | ||
* Resolution Modes | ||
* @class ResolutionMode | ||
*/ | ||
export declare class ResolutionMode { | ||
static PROXY: string | ||
static CLASSIC: string | ||
} | ||
/** | ||
* Lifetime management. | ||
@@ -211,2 +223,3 @@ * @class Lifetime | ||
lifetime: Lifetime | ||
resolutionMode: ResolutionMode | ||
} | ||
@@ -220,2 +233,3 @@ | ||
lifetime?: Lifetime | ||
resolutionMode?: ResolutionMode | ||
} |
@@ -6,3 +6,4 @@ // Export the public API. | ||
listModules: require('./listModules'), | ||
Lifetime: require('./Lifetime') | ||
Lifetime: require('./Lifetime'), | ||
ResolutionMode: require('./ResolutionMode') | ||
} | ||
@@ -9,0 +10,0 @@ |
const loadModules = require('./loadModules') | ||
const listModules = require('./listModules') | ||
const { asClass, asFunction, asValue } = require('./registrations') | ||
const ResolutionMode = require('./ResolutionMode') | ||
const AwilixResolutionError = require('./AwilixResolutionError') | ||
@@ -21,2 +22,5 @@ const nameValueToObject = require('./nameValueToObject') | ||
* | ||
* @param {string} options.resolutionMode | ||
* The mode used by the container to resolve dependencies. Defaults to 'Proxy'. | ||
* | ||
* @return {object} | ||
@@ -26,3 +30,5 @@ * The container. | ||
module.exports = function createContainer (options, __parentContainer) { | ||
options = Object.assign({}, options) | ||
options = Object.assign({ | ||
resolutionMode: ResolutionMode.PROXY | ||
}, options) | ||
@@ -45,2 +51,6 @@ // The resolution stack is used to keep track | ||
/** | ||
* Store the options on the container | ||
*/ | ||
options, | ||
/** | ||
* Getter for the rolled up registrations that merges the container family tree. | ||
@@ -159,3 +169,3 @@ * | ||
const obj = nameValueToObject(name, registration) | ||
for (let key in obj) { | ||
for (const key in obj) { | ||
const value = obj[key] | ||
@@ -172,8 +182,15 @@ registrations[key] = value | ||
* Makes a register function. | ||
* | ||
* @param {Function} fn | ||
* The `as*` function to make a register function for. | ||
* | ||
* @param {Boolean} verbatimValue | ||
* The `('name', [value, opts])` is not valid for all register functions. | ||
* When set to true, treat the value as-is, don't check if its an value-opts-array. | ||
*/ | ||
const makeRegister = (fn) => (name, value, opts) => { | ||
const makeRegister = (fn, verbatimValue) => function registerShortcut (name, value, opts) { | ||
// This ensures that we can support name+value style and object style. | ||
const obj = nameValueToObject(name, value) | ||
for (let key in obj) { | ||
for (const key in obj) { | ||
let valueToRegister = obj[key] | ||
@@ -183,3 +200,4 @@ | ||
opts = Object.assign({}, opts) | ||
if (Array.isArray(valueToRegister)) { | ||
if (!verbatimValue && Array.isArray(valueToRegister)) { | ||
// The ('name', [value, opts]) style | ||
@@ -237,3 +255,3 @@ opts = Object.assign({}, opts, valueToRegister[1]) | ||
*/ | ||
container.registerValue = makeRegister(asValue) | ||
container.registerValue = makeRegister(asValue, /* verbatimValue: */ true) | ||
@@ -240,0 +258,0 @@ /** |
@@ -39,9 +39,11 @@ const camelCase = require('camel-case') | ||
module.exports = function loadModules (dependencies, globPatterns, opts) { | ||
const container = dependencies.container | ||
opts = opts || {} | ||
opts = Object.assign({}, { | ||
registrationOptions: { | ||
lifetime: Lifetime.TRANSIENT | ||
} | ||
// Does a somewhat-deep merge on the registration options. | ||
registrationOptions: Object.assign({ | ||
lifetime: Lifetime.TRANSIENT, | ||
resolutionMode: container.options.resolutionMode | ||
}, opts && opts.registrationOptions) | ||
}, opts) | ||
const container = dependencies.container | ||
const modules = dependencies.listModules(globPatterns, opts) | ||
@@ -91,4 +93,2 @@ | ||
const reg = isClass(moduleDescriptor.value) ? registrations.asClass : registrations.asFunction | ||
const lifetime = (opts.registrationOptions && opts.registrationOptions.lifetime) || Lifetime.TRANSIENT | ||
let moduleDescriptorOpts = moduleDescriptor.opts | ||
@@ -100,3 +100,4 @@ | ||
const regOpts = Object.assign({ lifetime: lifetime }, moduleDescriptorOpts) | ||
const reg = isClass(moduleDescriptor.value) ? registrations.asClass : registrations.asFunction | ||
const regOpts = Object.assign({}, opts.registrationOptions, moduleDescriptorOpts) | ||
container.register( | ||
@@ -103,0 +104,0 @@ name, |
@@ -14,3 +14,3 @@ const isPlainObject = require('is-plain-object') | ||
*/ | ||
const nameValueToObject = (name, value) => { | ||
module.exports = function nameValueToObject (name, value) { | ||
let obj = name | ||
@@ -23,3 +23,1 @@ if (!isPlainObject(obj)) { | ||
} | ||
module.exports = nameValueToObject |
const Lifetime = require('./Lifetime') | ||
const ResolutionMode = require('./ResolutionMode') | ||
@@ -37,2 +38,7 @@ /** | ||
const setResolutionMode = (value) => { | ||
obj.resolutionMode = value | ||
return obj | ||
} | ||
return { | ||
@@ -42,3 +48,6 @@ setLifetime, | ||
scoped: () => setLifetime(Lifetime.SCOPED), | ||
singleton: () => setLifetime(Lifetime.SINGLETON) | ||
singleton: () => setLifetime(Lifetime.SINGLETON), | ||
setResolutionMode, | ||
proxy: () => setResolutionMode(ResolutionMode.PROXY), | ||
classic: () => setResolutionMode(ResolutionMode.CLASSIC) | ||
} | ||
@@ -95,8 +104,9 @@ } | ||
const resolve = (container) => fn(container.cradle) | ||
const resolve = generateResolve(fn) | ||
const result = { | ||
resolve, | ||
lifetime: opts.lifetime | ||
lifetime: opts.lifetime, | ||
resolutionMode: opts.resolutionMode | ||
} | ||
result.resolve = resolve.bind(result) | ||
Object.assign(result, makeFluidInterface(result)) | ||
@@ -130,13 +140,88 @@ return result | ||
const resolve = (container) => new Type(container.cradle) | ||
// A function to handle object construction for us, as to make the generateResolve more reusable | ||
const newClass = function () { | ||
return new Type(...arguments) | ||
} | ||
const resolve = generateResolve(newClass, Type.prototype.constructor) | ||
const result = { | ||
resolve, | ||
lifetime: opts.lifetime | ||
lifetime: opts.lifetime, | ||
resolutionMode: opts.resolutionMode | ||
} | ||
result.resolve = resolve.bind(result) | ||
Object.assign(result, makeFluidInterface(result)) | ||
Object.assign(result, makeFluidInterface(result)) | ||
return result | ||
} | ||
/** | ||
* Returns a resolve function used to construct the dependency graph | ||
* | ||
* @this {Registration} | ||
* The `this` context is a registration. | ||
* | ||
* @param {Function} fn | ||
* The function to construct | ||
* | ||
* @param {Function} dependencyParseTarget | ||
* The function to parse for the dependencies of the construction target | ||
* | ||
* @param {boolean} isFunction | ||
* Is the resolution target an actual function or a mask for a constructor? | ||
* | ||
* @return {Function} | ||
* The function used for dependency resolution | ||
*/ | ||
function generateResolve (fn, dependencyParseTarget) { | ||
// If the function used for dependency parsing is falsy, use the supplied function | ||
if (!dependencyParseTarget) { | ||
dependencyParseTarget = fn | ||
} | ||
// Try to resolve the dependencies | ||
const dependencies = parseDependencies(dependencyParseTarget) | ||
// Use a regular function instead of an arrow function to facilitate binding to the registration. | ||
return function resolve (container) { | ||
// Because the container holds a global reolutionMode we need to determine it in the proper order or precedence: | ||
// registration -> container -> default value | ||
const resolutionMode = (this.resolutionMode || container.options.resolutionMode || ResolutionMode.PROXY) | ||
if (resolutionMode !== ResolutionMode.CLASSIC) { | ||
// Just return the target injected with the cradle | ||
return fn(container.cradle) | ||
} | ||
// We have dependencies so we need to resolve them manually | ||
if (dependencies.length > 0) { | ||
const children = [] | ||
dependencies.forEach((d) => children.push(container.resolve(d))) | ||
return fn(...children) | ||
} | ||
return fn() | ||
} | ||
} | ||
/** | ||
* Regex used for parsing dependencies for a function. | ||
*/ | ||
const DEPS_EXPR = /(\(\s*([^)]+?)\s*\)|\(\))/ | ||
/** | ||
* Runs a regex on a function to return dependencies | ||
* | ||
* @param {function} function | ||
* A function to test | ||
* | ||
* @return {Array<string>} | ||
* Returns an array of dependency names | ||
*/ | ||
function parseDependencies (func) { | ||
const args = DEPS_EXPR.exec(func.toString()) | ||
if (args && args[2] && !args[2].includes('{') && !args[2].includes('}')) { | ||
return args[2].split(/\s*,\s*/) | ||
} | ||
return [] | ||
} | ||
module.exports.asClass = asClass |
{ | ||
"name": "awilix", | ||
"version": "2.2.6", | ||
"version": "2.3.0", | ||
"description": "Simple dependency injection container + helper utilities to facilitate wiring of modules", | ||
@@ -37,10 +37,10 @@ "main": "lib/awilix.js", | ||
"devDependencies": { | ||
"@types/chai": "^3.5.1", | ||
"@types/node": "^7.0.14", | ||
"chai": "^3.5.0", | ||
"coveralls": "^2.13.0", | ||
"@types/chai": "^4.0.0", | ||
"@types/node": "^7.0.28", | ||
"chai": "^4.0.2", | ||
"coveralls": "^2.13.1", | ||
"eslint": "^3.19.0", | ||
"eslint-config-standard": "^10.2.1", | ||
"eslint-plugin-import": "^2.2.0", | ||
"eslint-plugin-node": "^4.2.2", | ||
"eslint-plugin-import": "^2.3.0", | ||
"eslint-plugin-node": "^5.0.0", | ||
"eslint-plugin-promise": "^3.5.0", | ||
@@ -50,15 +50,14 @@ "eslint-plugin-standard": "^3.0.1", | ||
"istanbul": "^0.4.5", | ||
"mocha": "^3.3.0", | ||
"mocha-typescript": "^1.1.0", | ||
"sinon": "^2.1.0", | ||
"sinon-chai": "^2.9.0", | ||
"typescript": "^2.2.2" | ||
"mocha": "^3.4.2", | ||
"sinon": "^2.3.2", | ||
"sinon-chai": "^2.10.0", | ||
"typescript": "^2.3.4" | ||
}, | ||
"dependencies": { | ||
"camel-case": "^3.0.0", | ||
"glob": "^7.1.1", | ||
"glob": "^7.1.2", | ||
"is-class": "0.0.4", | ||
"is-plain-object": "^2.0.1", | ||
"is-plain-object": "^2.0.3", | ||
"is-string": "^1.0.4" | ||
} | ||
} |
393
README.md
@@ -15,3 +15,3 @@ # Awilix | ||
Extremely powerful **Inversion of Control** (IoC) container for Node with dependency resolution support powered by ES6 Proxies. Make IoC great again! | ||
Extremely powerful **Inversion of Control** (IoC) container for Node with dependency resolution support powered by `Proxy`. Make IoC great again! | ||
@@ -25,2 +25,3 @@ > Check out this [intro to Dependency Injection with Awilix](https://medium.com/@Jeffijoe/dependency-injection-in-node-js-2016-edition-f2a88efdd427) | ||
* [Lifetime management](#lifetime-management) | ||
* [Resolution modes](#resolution-modes) | ||
* [Auto-loading modules](#auto-loading-modules) | ||
@@ -36,2 +37,3 @@ * [API](#api) | ||
+ [`container.cache`](#containercache) | ||
+ [`container.options`](#containeroptions) | ||
+ [`container.resolve()`](#containerresolve) | ||
@@ -57,3 +59,3 @@ + [`container.registerValue()`](#containerregistervalue) | ||
Awilix has a pretty simple API. At minimum, you need to do 3 things: | ||
Awilix has a pretty simple API (but with many possible ways to invoke it). At minimum, you need to do 3 things: | ||
@@ -67,6 +69,8 @@ * Create a container | ||
```javascript | ||
const awilix = require('awilix'); | ||
const awilix = require('awilix') | ||
// Create the container. | ||
const container = awilix.createContainer(); | ||
// Create the container and set the resolutionMode to PROXY (which is also the default). | ||
const container = awilix.createContainer({ | ||
resolutionMode: awilix.ResolutionMode.PROXY | ||
}) | ||
@@ -80,3 +84,3 @@ // This is our app code... We can use | ||
// Save a reference to our dependency. | ||
this.userService = opts.userService; | ||
this.userService = opts.userService | ||
} | ||
@@ -86,3 +90,3 @@ | ||
getUser(ctx) { | ||
return this.userService.getUser(ctx.params.id); | ||
return this.userService.getUser(ctx.params.id) | ||
} | ||
@@ -95,3 +99,3 @@ } | ||
userController: UserController | ||
}); | ||
}) | ||
@@ -104,6 +108,6 @@ // Let's try with a factory function. | ||
getUser: (id) => { | ||
return db.query(`select * from users where id=${id}`); | ||
return db.query(`select * from users where id=${id}`) | ||
} | ||
}; | ||
}; | ||
} | ||
} | ||
@@ -114,9 +118,13 @@ container.registerFunction({ | ||
userService: makeUserService | ||
}); | ||
}) | ||
// Alright, now we need a database. | ||
// Let's make that a constructor function. | ||
function Database({ connectionString }) { | ||
// Notice how the dependency is referenced by name | ||
// directly instead of destructuring an object. | ||
// This is because we register it in "CLASSIC" | ||
// resolution mode below. | ||
function Database(connectionString, timeout) { | ||
// We can inject plain values as well! | ||
this.conn = connectToYourDatabaseSomehow(connectionString); | ||
this.conn = connectToYourDatabaseSomehow(connectionString, timeout) | ||
} | ||
@@ -126,12 +134,16 @@ | ||
// blah.... | ||
return this.conn.rawSql(sql); | ||
return this.conn.rawSql(sql) | ||
} | ||
// We use registerClass because we want it to be called with `new`. | ||
container.registerClass({ | ||
db: Database | ||
// We use register coupled with asClass to tell Awilix to | ||
// use `new Database(...)` instead of just `Database(...)`. | ||
// We also want to use `CLASSIC` resolution mode for this | ||
// registration. Read more about resolution modes below. | ||
container.register({ | ||
db: awilix.asClass(Database).classic() | ||
}) | ||
// Lastly we register the connection string, | ||
// as we need it in the Database constructor. | ||
// Lastly we register the connection string and timeout values | ||
// as we need them in the Database constructor. | ||
container.registerValue({ | ||
@@ -141,12 +153,12 @@ // We can register things as-is - this is not just | ||
// really - they will be passed through directly. | ||
connectionString: process.env.CONN_STR | ||
}); | ||
connectionString: process.env.CONN_STR, | ||
timeout: 1000 | ||
}) | ||
// We have now wired everything up! | ||
// Let's use it! (use your imagination with the router thing..) | ||
router.get('/api/users/:id', container.resolve('userController').getUser); | ||
router.get('/api/users/:id', container.resolve('userController').getUser) | ||
// Alternatively.. | ||
router.get('/api/users/:id', container.cradle.userController.getUser); | ||
// Alternatively, using the `cradle` proxy.. | ||
router.get('/api/users/:id', container.cradle.userController.getUser) | ||
@@ -157,3 +169,3 @@ // Using `container.cradle.userController` is actually the same as calling | ||
That example looks big, but if you extract things to their proper files, it becomes rather elegant! | ||
That example is rather lengthy, but if you extract things to their proper files it becomes more manageable. | ||
@@ -164,9 +176,9 @@ [Check out a working Koa example!](/examples/koa) | ||
Awilix supports managing the lifetime of registrations. This means that you can control whether objects are resolved and used once, or cached for the lifetime of the process. | ||
Awilix supports managing the lifetime of instances. This means that you can control whether objects are resolved and used once, cached within a certain scope, or cached for the lifetime of the process. | ||
There are 3 lifetime types available. | ||
* `TRANSIENT`: This is the default. The registration is resolved every time it is needed. This means if you resolve a class more than once, you will get back a new instance every time. | ||
* `SCOPED`: The registration is scoped to the container - that means that the resolved value will be reused when resolved from the same scope. | ||
* `SINGLETON`: The registration is always reused no matter what. | ||
* `Lifetime.TRANSIENT`: This is the default. The registration is resolved every time it is needed. This means if you resolve a class more than once, you will get back a new instance every time. | ||
* `Lifetime.SCOPED`: The registration is scoped to the container - that means that the resolved value will be reused when resolved from the same scope. | ||
* `Lifetime.SINGLETON`: The registration is always reused no matter what. | ||
@@ -176,3 +188,3 @@ They are exposed on the `awilix.Lifetime` object. | ||
```js | ||
const Lifetime = awilix.Lifetime; | ||
const Lifetime = awilix.Lifetime | ||
``` | ||
@@ -187,9 +199,9 @@ | ||
mailService: [MailService, { lifetime: Lifetime.SINGLETON }] | ||
}); | ||
}) | ||
// or using the registration functions directly.. | ||
const { asClass, asFunction, asValue } = awilix; | ||
const { asClass, asFunction, asValue } = awilix | ||
container.register({ | ||
mailService: asClass(MailService).lifetime(Lifetime.SINGLETON) | ||
}); | ||
}) | ||
@@ -199,3 +211,3 @@ // or.. | ||
mailService: asClass(MailService).singleton() | ||
}); | ||
}) | ||
@@ -205,5 +217,5 @@ // all roads lead to rome | ||
mailService: asClass(MailService, { lifetime: Lifetime.SINGLETON }) | ||
}); | ||
}) | ||
// seriously.. | ||
container.registerClass('mailService', MailService, { lifetime: SINGLETON }); | ||
container.registerClass('mailService', MailService, { lifetime: SINGLETON }) | ||
``` | ||
@@ -218,12 +230,12 @@ | ||
```js | ||
const { createContainer, asClass, asValue } = awilix; | ||
const container = createContainer(); | ||
const { createContainer, asClass, asValue } = awilix | ||
const container = createContainer() | ||
class MessageService { | ||
constructor({ currentUser }) { | ||
this.user = currentUser; | ||
this.user = currentUser | ||
} | ||
getMessages() { | ||
const id = this.user.id; | ||
const id = this.user.id | ||
// wee! | ||
@@ -235,3 +247,3 @@ } | ||
messageService: asClass(MessageService).scoped() | ||
}); | ||
}) | ||
@@ -241,3 +253,3 @@ // imagine middleware in some web framework.. | ||
// create a scoped container | ||
req.scope = container.createScope(); | ||
req.scope = container.createScope() | ||
@@ -247,14 +259,14 @@ // register some request-specific data.. | ||
currentUser: asValue(req.user) | ||
}); | ||
}) | ||
next(); | ||
}); | ||
next() | ||
}) | ||
app.get('/messages', (req,res) => { | ||
// for each request we get a new message service! | ||
const messageService = req.scope.resolve('messageService'); | ||
const messageService = req.scope.resolve('messageService') | ||
messageService.getMessages().then(messages => { | ||
res.send(200, messages) | ||
}); | ||
}); | ||
}) | ||
}) | ||
@@ -269,6 +281,6 @@ // The message service can now be tested | ||
const makePrintTime = ({ time }) => () => { | ||
console.log('Time:', time); | ||
}; | ||
console.log('Time:', time) | ||
} | ||
const getTime = () => new Date().toString(); | ||
const getTime = () => new Date().toString() | ||
@@ -278,3 +290,3 @@ container.register({ | ||
time: asFunction(getTime).transient() | ||
}); | ||
}) | ||
@@ -289,4 +301,4 @@ // Resolving `time` 2 times will | ||
// `getTime` was invoked when making the singleton. | ||
container.resolve('printTime')(); | ||
container.resolve('printTime')(); | ||
container.resolve('printTime')() | ||
container.resolve('printTime')() | ||
``` | ||
@@ -296,2 +308,118 @@ | ||
# Resolution modes | ||
The resolution mode determines how a function/constructor receives its dependencies. Pre-2.3.0, only one mode was | ||
supported - `PROXY` - which remains the default mode. | ||
Awilix v2.3.0 introduced an alternative resolution mode: `CLASSIC`. The resolution modes are available on `awilix.ResolutionMode` | ||
* `ResolutionMode.PROXY` (default): Injects a proxy to functions/constructors which looks like a regular object. | ||
```js | ||
class UserService { | ||
constructor (opts) { | ||
this.emailService = opts.emailService | ||
this.logger = opts.logger | ||
} | ||
} | ||
``` | ||
or with destructuring: | ||
```js | ||
class UserService { | ||
constructor ({ emailService, logger }) { | ||
this.emailService = emailService | ||
this.logger = logger | ||
} | ||
} | ||
``` | ||
* `ResolutionMode.CLASSIC`: Parses the function/constructor parameters, and matches them with registrations in the container. | ||
```js | ||
class UserService { | ||
constructor (emailService, logger) { | ||
this.emailService = emailService | ||
this.logger = logger | ||
} | ||
} | ||
``` | ||
Resolution modes can be set per-container and per-registration. The most specific one wins. | ||
> Note: I personally don't see why you would want to have different resolution modes in a project, but | ||
> if the need arises, Awilix supports it. | ||
**Container-wide**: | ||
```js | ||
const { createContainer, ResolutionMode } = require('awilix') | ||
const container = createContainer({ resolutionMode: ResolutionMode.CLASSIC }) | ||
``` | ||
**Per registration**: | ||
```js | ||
const container = createContainer() | ||
container.register({ | ||
logger: asClass(Logger).classic(), | ||
// or.. | ||
emailService: asFunction(makeEmailService).proxy() | ||
// or.. | ||
notificationService: asClass(NotificationService).setResolutionMode(ResolutionMode.CLASSIC) | ||
}) | ||
// or.. | ||
container.registerClass({ | ||
logger: [Logger, { resolutionMode: ResolutionMode.CLASSIC }] | ||
}) | ||
``` | ||
**For auto-loading modules**: | ||
```js | ||
const container = createContainer() | ||
container.loadModules([ | ||
'services/**/*.js', | ||
'repositories/**/*.js' | ||
], { | ||
registrationOptions: { | ||
resolutionMode: ResolutionMode.CLASSIC | ||
} | ||
}) | ||
``` | ||
Choose whichever fits your style. | ||
* `PROXY` _technically_ allows you to defer pulling dependencies (for circular dependency support), but **this isn't recommended**. | ||
* `CLASSIC` feels more like the DI you're used to in other languages. | ||
* `PROXY` is more descriptive, and makes for more readable tests; when unit testing your classes/functions without using Awilix, you don't have to worry about parameter ordering like you would with `CLASSIC`. | ||
Here's an example outlining the testability points raised. | ||
```js | ||
// CLASSIC | ||
function database (connectionString, timeout, logger) { | ||
// ... | ||
} | ||
// Shorter, but less readable, order-sensitive | ||
const db = database('localhost:1337;user=123...', 4000, new LoggerMock()) | ||
// PROXY | ||
function database ({ connectionString, timeout, logger }) { | ||
// ... | ||
} | ||
// Longer, more readable, order does not matter | ||
const db = database({ | ||
logger: new LoggerMock(), | ||
timeout: 4000, | ||
connectionString: 'localhost:1337;user=123...' | ||
}) | ||
``` | ||
# Auto-loading modules | ||
@@ -314,5 +442,5 @@ | ||
```js | ||
const awilix = require('awilix'); | ||
const awilix = require('awilix') | ||
const container = awilix.createContainer(); | ||
const container = awilix.createContainer() | ||
@@ -335,6 +463,6 @@ // Load our modules! | ||
} | ||
}); | ||
}) | ||
// We are now ready! We now have a userService, userRepository and emailService! | ||
container.resolve('userService').getUser(1); | ||
container.resolve('userService').getUser(1) | ||
``` | ||
@@ -354,3 +482,4 @@ | ||
* `asClass` | ||
* `Lifetime` - this one is documented above. | ||
* `Lifetime` - documented above. | ||
* `ResolutionMode` - documented above. | ||
@@ -367,2 +496,5 @@ These are documented below. | ||
- `options.require`: The function to use when requiring modules. Defaults to `require`. Useful when using something like [`require-stack`](https://npmjs.org/package/require-stack). Optional. | ||
- `options.resolutionMode`: Determines the method for resolving dependencies. Valid modes are: | ||
- `PROXY`: Uses the `awilix` default dependency resolution mechanism (I.E. injects the cradle into the function or class). This is the default resolution mode. | ||
- `CLASSIC`: Uses the named dependency resolution mechanism. Dependencies ___must___ be named exactly like they are in the registration. For example, a dependency registered as `repository` cannot be referenced in a class constructor as `repo`. | ||
@@ -389,9 +521,9 @@ ## `listModules()` | ||
```js | ||
const listModules = require('awilix').listModules; | ||
const listModules = require('awilix').listModules | ||
const result = listModules([ | ||
'services/*.js' | ||
]); | ||
]) | ||
console.log(result); | ||
console.log(result) | ||
// << [{ name: 'someService', path: 'path/to/services/someService.js' }] | ||
@@ -426,7 +558,11 @@ ``` | ||
### `container.options` | ||
Options passed to `createContainer` are stored here. | ||
```js | ||
let counter = 1; | ||
let counter = 1 | ||
container.register({ | ||
count: asFunction(() => counter++).singleton() | ||
}); | ||
}) | ||
@@ -436,3 +572,3 @@ container.cradle.count === 1 | ||
delete container.cache.count; | ||
delete container.cache.count | ||
container.cradle.count === 2 | ||
@@ -448,3 +584,3 @@ ``` | ||
leet: () => 1337 | ||
}); | ||
}) | ||
@@ -463,4 +599,4 @@ container.resolve('leet') === 1337 | ||
```js | ||
const awilix = require('awilix'); | ||
const { asValue, asFunction, asClass } = awilix; | ||
const awilix = require('awilix') | ||
const { asValue, asFunction, asClass } = awilix | ||
``` | ||
@@ -478,5 +614,5 @@ | ||
// name-value-options | ||
container.register('connectionString', asValue('localhost:1433;user=...')); | ||
container.register('mailService', asFunction(makeMailService), { lifetime: Lifetime.SINGLETON }); | ||
container.register('context', asClass(SessionContext), { lifetime: Lifetime.SCOPED }); | ||
container.register('connectionString', asValue('localhost:1433;user=...')) | ||
container.register('mailService', asFunction(makeMailService), { lifetime: Lifetime.SINGLETON }) | ||
container.register('context', asClass(SessionContext), { lifetime: Lifetime.SCOPED }) | ||
@@ -507,7 +643,7 @@ // object | ||
db: myDatabaseObject | ||
}); | ||
}) | ||
// Alternative syntax: | ||
container.registerValue('someName', 'some value'); | ||
container.registerValue('db', myDatabaseObject); | ||
container.registerValue('someName', 'some value') | ||
container.registerValue('db', myDatabaseObject) | ||
@@ -517,3 +653,3 @@ // Chaining | ||
.registerValue('someName', 'some value') | ||
.registerValue('db', myDatabaseObject); | ||
.registerValue('db', myDatabaseObject) | ||
``` | ||
@@ -532,6 +668,6 @@ | ||
`${new Date().toISOString()}: Hello, this is ${someName}` | ||
); | ||
) | ||
container.registerFunction({ fullString: myFactoryFunction }); | ||
console.log(container.cradle.fullString); | ||
container.registerFunction({ fullString: myFactoryFunction }) | ||
console.log(container.cradle.fullString) | ||
// << 2016-06-24T16:00:00.00Z: Hello, this is some value | ||
@@ -541,3 +677,3 @@ | ||
setTimeout(() => { | ||
console.log(container.cradle.fullString); | ||
console.log(container.cradle.fullString) | ||
// << 2016-06-24T16:00:02.00Z: Hello, this is some value | ||
@@ -547,12 +683,12 @@ | ||
// factory function was called again! | ||
}, 2000); | ||
}, 2000) | ||
// Let's try this again, but we want it to be | ||
// cached! | ||
const Lifetime = awilix.Lifetime; | ||
const Lifetime = awilix.Lifetime | ||
container.registerFunction({ | ||
fullString: [myFactoryFunction, { lifetime: Lifetime.SINGLETON }] | ||
}); | ||
}) | ||
console.log(container.cradle.fullString); | ||
console.log(container.cradle.fullString) | ||
// << 2016-06-24T16:00:02.00Z: Hello, this is some value | ||
@@ -562,3 +698,3 @@ | ||
setTimeout(() => { | ||
console.log(container.cradle.fullString); | ||
console.log(container.cradle.fullString) | ||
// << 2016-06-24T16:00:02.00Z: Hello, this is some value | ||
@@ -568,3 +704,3 @@ | ||
// the factory function's result was cached. | ||
}, 2000); | ||
}, 2000) | ||
``` | ||
@@ -581,7 +717,7 @@ | ||
constructor({ fullString }) { | ||
this.fullString = fullString; | ||
this.fullString = fullString | ||
} | ||
exclaim() { | ||
return this.fullString + '!!!!!'; | ||
return this.fullString + '!!!!!' | ||
} | ||
@@ -592,3 +728,3 @@ } | ||
exclaimer: Exclaimer | ||
}); | ||
}) | ||
@@ -598,5 +734,5 @@ // or.. | ||
exclaimer: [Exclaimer, { lifetime: Lifetime.SINGLETON }] | ||
}); | ||
}) | ||
container.cradle.exclaimer.exclaim(); | ||
container.cradle.exclaimer.exclaim() | ||
// << 2016-06-24T17:00:00.00Z: Hello, this is some value!!!!! | ||
@@ -613,10 +749,10 @@ ``` | ||
// Increments the counter every time it is resolved. | ||
let counter = 1; | ||
let counter = 1 | ||
container.register({ | ||
counterValue: asFunction(() => counter++).scoped() | ||
}); | ||
const scope1 = container.createScope(); | ||
const scope2 = container.createScope(); | ||
}) | ||
const scope1 = container.createScope() | ||
const scope2 = container.createScope() | ||
const scope1Child = scope1.createScope(); | ||
const scope1Child = scope1.createScope() | ||
@@ -634,8 +770,8 @@ scope1.cradle.counterValue === 1 | ||
```js | ||
let counter = 1; | ||
let counter = 1 | ||
container.register({ | ||
counterValue: asFunction(() => counter++).scoped() | ||
}); | ||
const scope1 = container.createScope(); | ||
const scope2 = container.createScope(); | ||
}) | ||
const scope1 = container.createScope() | ||
const scope2 = container.createScope() | ||
@@ -659,11 +795,11 @@ container.cradle.counterValue === 1 | ||
scopedValue: asFunction((cradle) => 'Hello ' + cradle.someValue) | ||
}); | ||
}) | ||
// Create a scope and register a value. | ||
const scope = container.createScope(); | ||
const scope = container.createScope() | ||
scope.register({ | ||
someValue: asValue('scope') | ||
}); | ||
}) | ||
scope.cradle.scopedValue === 'Hello scope'; | ||
scope.cradle.scopedValue === 'Hello scope' | ||
container.cradle.someValue | ||
@@ -681,3 +817,3 @@ // throws AwilixResolutionException | ||
// in it's parent. | ||
const scope = container.createScope(); | ||
const scope = container.createScope() | ||
@@ -687,7 +823,7 @@ container.register({ | ||
usedValue: asFunction((cradle) => cradle.value) | ||
}); | ||
}) | ||
scope.register({ | ||
value: asValue('scope') | ||
}); | ||
}) | ||
@@ -710,3 +846,3 @@ container.cradle.usedValue === 'root' | ||
* `opts.cwd`: The `cwd` being passed to `glob`. Defaults to `process.cwd()`. | ||
* `opts.formatName`: Can be either `'camelCase'`, or a function that takes the current name as the first parameter and returns the new name. Default is to pass the name through as-is. | ||
* `opts.formatName`: Can be either `'camelCase'`, or a function that takes the current name as the first parameter and returns the new name. Default is to pass the name through as-is. The 2nd parameter is a full module descriptor. | ||
* `registrationOptions`: An `object` passed to the registrations. Used to configure the lifetime of the loaded modules. | ||
@@ -724,3 +860,3 @@ | ||
container.cradle.userService.getUser(123); | ||
container.cradle.userService.getUser(123) | ||
@@ -736,5 +872,5 @@ // to configure lifetime for all modules loaded.. | ||
} | ||
}); | ||
}) | ||
container.cradle.userService.getUser(123); | ||
container.cradle.userService.getUser(123) | ||
@@ -750,5 +886,32 @@ // to configure lifetime for specific globs.. | ||
} | ||
}); | ||
}) | ||
container.cradle.userService.getUser(123); | ||
container.cradle.userService.getUser(123) | ||
// to use camelCase for modules where filenames are not camelCase | ||
container.loadModules([ | ||
'repositories/account-repository.js', | ||
'db/db.js' | ||
], { | ||
formatName: 'camelCase' | ||
}) | ||
container.cradle.accountRepository.getUser(123) | ||
// to customize how modules are named in the container (and for injection) | ||
container.loadModules([ | ||
'repository/account.js', | ||
'service/email.js' | ||
], { | ||
// This formats the module name so `repository/account.js` becomes `accountRepository` | ||
formatName: (name, descriptor) => { | ||
const splat = descriptor.path.split('/') | ||
const namespace = splat[splat.length - 2] // `repository` or `service` | ||
const upperNamespace = namespace.charAt(0).toUpperCase() + namespace.substring(1) | ||
return name + upperNamespace | ||
} | ||
}) | ||
container.cradle.accountRepository.getUser(123) | ||
container.cradle.emailService.sendEmail('test@test.com', 'waddup') | ||
``` | ||
@@ -762,3 +925,3 @@ | ||
For code coverage, run `npm run coverage`. | ||
For code coverage, run `npm run cover`. | ||
@@ -765,0 +928,0 @@ If you submit a PR, please aim for 100% code coverage and no linting errors. |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
325637
16
47
1559
882
Updatedglob@^7.1.2
Updatedis-plain-object@^2.0.3