{"name":"power-di","version":"2.4.41","description":"A lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.","main":"./lib/index.js","typings":"./lib/index.d.ts","scripts":{"clean":"rm -rf es && rimraf -- dist lib/**/*.js lib/**/*.js.map lib/**/*.d.ts","rmjsmap":"rimraf -- **/*.js.map ./*.js.map test/*.js.map scripts/*.js.map","babel":"babel lib --out-dir lib","build:dist":"webpack --progress","test":"rimraf -- test/**/*.js && tsc && ava -v -s && npm run rmjsmap","test:prod":"npm run clean && tsc && npm run test","coverage":"nyc npm test","coverage:report":"nyc report --reporter=lcov","coverage:upload":"cat ./coverage/lcov.info | coveralls","report":"npm run coverage && npm run coverage:report","reinstall":"rimraf -- node_modules && npm install","prepublishOnly":"npm run test:prod && npm run clean && npm run es5","postpublish":"node scripts/published.js","es5":"rimraf -- es && tsc -p tsconfig.es5.json","es":"rimraf -- es && tsc -p tsconfig.es.json"},"ava":{"files":["test/*.js"]},"repository":{"type":"git","url":"git+https://github.com/zhang740/power-di.git"},"author":{"name":"zhang740"},"license":"MIT","bugs":{"url":"https://github.com/zhang740/power-di/issues"},"homepage":"https://github.com/zhang740/power-di#readme","keywords":["di","ts","ioc","react"],"peerDependencies":{"reflect-metadata":">=0.1.12"},"devDependencies":{"@babel/cli":"^7.0.0","@babel/core":"^7.0.0","@babel/preset-env":"^7.3.4","@types/co":"^4.6.2","@types/node":"^11.9.5","@types/react":"^16.x","@types/react-test-renderer":"^16.x","ava":"^3.7.1","co":"^4.6.0","coveralls":"^3.1.0","husky":"^7.0.4","lint-staged":"^12.1.2","nyc":"^15.0.1","prettier":"^2.5.1","react":"^16.x","react-test-renderer":"^16.x","rimraf":"^3.0.2","tslint":"5.13.0","typescript":"~5.0","webpack":"^4.29.5"},"husky":{"hooks":{"pre-commit":"lint-staged --allow-empty"}},"lint-staged":{"*.{js,ts,tsx,less}":["prettier --write"]},"_id":"power-di@2.4.41","gitHead":"3e3efb5e2b56dc4e9955bc06f665cdc707e9c61e","_nodeVersion":"22.4.1","_npmVersion":"10.8.1","dist":{"integrity":"sha512-66gqN3Iler86Fy5bBRD1MC37YzabaC/s3zR1fuOqsUgnO7mmR+RvRF04bcGoEV2TwWD0I/GOuUXEu7AR/khUUA==","shasum":"d890df0435b7bb8c9c1a0bee527883183c88b771","tarball":"http://registry-npm.ywwl.com/power-di/download/power-di-2.4.41.tgz","fileCount":127,"unpackedSize":245670,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDlzVkEFEZrtHoytxW0xG48kj57GW6XYQiRdqv93KFkggIgeyi4nQsmw2TfhDDABd8A3B7qtN6GHvbKMSmeFLjzsnQ="}],"size":45573,"noattachment":false,"key":"/power-di/-/power-di-2.4.41.tgz"},"_npmUser":{"name":"zhang740","email":"zhang740@vmzclub.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/power-di_2.4.41_1723516582847_0.18869891261483462"},"_hasShrinkwrap":false,"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":1723516582998,"maintainers":[{"name":"zhang740","email":"zhang740@vmzclub.com"}],"_cnpm_publish_time":1723516582998,"dist-tags":{"alpha":"3.0.0-alpha.0","latest":"2.4.57"}}