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

typed-inject

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-inject - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

17

CHANGELOG.md

@@ -0,1 +1,18 @@

# [0.2.0](https://github.com/nicojs/typed-inject/compare/v0.1.1...v0.2.0) (2019-02-05)
### Features
* **covariant injector:** Injector interface covariance ([46058a8](https://github.com/nicojs/typed-inject/commit/46058a8))
### BREAKING CHANGES
* **covariant injector:** It is no longer possible to resolve
`TARGET_TOKEN` or `INJECTOR_TOKEN` directly from an
`Injector` using `resolve`. I don't see a use case for that,
so it's no big deal
## [0.1.1](https://github.com/nicojs/typed-inject/compare/v0.1.0...v0.1.1) (2019-01-26)

@@ -2,0 +19,0 @@

7

package.json
{
"name": "typed-inject",
"version": "0.1.1",
"version": "0.2.0",
"description": "Type safe dependency injection framework for TypeScript",

@@ -9,3 +9,4 @@ "main": "src/index.js",

"start": "tsc -b -w",
"prebuild": "rimraf \"+(src|test)/**/*+(.map|.js|.d.ts)\"",
"clean": "rimraf \"+(src|test)/**/*+(.map|.js|.d.ts)\"",
"prebuild": "npm run clean",
"build": "tsc -b",

@@ -66,4 +67,4 @@ "postbuild": "tslint -p tsconfig.lint.json",

"tslint": "^5.12.1",
"typescript": "^3.2.2"
"typescript": "^3.3.1"
}
}
import { InjectableClass, InjectableFunction } from './Injectable';
import { CorrespondingType } from './CorrespondingType';
import { InjectionToken } from './InjectionToken';

@@ -8,3 +7,3 @@ import { Scope } from './Scope';

injectFunction<R, Tokens extends InjectionToken<TContext>[]>(Class: InjectableFunction<TContext, R, Tokens>): R;
resolve<Token extends InjectionToken<TContext>>(token: Token): CorrespondingType<TContext, Token>;
resolve<Token extends keyof TContext>(token: Token): TContext[Token];
provideValue<Token extends string, R>(token: Token, value: R): Injector<{

@@ -11,0 +10,0 @@ [k in Token]: R;

@@ -49,3 +49,12 @@ "use strict";

const tokens = injectable.inject || [];
return tokens.map(key => this.resolve(key, injectable, target));
return tokens.map(key => {
switch (key) {
case InjectionToken_1.TARGET_TOKEN:
return target;
case InjectionToken_1.INJECTOR_TOKEN:
return this;
default:
return this.resolve(key, injectable);
}
});
}

@@ -61,11 +70,4 @@ provideValue(token, value) {

}
resolve(token, providedIn, target) {
switch (token) {
case InjectionToken_1.TARGET_TOKEN:
return target;
case InjectionToken_1.INJECTOR_TOKEN:
return this;
default:
return this.resolveInternal(token, providedIn);
}
resolve(token, providedIn) {
return this.resolveInternal(token, providedIn);
}

@@ -72,0 +74,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