Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

injection-js

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

injection-js - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

5

package.json
{
"name": "injection-js",
"version": "1.0.0",
"version": "1.0.1",
"description": "Dependency Injection library for JavaScript and TypeScript",

@@ -10,5 +10,2 @@ "main": "injection.bundle.js",

"dependencies": {},
"peerDependencies": {
"reflect-metadata": "^0.1.9"
},
"keywords": [

@@ -15,0 +12,0 @@ "DI",

34

README.md
# Dependency Injection
Extraction of the Angular's Dependency Injection which allows you to use it outside of the framework.
Dependency injection library for JavaScript and TypeScript in **6.6K**. It is extraction of the Angular's dependency injection which means that it's feature complete, reliable and well tested.
# How to use?
```
$ npm i injection-js --save
```
Note that for ES5 `Class` syntax and TypeScript you need a polyfill for the [Reflect API](http://www.ecma-international.org/ecma-262/6.0/#sec-reflection). You can use, for instance, [reflect-metadata](https://www.npmjs.com/package/reflect-metadata), or [`core-js` (`core-js/es7/reflect`)](https://www.npmjs.com/package/core-js).
## TypeScript

@@ -25,3 +31,3 @@

injector.get(Service);
console.log(injector.get(Service) instanceof Service);
```

@@ -33,3 +39,3 @@

require('reflect-metadata');
var di = require('../dist');
var di = require('injection-js');

@@ -51,2 +57,24 @@ var Http = di.Class({

## ES6
```js
const { Inject, ReflectiveInjector } = require('injection-js');
class Http {}
class Service {
static get parameters() {
return [[new Inject(Http)]];
}
constructor(http) {
this.http = http;
}
}
const injector = ReflectiveInjector.resolveAndCreate([Http, Service]);
console.log(injector.get(Service) instanceof Service);
```
For full documentation click [here](https://angular.io/docs/ts/latest/guide/dependency-injection.html).

@@ -53,0 +81,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc