{"name":"power-di","version":"2.4.18","keywords":["di","ts","ioc","react"],"author":{"name":"zhang740"},"license":"MIT","_id":"power-di@2.4.18","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":"47dfe83f1adfe9981fc2fed005ad1a9e8aa50850","tarball":"http://registry-npm.ywwl.com/power-di/download/power-di-2.4.18.tgz","fileCount":81,"integrity":"sha512-Ob42P3HE9aPFAxRnowl0I4SpYPD4AA5ssWSjE4niYH4u19i452pkHlnYW5i59+YubODP5OU+C6eguUwtKalZsA==","signatures":[{"sig":"MEYCIQCykP2dO+fhAI3SYkSyx9dF0SAp9pFaAfKw/rDZjQQ1QwIhAPxh82CBro+APYEr1GZNi4dq/sq1jyqPyGpfFQ7CDP46","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":103855,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiEvTrACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrQ7Q/8DYmIjHApnWIpc9ardByAIdHYVQfL3k2D9DAiLSdjRAtDqMEo\r\nST57ECraL6cED79ExrXvEQKBYwcNZbtrpeatFvUO1UmlL9e3uGLydiqBJPrz\r\n2fRKyalYzfxGWXgSij9hP2Od4qgwKJYicllVyk0MDKnZkbDiQu275vlHN6QB\r\nUU9AuUBQ2yvgC+qKFA0fJViOE295wT23GZH8+QxVqJ6owmlSQNDJXlcLIrnM\r\nsMlcCOl1IAjdlwXhySCa7WGzJBXRByW6aIN1b9IawTahLJBIfyA/eHFiXBTS\r\nvjPaHwDX0YM6xi/R4hgl/ldOdX2n1+Ej8uOAac1jU4XHGnGKEoD0mz5xTqBm\r\niCIOj83GaF9PbPmJcCcwxJI9pqsEv8BWtHN5TGmcSFS7vaL27NrKCX90C68a\r\noi1QKhdFeCUvs7Mx/+cpGAeLjYgYtUSd4+u10NKxkQRprZ7tgBwAn/AdnIvd\r\nLWEbM9QmkxwFosZeFrpYUReAkDNTNAFWGEyHxeT/Hl3/3/AQ+2bIGbGaHBB3\r\nJ12Z5AXCYMLvoH66jj+NrYNztV/Mtt/tIfTK2FVu7sfB4CJPp3iBPgBKT87i\r\niE0HLbz/NQ93IynCBI4TMgBebKMTazpghwyV2M8bLBxt62LHNV9P0N4feTp9\r\nSXBn6YahD5qgF9fpwhZ0jvRb5HQeLGgh0nE=\r\n=vq2k\r\n-----END PGP SIGNATURE-----\r\n","size":22977,"noattachment":false,"key":"/power-di/-/power-di-2.4.18.tgz"},"main":"./lib/index.js","husky":{"hooks":{"pre-commit":"lint-staged --allow-empty"}},"gitHead":"3539671dbe20554bc8768b23f69fe84255fde724","scripts":{"es":"rimraf -- es && tsc -p tsconfig.es.json","es5":"rimraf -- es && tsc -p tsconfig.es5.json","test":"rimraf -- test/**/*.js && tsc && ava -v -s && npm run rmjsmap","babel":"babel lib --out-dir lib","clean":"rm -rf es && 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":"npm run clean && tsc && npm run test","build:dist":"webpack --progress","prepublish":"npm run test:prod && npm run clean && npm run es5","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":"6.14.9","description":"A lightweight Dependency Injection library. Using es6 and other features, remove unnecessary concepts, easy and convenient to use.","directories":{},"lint-staged":{"*.{js,ts,tsx,less}":["prettier --write"]},"_nodeVersion":"14.15.3","dependencies":{"reflect-metadata":"^0.1.12"},"_hasShrinkwrap":false,"devDependencies":{"co":"^4.6.0","ava":"^3.7.1","nyc":"^15.0.1","husky":"^7.0.4","react":"^16.x","rimraf":"^3.0.2","tslint":"5.13.0","webpack":"^4.29.5","prettier":"^2.5.1","@types/co":"^4.6.2","coveralls":"^3.1.0","@babel/cli":"^7.0.0","typescript":"^3","@babel/core":"^7.0.0","@types/node":"^11.9.5","lint-staged":"^12.1.2","@types/react":"^16.x","@babel/preset-env":"^7.3.4","react-test-renderer":"^16.x","@types/react-test-renderer":"^16.x"},"_npmOperationalInternal":{"tmp":"tmp/power-di_2.4.18_1645409515709_0.6464707843344457","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":1645409515891,"_cnpm_publish_time":1645409515891,"dist-tags":{"alpha":"3.0.0-alpha.0","latest":"2.4.57"}}