{"_id":"@ayana/di","_rev":"3-60bbf12083c6ee55ac526fc055b353fb","name":"@ayana/di","dist-tags":{"latest":"1.0.0-alpha.2"},"versions":{"1.0.0-alpha.1":{"name":"@ayana/di","version":"1.0.0-alpha.1","description":"Dependency Injection for Bento, libraries and more","repository":{"type":"git","url":"https://gitlab.com/ayana/libs/di"},"author":{"name":"Ayana Developers","email":"devs@ayana.io"},"contributors":[{"name":"HcgRandon","email":"me@randon.moe"},{"name":"TheAkio","email":"me@theak.io"}],"main":"build/index.js","types":"build/index.d.ts","scripts":{"build":"ayc build","prepublishOnly":"ayc clean build","test":"ayt test","cover":"ayt coverage"},"dependencies":{"@ayana/errors":"^1.0.1","reflect-metadata":"^0.1.13"},"devDependencies":{"@ayana/test":"^2.1.0","@ayana/ts":"^1.0.1","@types/node":"^12.6.8","tslint":"^5.18.0","typescript":"^3.5.3"},"license":"MIT","private":false,"licenseText":"MIT License\n\nCopyright (c) 2019 Ayana Developers <devs@ayana.io>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@ayana/di@1.0.0-alpha.1","dist":{"shasum":"84097e8f1f2f1a102ce755a71648063da6d78bc0","integrity":"sha512-O64YY2Qr+zZrhrC/GBr9o1KXDySK/tn7lYsioA6R2ay37qd1sqeuWsPontAshyChvAtK3eVgpFiHn7SRAMh0CA==","tarball":"https://registry.npmjs.org/@ayana/di/-/di-1.0.0-alpha.1.tgz","fileCount":71,"unpackedSize":71776,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdM1eTCRA9TVsSAnZWagAAzAoP/1ppNIDQ8nzTlo3Y7Jma\nIbO8ccWiOpo4/xex3vZzU8TTV5UAa0ncjL4FlwaJ4JGrnHWLQyco8TfhkzYS\nobw/IHaNj8C2cdErSuRDg9RUsqwSzcJOCmXC2BB6XRbG/h2KMGmsUTcx96iF\n4Vl4ePPZv0kw3cooabvtZm/NaJozvYxhXtU4LC9m/HrudEJfaK9p1wdFLN6P\nPqOaQu1XpqQKMrfQBB9fbTUzIQmoKpxqRkMsLmw1kjzl4xEnzpwNH76b6PUI\nxlNU3P/iOrTYIjKnIinCyl+Rdx0G4t985OFNBHARd/JZvI2Q0DeFvwVS82ff\n4lP18eBroyAawv3Hdo6DRWQ1cX3pwjJPYDaVOnuIep8pfsiKnjHkKcN8Wi5q\nlBfwkFjBl5W0prNscor3MAXpCVpCYboeq4XloZd53v5yA9lk1D9YVXaDFHt4\naUgMtBJcXTU9bpmzcwPH9IzWQrYxb4bU62Tw5r3xCNNpod/QFCckt45KZfWq\n/Gnkog7Obr1WoRAKX5wEDKUuecYT/dPx143epKUwqI7tRlOSYeBroa/Eox09\nhnIVWmVuVKhYO//l7ETvmVVtE8u9mqXJnN9LspJLpWen0Ur1QeE3NQxGTBHz\nq6Qsv6Ngu68x12hO4G3rWIQXn0vywRK54lyUgO2kucKjwLk4sIBD/pTeP9iP\nuT25\r\n=hP69\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIFJEvqKLoPO5QHi9ndYEy0bXGkHyV6coZTKKzWpmnUG1AiBUem5wxkyc9V14OZKwwfmZ+N6GwIWne/vS7iRH3Bc/wg=="}]},"maintainers":[{"name":"hcgrandon","email":"me@randon.moe"},{"name":"akio","email":"me@theak.io"}],"_npmUser":{"name":"akio","email":"me@theak.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/di_1.0.0-alpha.1_1563645842831_0.393869214146636"},"_hasShrinkwrap":false},"1.0.0-alpha.2":{"name":"@ayana/di","version":"1.0.0-alpha.2","description":"Dependency Injection for Bento, libraries and more","repository":{"type":"git","url":"https://gitlab.com/ayana/libs/di"},"author":{"name":"Ayana Developers","email":"devs@ayana.io"},"contributors":[{"name":"HcgRandon","email":"me@randon.moe"},{"name":"TheAkio","email":"me@theak.io"}],"main":"build/index.js","types":"build/index.d.ts","scripts":{"build":"ayc build","prepublishOnly":"ayc clean build","test":"ayt test","cover":"ayt coverage"},"dependencies":{"@ayana/errors":"^1.0.1","reflect-metadata":"^0.1.13"},"devDependencies":{"@ayana/test":"^2.1.0","@ayana/ts":"^1.1.0","@types/node":"^12.7.2","tslint":"^5.18.0","typescript":"^3.5.3"},"license":"MIT","private":false,"licenseText":"MIT License\n\nCopyright (c) 2019 Ayana Developers <devs@ayana.io>\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@ayana/di@1.0.0-alpha.2","dist":{"shasum":"5f37de5ef563609411f1894e1de026292479b296","integrity":"sha512-anDU9HsRQFfTB6X3dTsilhSHq+n+KgZjp7rkjd+FHIzWfDWMGnlFuPS86P0CIPSUIoUpKW7UQ6JugTWlHdLG/A==","tarball":"https://registry.npmjs.org/@ayana/di/-/di-1.0.0-alpha.2.tgz","fileCount":71,"unpackedSize":84030,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdWv55CRA9TVsSAnZWagAA9zcP/jG+hfleoye1JbOdjyze\nU9tAoRI8yflT0RwwgwpADeiUIskMbDSlL/znFXySHMV0UvVuRMQ4kUCUvW13\nggLFWIFIEfbwJlUNW75cBiZ5M4E5aVMhAvr0o5Mh72M+m/XndZ/YN/16ZTAZ\nWH5+05HKN0CijoEPMcthVvEpaEcUrqAlbXtskHh+qLV1qEP2EmClFFc9pgmf\niJ0tXT3o+yiE5NWM+1G9ciDgBHgF2jsb3bNUrWJD6qjjniEUqicOrSC1MKgz\niP+5f7kMKnMuqYMcLCfJXXzqJxkEOpqHFdppkLI6zVjAvpAwqfl8e42q1H+v\n3K0fkzRfqdQdKYSQqxE1ddQMQQltiKj3ABYT15Gz2IS+y1i3JAduOwW2uwji\nPHFBrrBAjDplFfbNLNT6OiVJcWiWLu1MVnDFJ875gdel1Sd575cVaqU87xMz\niH7yXwhWv8t+cYfyYhbb20FG1d6XH+T4hBp/VmvwVWm+HUf8Ba5henNQIxqb\nxqUbsIMjYSHXzrAKfu93bCIvMNpbwsGqbVcEpNjCd6Af/IBIVRzFvONTqLZ3\nEUkIz2Z7Huw4Bp9cjuHCNc3nbzfM3JL73RPv0Oq/PFPzF5YmOufaxkjPHC8+\ncmXad5rz8nTk0UHE7y/qZ/iX/202ypTGiJb3AemgZA7fWRKC+dIhLuFgBIHU\n8BKf\r\n=uAzm\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDbgVWUAGXOex4d1WJzt48aNeS/CtUAKHx02hF3f7i57wIhAIAxjToaJGvGmDX/WiufpzsXqlKudU8Nxs9PitVc6sGS"}]},"maintainers":[{"name":"akio","email":"me@theak.io"},{"name":"hcgrandon","email":"me@randon.moe"}],"_npmUser":{"name":"akio","email":"me@theak.io"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/di_1.0.0-alpha.2_1566244472143_0.40491599533307787"},"_hasShrinkwrap":false}},"time":{"created":"2019-07-20T18:04:02.831Z","1.0.0-alpha.1":"2019-07-20T18:04:03.001Z","modified":"2022-04-04T17:14:10.101Z","1.0.0-alpha.2":"2019-08-19T19:54:32.406Z"},"maintainers":[{"email":"cloudmaster@game.tv","name":"cloudmaster"},{"email":"me@randon.moe","name":"hcgrandon"},{"email":"me@theak.io","name":"akio"}],"description":"Dependency Injection for Bento, libraries and more","repository":{"type":"git","url":"https://gitlab.com/ayana/libs/di"},"contributors":[{"name":"HcgRandon","email":"me@randon.moe"},{"name":"TheAkio","email":"me@theak.io"}],"author":{"name":"Ayana Developers","email":"devs@ayana.io"},"license":"MIT","readme":"@ayana/di [![NPM](https://img.shields.io/npm/v/@ayana/di.svg)](https://www.npmjs.com/package/@ayana/di) [![Discord](https://discordapp.com/api/guilds/508903834853310474/embed.png)](https://discord.gg/eaa5pYf) [![Install size](https://packagephobia.now.sh/badge?p=@ayana/di)](https://packagephobia.now.sh/result?p=@ayana/di)\n===\n\n[Documentation](https://docs.ayana.io/modules/di.html)\n\nDependency Injection for Bento, libraries and more\n\nWhat this is\n---\n\nIn a nutshell, this package provides you with a fancy way of linking objects together called \"Dependency Injection\" (DI). The goal of this package is to make DI portable so it can be used inside libraries too and not only applications.\nThis library was heavily inspired by [Angular's](https://github.com/angular/angular) way of doing DI so some terms may sound familiar.\n\nInstallation\n---\n\nWith NPM\n\n```\nnpm i @ayana/di\n```\n\nWith Yarn\n\n```\nyarn add @ayana/di\n```\n\nUsage\n---\n\nSoon™ (Meanwhile, there are some examples inside the Injector.spec.ts file and inside the @ayana/test README)\n\nReading \"Circular dependency\" errors\n---\n\nThose errors might seem a bit cryptic at first, but they are actually pretty simple to understand.\n\nThe basic message structure looks somewhat like this:\n\n```\nCircular dependency detected: Injectable1 <=C= Injectable2 <=P= Injectable3(M) <=?= Injectable1\n```\n\nThe names between the arrows represent a stringified version of the Token that you and `@ayana/di` use as a key to an injectable.\nThe first and last dependency in such a chain are always the same because we're dealing with a circular dependency chain here.\nIf there's an `(M)` after the stringified Token, that indicates that the dependency is a multi dependency.\n\nThe arrows point form right to left so you can read each arrow as `injects` i.e. `Injectable1 injects Injectable2`, `Injectable2 injects Injectable3` and so on.\nIf you would read it from right to left it would become `is injected into` i.e. `Injectable2 is injected into Injectable1` and so on.\n\nThe letter in the arrow represents the way the injection was done. There are currently 4 characters that can appear here:\n\n|Letter|Explaination|\n|------|------------|\n|C|The dependency was injected via constructor. This is likely the cause of issues with circular dependencies. Read the troubleshooting section for more information| \n|E|The dependency was referenced by the `ExistingProvider` to the left of the arrow. This is usually not the cause of an issue|\n|P|The dependency was injected via property|\n|?|It is unknown how the injection was done, but a dependency was declared. This should only appear when using custom injectors|\n\nLet's break some examples down:\n\n```\nCircular constructor dependency detected: C <=P= B <=C= A <=P= C\n```\n\nThe text `Circular constructor dependency` already tells us that we are injecting something circularly with at least one constructor injection.\nIf we read the error out we get `C injects B, B injects A, A injects C`. We also see a `<=C=` between `B` and `A` which already tells us that one issue is there. When looking at the other arrows we only have `<=P=` which means they are likely not involved in this specific error.\n\nIn this case we need to remove the constructor injection inside `B` and replace it with a property injection, or remove it completely.\n\n```\nCircular existing dependency detected: A <=E= B <=E= A\n```\n\nThe text `Circular existing dependency` already tells us that we are circularly referencing `ExistingProvider`s.\nWhen we read the error out we get `A injects B, B injects A`. The `<=E=` tells us that it is a reference by an `ExistingProvider`.\n\nIn this case we need to remove either the existing provider `A` or `B` and replace it with a \"real\" provider.\n\n```\nCircular multi dependency detected: A(M) <=P= B(M) <=P= A(M)\n```\n\nThe text `Circular multi dependency` already tells us that we are circularly referencing providers declared as multi.\nWhen we read the error out we get `A injects B, B injects A`. The `(M)` tells us that it is a multi dependency.\n\nIn this case we need to either mark `A` or `B` as non-multi, or remove the dependency from one to the other.\n\nTroubleshooting\n---\n\n### I'm getting the error \"Circular constructor/multi/existing dependency detected\"\n\nThis could be due to 2 reasons:\n\n1. The option `allowCircularDependencies` was set to `false`, meaning no circular dependencies at all are allowed, so you have to either enable that option or get rid of the circular dependency\n2. You attempted to make a circular dependency in a way that is not supported by `@ayana/di`, like making a circular dependency chain only consisting of multi or existing dependencies, or making a circular dependency chain that consists of at least one constructor injection.\n\nThe error is usually pretty informative so you can figure out the problem yourself after checking out the guide about how to read those errors.\nIf you still need help however, you can join our [Discord Server](https://discord.gg/eaa5pYf).\n\nTesting with [@ayana/test](https://www.npmjs.com/package/@ayana/test)\n---\n\nSee the [README of the @ayana/test module](https://www.npmjs.com/package/@ayana/test#testing-with-ayanadi) for more information about how to test software that uses @ayana/di.\n\nLinks\n---\n\n[GitLab repository](https://gitlab.com/ayana/libs/di)\n\n[NPM package](https://npmjs.com/package/@ayana/di)\n\nLicense\n---\n\nRefer to the [LICENSE](LICENSE) file.\n","readmeFilename":"README.md"}