{"_id":"@aedart/js-ioc","_rev":"11-5140af78dc20410202e0030eb0b62357","name":"@aedart/js-ioc","description":"IoC Service Container","dist-tags":{"latest":"1.2.2"},"versions":{"0.9.0":{"name":"@aedart/js-ioc","version":"0.9.0","description":"IoC Service Container","main":"index.js","scripts":{"test":"karma start karma.conf.js"},"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"keywords":["ioc","service","container"],"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"homepage":"https://github.com/aedart/js-ioc#readme","dependencies":{"@aedart/js-meta":"^1.0.0"},"devDependencies":{"babel-plugin-external-helpers":"^6.18.0","babel-plugin-transform-builtin-extend":"^1.1.0","babel-preset-es2015-rollup":"^1.2.0","faker":"^3.1.0","jasmine":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.0.2","karma-phantomjs-launcher":"^1.0.2","karma-rollup-plugin":"^0.2.4","karma-spec-reporter":"0.0.26","rollup":"^0.36.3","rollup-plugin-babel":"^2.6.1","rollup-plugin-buble":"^0.14.0","rollup-plugin-commonjs":"^5.0.5","rollup-plugin-eslint":"^3.0.0","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-node-globals":"^1.0.9","rollup-plugin-node-resolve":"^2.0.0","rollup-plugin-replace":"^1.1.1","rollup-plugin-uglify":"^1.0.1","uglify-js-harmony":"^2.6.2"},"gitHead":"f6bd6024d467e14f175d9cdfa0a3458d9b706a4f","_id":"@aedart/js-ioc@0.9.0","_shasum":"cd4b914f724c1d3ee984cbcfcc6cc64b2557e4dd","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"aedart","email":"aedart@gmail.com"},"dist":{"shasum":"cd4b914f724c1d3ee984cbcfcc6cc64b2557e4dd","tarball":"https://registry.npmjs.org/@aedart/js-ioc/-/js-ioc-0.9.0.tgz","integrity":"sha512-MUTF1KsMMCW3YR005R4YNF25CwGo5F/+ZcCnJJsal6p6+BY5RimwcZx0Q21nuRUetREeFecwZ6q3Xf2R3U2bvw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIA1IZ2WSuEstKD/fPw3Qlcs/oS2Ha6h25cjy9Lv/nEqQAiAxZ3DAdPZUuYiiqUkd8O7uitOAB5Sx3294isvwteflIw=="}]},"maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/js-ioc-0.9.0.tgz_1477749031219_0.35717590036801994"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.0.0":{"name":"@aedart/js-ioc","version":"1.0.0","description":"IoC Service Container","main":"index.js","scripts":{"test":"karma start karma.conf.js"},"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"keywords":["ioc","service","container"],"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"homepage":"https://github.com/aedart/js-ioc#readme","dependencies":{"@aedart/js-meta":"^1.0.0"},"devDependencies":{"babel-plugin-external-helpers":"^6.18.0","babel-plugin-transform-builtin-extend":"^1.1.0","babel-preset-es2015-rollup":"^1.2.0","faker":"^3.1.0","jasmine":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.0.2","karma-phantomjs-launcher":"^1.0.2","karma-rollup-plugin":"^0.2.4","karma-spec-reporter":"0.0.26","rollup":"^0.36.3","rollup-plugin-babel":"^2.6.1","rollup-plugin-buble":"^0.14.0","rollup-plugin-commonjs":"^5.0.5","rollup-plugin-eslint":"^3.0.0","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-node-globals":"^1.0.9","rollup-plugin-node-resolve":"^2.0.0","rollup-plugin-replace":"^1.1.1","rollup-plugin-uglify":"^1.0.1","uglify-js-harmony":"^2.6.2"},"gitHead":"f88e78a1db1f6f802301b9c798d15b5cf42f704f","_id":"@aedart/js-ioc@1.0.0","_shasum":"510f25aef9ddde2d6ee6c705eba6620a14656052","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"aedart","email":"aedart@gmail.com"},"dist":{"shasum":"510f25aef9ddde2d6ee6c705eba6620a14656052","tarball":"https://registry.npmjs.org/@aedart/js-ioc/-/js-ioc-1.0.0.tgz","integrity":"sha512-oT4RJ4GaVahZ6RyLECbw58phcXINCtRa116El/VTNoIjypWR7EZ+kdFsYQqrN7bU+8N0wEPcHyGBCQWfQriPgw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGH7DgW/Te29vXnwnEBBC4g4tRUmGc6PS8kYkZqeN3ksAiAzvdiJJt1q30N9j1HLxyO4eOF4OeJUr+VBokn8QuEMPQ=="}]},"maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/js-ioc-1.0.0.tgz_1478947967308_0.26395341381430626"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.0.1":{"name":"@aedart/js-ioc","version":"1.0.1","description":"IoC Service Container","main":"index.js","scripts":{"test":"karma start karma.conf.js"},"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"keywords":["ioc","service","container"],"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"homepage":"https://github.com/aedart/js-ioc#readme","dependencies":{"@aedart/js-meta":"^1.0.0"},"devDependencies":{"babel-plugin-external-helpers":"^6.18.0","babel-plugin-transform-builtin-extend":"^1.1.0","babel-preset-es2015-rollup":"^1.2.0","faker":"^3.1.0","jasmine":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.0.2","karma-phantomjs-launcher":"^1.0.2","karma-rollup-plugin":"^0.2.4","karma-spec-reporter":"0.0.26","rollup":"^0.36.3","rollup-plugin-babel":"^2.6.1","rollup-plugin-buble":"^0.14.0","rollup-plugin-commonjs":"^5.0.5","rollup-plugin-eslint":"^3.0.0","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-node-globals":"^1.0.9","rollup-plugin-node-resolve":"^2.0.0","rollup-plugin-replace":"^1.1.1","rollup-plugin-uglify":"^1.0.1","uglify-js-harmony":"^2.6.2"},"gitHead":"ef8ecc34816d44bf678170acdbb8e9c178662d11","_id":"@aedart/js-ioc@1.0.1","_shasum":"7a3af6c974f414edc2db8ffe72368a39affb7724","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"aedart","email":"aedart@gmail.com"},"dist":{"shasum":"7a3af6c974f414edc2db8ffe72368a39affb7724","tarball":"https://registry.npmjs.org/@aedart/js-ioc/-/js-ioc-1.0.1.tgz","integrity":"sha512-VeXlujcyfgfqAr9dWRfSy9ff/RXjk91bf+6flDKqpN4eVKQwC8Dfd/1PqSOGMPejMiw5J9B3KALmIgKFhion0A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIEELeGg/ZrY4pAh3/0OY0dqRP0QukiY++maINEnT/v7IAiAru0d4JNSr3xXV/njdE69GNp0ohG64mO0ozEXBBWR5Qw=="}]},"maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/js-ioc-1.0.1.tgz_1478948069194_0.4055855479091406"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.1.0":{"name":"@aedart/js-ioc","version":"1.1.0","description":"IoC Service Container","main":"index.js","scripts":{"test":"karma start karma.conf.js"},"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"keywords":["ioc","service","container"],"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"homepage":"https://github.com/aedart/js-ioc#readme","dependencies":{"@aedart/js-meta":"^1.0.0"},"devDependencies":{"babel-plugin-external-helpers":"^6.18.0","babel-plugin-transform-builtin-extend":"^1.1.0","babel-preset-es2015-rollup":"^1.2.0","faker":"^3.1.0","jasmine":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.0.2","karma-phantomjs-launcher":"^1.0.2","karma-rollup-plugin":"^0.2.4","karma-spec-reporter":"0.0.26","rollup":"^0.36.3","rollup-plugin-babel":"^2.6.1","rollup-plugin-buble":"^0.14.0","rollup-plugin-commonjs":"^5.0.5","rollup-plugin-eslint":"^3.0.0","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-node-globals":"^1.0.9","rollup-plugin-node-resolve":"^2.0.0","rollup-plugin-replace":"^1.1.1","rollup-plugin-uglify":"^1.0.1","uglify-js-harmony":"^2.6.2"},"gitHead":"b7b198fc715436cb3fd0da568b3c5bf8d085ade9","_id":"@aedart/js-ioc@1.1.0","_shasum":"a4aff5b1039ef8c1e30f7728572763fd8fb2f862","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"aedart","email":"aedart@gmail.com"},"dist":{"shasum":"a4aff5b1039ef8c1e30f7728572763fd8fb2f862","tarball":"https://registry.npmjs.org/@aedart/js-ioc/-/js-ioc-1.1.0.tgz","integrity":"sha512-56Qu0Pp04djx8jiQZRtoGEjfPG/o8y5OBQ5h3OYiFL/DBxQQY0bFfgCmfI+1+nZQ50iVDcHIGYryyGRPovs1Xw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDLanBjOTKu/XoO8HDh3SQgMUjb6V9BHo2K0fLfs6X5ggIhANHLkOmDb2bZfMDLXSxyy/DOFFG6KEDE32csO8cN0g7v"}]},"maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/js-ioc-1.1.0.tgz_1483876580155_0.4404027049895376"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.2.0":{"name":"@aedart/js-ioc","version":"1.2.0","description":"IoC Service Container","main":"index.js","scripts":{"test":"karma start karma.conf.js"},"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"keywords":["ioc","service","container"],"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"homepage":"https://github.com/aedart/js-ioc#readme","dependencies":{"@aedart/js-meta":"^1.3.1"},"devDependencies":{"babel-plugin-external-helpers":"^6.18.0","babel-plugin-transform-builtin-extend":"^1.1.0","babel-preset-es2015-rollup":"^1.2.0","faker":"^3.1.0","jasmine":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.0.2","karma-phantomjs-launcher":"^1.0.2","karma-rollup-plugin":"^0.2.4","karma-spec-reporter":"0.0.26","rollup":"^0.36.3","rollup-plugin-babel":"^2.6.1","rollup-plugin-buble":"^0.14.0","rollup-plugin-commonjs":"^5.0.5","rollup-plugin-eslint":"^3.0.0","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-node-globals":"^1.0.9","rollup-plugin-node-resolve":"^2.0.0","rollup-plugin-replace":"^1.1.1","rollup-plugin-uglify":"^1.0.1","uglify-js-harmony":"^2.6.2"},"gitHead":"1fe0c7e94c05e2c31b6d6394d858dfa33263b34f","_id":"@aedart/js-ioc@1.2.0","_shasum":"e33ebcfa54500ceb2f32c459e08aac9eab311528","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"aedart","email":"aedart@gmail.com"},"dist":{"shasum":"e33ebcfa54500ceb2f32c459e08aac9eab311528","tarball":"https://registry.npmjs.org/@aedart/js-ioc/-/js-ioc-1.2.0.tgz","integrity":"sha512-uzlZ8VqdRUEcmLjMv5CUBennK1RZRddZXENEdtU8u73MhXZo/HNcuE5JLS5e6s4jqNigcOdshbq4WiQRWehMeg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDOTs+Z9Zd/90rJayPgF5HuU51VodrAOMo7b7lM8FqXWwIhAK05MXNgEeeb/kFfse135f5UNs9XKJtS/nnE7408CUyW"}]},"maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/js-ioc-1.2.0.tgz_1496668928419_0.604343150742352"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.2.1":{"name":"@aedart/js-ioc","version":"1.2.1","description":"IoC Service Container","main":"index.js","scripts":{"test":"karma start karma.conf.js"},"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"keywords":["ioc","service","container"],"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"homepage":"https://github.com/aedart/js-ioc#readme","dependencies":{"@aedart/js-meta":"^1.3.2"},"devDependencies":{"babel-plugin-external-helpers":"^6.18.0","babel-plugin-transform-builtin-extend":"^1.1.0","babel-preset-es2015-rollup":"^1.2.0","faker":"^3.1.0","jasmine":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.0.2","karma-phantomjs-launcher":"^1.0.2","karma-rollup-plugin":"^0.2.4","karma-spec-reporter":"0.0.26","rollup":"^0.36.3","rollup-plugin-babel":"^2.6.1","rollup-plugin-buble":"^0.14.0","rollup-plugin-commonjs":"^5.0.5","rollup-plugin-eslint":"^3.0.0","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-node-globals":"^1.0.9","rollup-plugin-node-resolve":"^2.0.0","rollup-plugin-replace":"^1.1.1","rollup-plugin-uglify":"^1.0.1","uglify-js-harmony":"^2.6.2"},"gitHead":"94a98341838821a967fe584b2296453740242d7d","_id":"@aedart/js-ioc@1.2.1","_npmVersion":"5.0.3","_nodeVersion":"6.10.3","_npmUser":{"name":"aedart","email":"aedart@gmail.com"},"dist":{"integrity":"sha512-eKdqTbU0MxGj4bxja02PhCE68z6QJhDljYUSO59AbJHS3hIOXJd8avlfmAXb/uWAJ2z6rhpHA0br/Ar1LHkgZg==","shasum":"bd3c2568e6968fac52d980222e3ca35d9ea86045","tarball":"https://registry.npmjs.org/@aedart/js-ioc/-/js-ioc-1.2.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDBF2kJDwR0rWQ+roSt6aYRUiOJsibYqiL5P0SnNO3vcAIgRea1/s49vrTXe85us+nvbXPPGkufyHtRJtYl3lHq1ps="}]},"maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/js-ioc-1.2.1.tgz_1496818168548_0.7871278638485819"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."},"1.2.2":{"name":"@aedart/js-ioc","version":"1.2.2","description":"IoC Service Container","main":"index.js","scripts":{"test":"karma start karma.conf.js"},"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"keywords":["ioc","service","container"],"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"license":"BSD-3-Clause","bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"homepage":"https://github.com/aedart/js-ioc#readme","dependencies":{"@aedart/js-meta":"^1.3.2"},"devDependencies":{"babel-plugin-external-helpers":"^6.18.0","babel-plugin-transform-builtin-extend":"^1.1.0","babel-preset-es2015-rollup":"^1.2.0","faker":"^3.1.0","jasmine":"^2.5.2","karma":"^1.3.0","karma-chrome-launcher":"^2.0.0","karma-firefox-launcher":"^1.0.0","karma-ie-launcher":"^1.0.0","karma-jasmine":"^1.0.2","karma-phantomjs-launcher":"^1.0.2","karma-rollup-plugin":"^0.2.4","karma-spec-reporter":"0.0.26","rollup":"^0.36.3","rollup-plugin-babel":"^2.6.1","rollup-plugin-buble":"^0.14.0","rollup-plugin-commonjs":"^5.0.5","rollup-plugin-eslint":"^3.0.0","rollup-plugin-node-builtins":"^2.0.0","rollup-plugin-node-globals":"^1.0.9","rollup-plugin-node-resolve":"^2.0.0","rollup-plugin-replace":"^1.1.1","rollup-plugin-uglify":"^1.0.1","uglify-js-harmony":"^2.6.2"},"gitHead":"7662437b64b05d4a10431df91159684adfd88795","_id":"@aedart/js-ioc@1.2.2","_shasum":"0a9f97760b9e442fcff011347e055b2334794fb3","_from":".","_npmVersion":"3.10.8","_nodeVersion":"6.8.1","_npmUser":{"name":"aedart","email":"aedart@gmail.com"},"dist":{"shasum":"0a9f97760b9e442fcff011347e055b2334794fb3","tarball":"https://registry.npmjs.org/@aedart/js-ioc/-/js-ioc-1.2.2.tgz","integrity":"sha512-RSDLQ7p7g38bmIJesxp0M89ZmRJayNlTOLVujldEFWRtVnJiHiDq7t41qZWy6nx6bsMs4Qcixyk5tuvRzIi/Ug==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIBAHWhakRQ2Jh6mL1i5sorLUqMiEiNaD/TegTiDIlsDfAiEAymgqGrZ0y46qg5XcC+DSt74/W7ItczN5LAvKCfUKBM4="}]},"maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/js-ioc-1.2.2.tgz_1504338120711_0.7371663386002183"},"directories":{},"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info."}},"readme":"# Js IoC\r\n\r\n[Inverse of Control](https://en.wikipedia.org/wiki/Inversion_of_control) (IoC) Service Container for ES6.\r\n\r\nBefore you continue reading, you should know that this package is heavily inspired by [Taylor Otwell's](https://github.com/taylorotwell) [Service Container](https://laravel.com/docs/master/container) in [Laravel](https://laravel.com/).\r\nPlease go read the documentation, to gain a better understanding of what a Service Container is and how they are intended to work... and please do support Laravel!\r\n\r\n**Limitations**\r\n\r\nBecause this is JavaScript, you will not have the same capabilities as a PHP version of the IoC, due to the \"poor\" support of [Reflections](https://en.wikipedia.org/wiki/Reflection_(computer_programming)).\r\n\r\n## Contents\r\n\r\n* [How to install](#how-to-install)\r\n* [Import the IoC](#import-the-ioc)\r\n* [Bindings](#bindings)\r\n  * [Bind to a callback](#bind-to-a-callback)\r\n  * [Bind to an instance](#bind-to-an-instance)\r\n  * [Bind singletons](#bind-singletons)\r\n  * [Aliases](#aliases)\r\n* [Resolving nested dependencies](#resolving-nested-dependencies)\r\n* [Delete Bindings](#delete-bindings)\r\n* [Contribution](#contribution)\r\n* [Acknowledgement](#acknowledgement)\r\n* [Versioning](#versioning)\r\n* [License](#license)\r\n\r\n## How to install\r\n\r\n```console\r\nnpm install @aedart/js-ioc\r\n```\r\n\r\n## Import the IoC\r\n\r\nThe IoC is exported as a [singleton](https://en.wikipedia.org/wiki/Singleton_pattern) instance, which means that you only have to import and then you can start using it straight away.\r\n\r\n```javascript\r\nimport IoC from '@aedart/js-ioc';\r\n```\r\n\r\n## Bindings\r\n\r\nThe basic principle behind an IoC is that you \"bind\" a resource to the container. This allows you to resolve it (to fetch it) at some later point in your application.   \r\n\r\nIn other words, think of a binding as a [factory method](https://en.wikipedia.org/wiki/Factory_method_pattern).\r\n\r\n### Bind to a callback\r\n\r\n**Simple binding**\r\n\r\n```javascript\r\nimport IoC from '@aedart/js-ioc';\r\n\r\n// Your class\r\nclass Box {\r\n    // ... implementation not shown .../\r\n}\r\n\r\n// Bind \"my-box\" to a callback\r\nIoC.bind('my-box', () => {\r\n    return new Box();\r\n});\r\n\r\n// Later in your application, you can resolve \"my-box\"\r\nlet box = IoC.make('my-box'); // Resolves to Box\r\n```\r\n\r\n**Binding with arguments**\r\n\r\n```javascript\r\nimport IoC from '@aedart/js-ioc';\r\n\r\n// Your class\r\nclass Box {\r\n    // ... implementation not shown .../\r\n}\r\n\r\n// Bind \"my-box\" to a callback\r\nIoC.bind('my-box', (ioc, params) => {\r\n    return new Box(params.width, params.height);\r\n});\r\n\r\n// Later in your application, you can resolve \"my-box\"\r\nlet box = IoC.make('my-box', {width:50, height:60}); // Resolves to Box\r\n```\r\n\r\n### Bind to an instance\r\n\r\nIn this context, an instance is an object that can be \"newed up\" - e.g. a class that will be initialised.\r\n\r\n```javascript\r\n// Bind instance\r\nIoC.bindInstance('my-box', Box);\r\n\r\n// Later... resolve \"my-box\" - will return \"new Box\"\r\nlet box = IoC.make('my-box');\r\n```\r\n\r\n**Arguments**\r\n\r\nYou can also pass in arguments for the constructor, via the `make` method.\r\n\r\n```javascript\r\n// Bind instance\r\nIoC.bindInstance('my-box', Box);\r\n\r\n// Later... resolve \"my-box\" - will return \"new Box\"\r\nlet box = IoC.make('my-box', {width:50, height:60});\r\n```\r\n\r\n### Bind singletons\r\n\r\n**Via callback**\r\n\r\n```javascript\r\n// Bind as a singleton\r\nIoC.singleton('my-box', (ioc, params)=>{\r\n    return new Box();\r\n});\r\n\r\n// Later in your application...\r\nlet boxA = IoC.make('my-box');\r\nlet boxB = IoC.make('my-box');\r\n\r\nconsole.log(boxA === boxB); // true\r\n```\r\n\r\n**Via instance**\r\n\r\n```javascript\r\n// Bind as a singleton\r\nIoC.singletonInstance('my-box', Box);\r\n\r\n// Later in your application...\r\nlet boxA = IoC.make('my-box');\r\nlet boxB = IoC.make('my-box');\r\n\r\nconsole.log(boxA === boxB); // true\r\n```\r\n\r\n**Set instance directly**\r\n\r\nIt is also possible for you to set an instance directly, via the `instances` property.\r\n\r\n```javascript\r\n// Your class\r\nclass Box {\r\n    // ... implementation not shown .../\r\n}\r\n\r\nlet box = new Box();\r\nIoC.instances.set('my-box', box);\r\n\r\n// Later ...\r\nlet myBox = IoC.make('my-box');\r\n```\r\n\r\n### Aliases\r\n\r\nOnce you have bound a resource, you can also assign an alias for it. This can be useful in situations where your resource needs to be resolved / obtained via different identifiers.\r\n\r\n```javascript\r\n// Binding first\r\nIoC.bind('my-box', (ioc, params) => {\r\n    // ... not shown .../\r\n});\r\n\r\n// Alias\r\nIoC.alias('my-box', 'largeBox');\r\n\r\n// Later...\r\nlet largeBox = IoC.make('largeBox');\r\n```\r\n\r\n## Resolving nested dependencies\r\n\r\nTo the extend of my knowledge, one cannot gain insight of what object or \"scalar\" types are expected by a class or method, using plain JavaScript.\r\nTherefore, in order to resolve nested dependencies, this Service Container makes use of [\"mata data\"](https://github.com/aedart/js-meta), which can be assigned to any class or object.\r\n\r\nIn the following example, image that you have a class has a dependency. There are several ways that you can resolve it.\r\nHowever, if you need the IoC to resolve that dependency automatically, then you need to provide a bit more information when binding.\r\n\r\n```javascript\r\n// Class A\r\nclass DimensionsCalculator {\r\n    // ... implementation not shown ... //\r\n}\r\n\r\n// Class B\r\nclass Box {\r\n\r\n    /**\r\n     * @param {DimensionsCalculator} calculator\r\n     */\r\n    constructor(calculator){\r\n        this.calculator = calculator;\r\n    }\r\n    \r\n    // ... remaining not shown ... //\r\n}\r\n\r\n// Bind the calculator via callback (just as an example)\r\nIoC.bind('calculator', (ioc, params) => {\r\n    return new DimensionsCalculator();\r\n});\r\n\r\n// Bind the Box class - specify it's expected dependencies\r\nIoC.bindInstance('my-box', Box, false, [\r\n    '@ref:calculator'       // '@ref:' prefix MUST be present!\r\n]);\r\n\r\n// Later...\r\nlet box = IoC.make('my-box');\r\n\r\nconsole.log(box.calculator); // DimensionsCalculator{}\r\n```\r\n\r\nBasically, any class or object that has \"meta data\" defined, with dependencies (`@ref:` prefixed), the IoC will attempt to resolve those dependencies.\r\n \r\nFor more information, please review the source code and the [\"mata data\"](https://github.com/aedart/js-meta) package.\r\n\r\n## Delete Bindings\r\n\r\nSometimes it can be useful to remove (delete) bindings again. This is especially true, when you are writing various executable tests.\r\n\r\n**Remove a single binding**\r\n```javascript\r\nIoC.forget('my-box');\r\n```\r\n\r\n**Remove ALL bindings**\r\n```javascript\r\nIoC.flush();\r\n```\r\n\r\n-------------------------------------------------------------------------------\r\n## Contribution\r\n\r\nHave you found a defect ( [bug or design flaw](https://en.wikipedia.org/wiki/Software_bug) ), or do you wish improvements? In the following sections, you might find some useful information\r\non how you can help this project. In any case, I thank you for taking the time to help me improve this project's deliverables and overall quality.\r\n\r\n### Bug Report\r\n\r\nIf you are convinced that you have found a bug, then at the very least you should create a new issue. In that given issue, you should as a minimum describe the following;\r\n\r\n* Where is the defect located\r\n* A good, short and precise description of the defect (Why is it a defect)\r\n* How to replicate the defect\r\n* (_A possible solution for how to resolve the defect_)\r\n\r\nWhen time permits it, I will review your issue and take action upon it.\r\n\r\n### Fork, code and send pull-request\r\n\r\nA good and well written bug report can help me a lot. Nevertheless, if you can or wish to resolve the defect by yourself, here is how you can do so;\r\n\r\n* Fork this project\r\n* Create a new local development branch for the given defect-fix\r\n* Write your code / changes\r\n* Create executable test-cases (prove that your changes are solid!)\r\n* Commit and push your changes to your fork-repository\r\n* Send a pull-request with your changes\r\n* _Drink a [Beer](https://en.wikipedia.org/wiki/Beer) - you earned it_ :)\r\n\r\nAs soon as I receive the pull-request (_and have time for it_), I will review your changes and merge them into this project. If not, I will inform you why I choose not to.\r\n\r\n## Acknowledgement\r\n\r\n* [Taylor Otwell](https://github.com/taylorotwell),  for his [Service Container](https://laravel.com/docs/master/container), that I'm using daily\r\n\r\n## Versioning\r\n\r\nThis package follows [Semantic Versioning 2.0.0](http://semver.org/)\r\n\r\n## License\r\n\r\n[BSD-3-Clause](http://spdx.org/licenses/BSD-3-Clause), Read the LICENSE file included in this package","maintainers":[{"name":"aedart","email":"aedart@gmail.com"}],"time":{"modified":"2023-02-16T11:36:39.280Z","created":"2016-10-29T13:50:33.327Z","0.9.0":"2016-10-29T13:50:33.327Z","1.0.0":"2016-11-12T10:52:49.584Z","1.0.1":"2016-11-12T10:54:29.793Z","1.1.0":"2017-01-08T11:56:22.019Z","1.2.0":"2017-06-05T13:22:09.512Z","1.2.1":"2017-06-07T06:49:29.571Z","1.2.2":"2017-09-02T07:42:01.858Z"},"homepage":"https://github.com/aedart/js-ioc#readme","keywords":["ioc","service","container"],"repository":{"type":"git","url":"git+https://github.com/aedart/js-ioc.git"},"author":{"name":"Alin Eugen Deac","email":"aedart@gmail.com","url":"https://github.com/aedart"},"bugs":{"url":"https://github.com/aedart/js-ioc/issues"},"license":"BSD-3-Clause","readmeFilename":"README.md"}