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

di-ts

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

di-ts - npm Package Compare versions

Comparing version 0.0.29 to 0.0.30

2

di.d.ts

@@ -16,3 +16,3 @@

export class Inject {
constructor(injectableClass: IClassInterface<any>);
constructor(...injectableClasses: Array<IClassInterface<any>>);
}

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

@@ -6,6 +6,12 @@ /// <reference path="node_modules/reflect-metadata/reflect-metadata.d.ts"/>

exports.Injector = di.Injector;
function factory(data) {
function F() {
di.Inject.apply(this, data);
}
F.prototype = di.Inject.prototype;
return new F();
}
function Inject(classFunc) {
var dependencies = Reflect.getMetadata("design:paramtypes", classFunc) || [];
var annotateArgs = [classFunc].concat(dependencies.map(function (dep) { return new di.Inject(dep); }));
di.annotate.apply(di, annotateArgs);
di.annotate(classFunc, factory(dependencies));
}

@@ -12,0 +18,0 @@ exports.Inject = Inject;

@@ -8,9 +8,15 @@

export var Injector = di.Injector;
function factory(data: Array<any>) : di.Inject {
function F() : void {
di.Inject.apply(this, data);
}
F.prototype = di.Inject.prototype;
return new F();
}
export function Inject(classFunc: any) {
const dependencies = Reflect.getMetadata("design:paramtypes", classFunc) || [];
var annotateArgs = [classFunc].concat(dependencies.map((dep: any) => new di.Inject(dep)));
di.annotate.apply(di, annotateArgs);
di.annotate(classFunc, factory(dependencies));
}

@@ -17,0 +23,0 @@

{
"name": "di-ts",
"version": "0.0.29",
"version": "0.0.30",
"description": "Lightweight wrap and extension of di.js v2 for TypeScript.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -12,5 +12,10 @@

export class Doors {
}
@Inject
export class Car {
constructor(public engine: Engine) {}
constructor(public engine: Engine, public doors:Doors) {}
}

@@ -21,2 +26,2 @@

}
}
/// <reference path="../typings/mocha/mocha.d.ts"/>
/// <reference path="./typings/expectations.d.ts"/>
/// <reference path="../typings/expectations/expectations.d.ts"/>
import 'expectations'
import {Injector} from '../index'
import {Engine, MockEngine, Car} from './fixtures'
import {Engine, MockEngine, Car, Doors} from './fixtures'

@@ -18,3 +17,3 @@ describe("di.ts", () => {

it("should instatiate a class with dependency", () => {
it("should instantiate a class with dependency", () => {
var injector = new Injector();

@@ -27,3 +26,14 @@ var car: Car = injector.get(Car);

it("should instatiate a class with mocked dependency", () => {
it("should instantiate a class with multiple dependencies", () => {
var injector = new Injector();
var car: Car = injector.get(Car);
expect(car instanceof Car).toBeTruthy();
expect(car.engine instanceof Engine).toBeTruthy();
expect(car.doors instanceof Doors).toBeTruthy();
});
it("should instantiate a class with mocked dependency", () => {
var injector = new Injector([MockEngine]);

@@ -38,2 +48,2 @@ var car: Car = injector.get(Car);

});
});

@@ -13,4 +13,7 @@ {

"commit": "52fa2b9ce36f2c5843204e9bfbaada7cded9b47a"
},
"expectations/expectations.d.ts": {
"commit": "c7b1128cc9a8f5797bade826e7632b36b06a856c"
}
}
}

Sorry, the diff of this file is not supported yet

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