{"name":"power-di","version":"1.4.9","keywords":["di","ts","ioc","react"],"author":{"name":"zhang740"},"license":"MIT","_id":"power-di@1.4.9","maintainers":[{"name":"zhang740","email":"zhang740@vmzclub.com"}],"homepage":"https://github.com/zhang740/power-di#readme","bugs":{"url":"https://github.com/zhang740/power-di/issues"},"ava":{"files":["test/*.js"]},"dist":{"shasum":"542b09ef38cb91e43523bd21c5d68d9e3180ee9a","tarball":"http://registry-npm.ywwl.com/power-di/download/power-di-1.4.9.tgz","fileCount":64,"integrity":"sha512-LBQzh1Or/mD36JE9MdeOnNnQxJaOuFrjbhlZWIZEpcv5u5BSh/bQHPbiWgrwfxIpX1xYusmSyz7y3CfLst7ofQ==","signatures":[{"sig":"MEUCIAt1y1g/6sIGPvYCvQXOysb3jx8PT9dKCk2XoKcD7GwtAiEAm9Q6wC7vjifOG/+gDzSdXCKGeQWKE6N7XOt5tDYHUKo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":60825,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJa4YMcCRA9TVsSAnZWagAAFeIP/1CWSVzWz6KE+S5c8b4v\n+kL/HXiZDW1g4OSGYZKNdzfEwpVtpfDpSqHtDKnbUbtUsP3bX5vR+zY7WO0D\n8swnlrBrakd5F9uGu3c4YRe5pZwGosXXs/XbqdbLJdv0sHhlxHw+ya2Ufr8O\noNbLfabgpDkHEiBAAodggzqXvKBNxtk5CT6LQEluiaI8L/u6pWrO6gnjjkuo\nor8RttEWQj0JMSjWtZix7IUe7/IxIMF91yT6opq+m4bIHGCNh8CffZr3H1Wj\nwM3hEdXDxxWXGhGstl8MBq5/0nXcf/Usgr+FsnqgF/0GV1GxZcP+2uvE1BKn\noi6eHAEgY+/g24IQIA4qqmRN7mZajCchCfHOUdwjLxw/p1+3W2iFYXs40tT+\n9B6w3uRjSlGGpIFoTTequ4OsEI2j8qqznFB2CFBSD82egNGmxracf0PvbXjx\ntoz2tgpwODY0IMtL40Ap0fZv2u9UdozuCzVHc7aEBUPA8o2HzDT1HE73sS3Y\ncAv+VWdJ8T6jfHgrSQ2WLtvehWmNIdaTWuUyqdt+DOZb8fAlRETTtDk6XlXW\n/kMSAyucfQORTKmN+xMrcA1U89F1xV/Uc2k/Nah6whnFeIZrq2hC6LbWH3H2\nF54H2KLAQYuS5/RSdJlbCxzpHCmlmPsSbh2i1nPRQIFfM6EQgBBwntozba+O\nRNRX\r\n=Ewx4\r\n-----END PGP SIGNATURE-----\r\n","size":13109,"noattachment":false,"key":"/power-di/-/power-di-1.4.9.tgz"},"main":"./lib/index.js","files":["utils.js","utils.d.ts","helper.js","helper.d.ts","react.js","react.d.ts","lib/**/*.js","**/*.d.ts","dist"],"gitHead":"c6a75d891217fa8c6bd1b8c3e8428f1c241f35d8","scripts":{"es":"rimraf -- es && tsc -p tsconfig.es.json","test":"rimraf -- test/**/*.js && tsc && ava -v -s && npm run rmjsmap","babel":"babel lib --out-dir lib","clean":"rimraf -- dist lib/**/*.js lib/**/*.js.map lib/**/*.d.ts","report":"npm run coverage && npm run coverage:report","rmjsmap":"rimraf -- **/*.js.map ./*.js.map test/*.js.map scripts/*.js.map","coverage":"nyc npm test","reinstall":"rimraf -- node_modules && npm install","test:prod":"tsc && npm run test && npm run babel","build:dist":"webpack --progress","prepublish":"npm run clean && npm run test:prod","postpublish":"node scripts/published.js","coverage:report":"nyc report --reporter=lcov","coverage:upload":"cat ./coverage/lcov.info | coveralls"},"typings":"./lib/index.d.ts","_npmUser":{"name":"zhang740","email":"zhang740@vmzclub.com"},"repository":{"url":"git+https://github.com/zhang740/power-di.git","type":"git"},"_npmVersion":"5.7.1","description":"A lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.","directories":{},"_nodeVersion":"8.7.0","dependencies":{"reflect-metadata":"^0.1.12"},"_hasShrinkwrap":false,"devDependencies":{"ava":"^0.21.0","nyc":"^11.1.0","react":"^15.6.1","rimraf":"^2.6.1","tslint":"5.5.0","webpack":"^3.6.0","babel-cli":"^6.24.1","coveralls":"^2.13.1","babel-core":"^6.25.0","typescript":"2.4.2","@types/node":"^9.4.7","@types/react":"^15.6.0","babel-loader":"^7.1.1","babel-preset-env":"^1.6.0","reflect-metadata":"^0.1.12","babel-preset-react":"^6.24.1","babel-preset-es2015":"^6.24.1","react-test-renderer":"^15.6.1","babel-preset-stage-0":"^6.24.1","babel-preset-stage-1":"^6.24.1","@types/react-test-renderer":"^15.5.2"},"_npmOperationalInternal":{"tmp":"tmp/power-di_1.4.9_1524728603804_0.8709875598438568","host":"s3://npm-registry-packages"},"readme":"# Power DI\n\n[![CI](https://img.shields.io/travis/zhang740/power-di.svg?style=flat-square)](https://travis-ci.org/zhang740/power-di)\n[![Coverage](https://img.shields.io/coveralls/zhang740/power-di.svg?style=flat-square)](https://coveralls.io/github/zhang740/power-di)\n[![Version](https://img.shields.io/npm/v/power-di.svg?style=flat-square)](https://www.npmjs.com/package/power-di)\n[![License](https://img.shields.io/npm/l/power-di.svg?style=flat-square)](https://github.com/zhang740/power-di/blob/master/LICENSE)\n\nA lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.\n\n## Install\n```shell\nnpm i power-di --save\n```\n\n## Example\n\n### a simple example\n```ts\nimport { IocContext } from 'power-di';\n\nclass AService { }\n\n// default instance, you can also new IocContext to get a instance.\nconst context = IocContext.DefaultInstance;\ncontext.register(AService);\nconst aService = context.get(AService); // a instance of AService\n```\n\n### inject with key\n```ts\nclass AService { }\n\nconst context = IocContext.DefaultInstance;\ncontext.register(AService, 'XService'); // key need a string or class, e.g super class or whatever class.\ncontext.get('XService');\n```\n\n### use with decorators\n```ts\nconst context = new IocContext();\n\n@injectable()\nclass NRService { }\n\n@injectable()\nclass LITestService {\n  @inject()\n  public testService: NRService;\n}\n\nconst test = context.get(LITestService);\n```\n\n### collect impl or extends of some interface/base class\n```ts\nclass A { }\n\n@classInfo()\nclass B extends A { }\n\n@classInfo()\nclass C extends A { }\n\n@injectable()\nclass LITestService {\n  @imports({ type: A })\n  public testService: A[];\n}\n\nconst test = context.get(LITestService); // test.testService as A[];\n```\n\n### use in react\n```tsx\nconst context = new IocContext;\nclass NRService { }\ncontext.register(NRService);\n\nclass TestComponent extends Component<{}, {}> {\n  @inject()\n  service: NRService;\n\n  componentDidMount() {\n    t.true(this.service instanceof NRService);\n  }\n\n  render(): any {\n    return null;\n  }\n}\n\ncreate(\n  <IocProvider context={context}>\n    <TestComponent />\n  </IocProvider>\n);\n```\n\n## Class Loader\nPower DI introduced the concept of class loader. We can customize the find rule of ioc.\n\n#### [See the test case for details.](https://github.com/zhang740/power-di/tree/master/test)\n","publish_time":1524728604030,"_cnpm_publish_time":1524728604030,"dist-tags":{"alpha":"3.0.0-alpha.0","latest":"2.4.57"}}