Socket
Socket
Sign inDemoInstall

huject

Package Overview
Dependencies
2
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.3.4 to 1.4.0

0

Changelog.md

@@ -0,0 +0,0 @@ # Version 1.3.4

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

@@ -0,0 +0,0 @@ "use strict";

3

Gruntfile.js

@@ -15,2 +15,5 @@ module.exports = function(grunt) {

ts: {
options: {
compiler: "./node_modules/typescript/bin/tsc"
},
default: {

@@ -17,0 +20,0 @@ src: ['src/**/*.ts'],

10

huject.d.ts

@@ -121,3 +121,3 @@ declare module Huject {

*/
export function Inject(method: FactoryMethod);
export function Inject(method: FactoryMethod): any;

@@ -137,3 +137,3 @@ /**

*/
export function Inject(literal: string, method?: FactoryMethod);
export function Inject(literal: string, method?: FactoryMethod): any;

@@ -179,3 +179,3 @@ /**

*/
export function ConstructorInject(method: FactoryMethod);
export function ConstructorInject(method: FactoryMethod): any;

@@ -205,3 +205,3 @@ /**

*/
export function ConstructorInject(literal: string, method?: FactoryMethod);
export function ConstructorInject(literal: string, method?: FactoryMethod): any;

@@ -241,3 +241,3 @@ /**

*/
export function Optional(target: Object, propertyKey: string|symbol, parameterIndex: number);
export function Optional(target: Object, propertyKey: string|symbol, parameterIndex: number): any;

@@ -244,0 +244,0 @@ /**

{
"name": "huject",
"version": "1.3.4",
"version": "1.4.0",
"description": "Typescript dependency injection container for humans",

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

@@ -14,4 +14,4 @@ # Typescript dependency injection for humans!

* Optional injection (from version 1.2)
* Injecting container as factory (**new** 1.3 version)
* Auto-Creating object factories! (**new** 1.3 version)
* Injecting container as factory (from 1.3 version)
* Auto-Creating object factories! (from 1.3 version)

@@ -238,3 +238,3 @@ ## Todo

// If dependency wasn't found then leave original value (for property injection) or pass null (for constructor injection)
@Optional
@Optional()
// Used for creating auto factories (See below)

@@ -291,4 +291,4 @@ @Factory

service: MyService,
@Optional @ConstructorInject('token') param1: string,
@Optional @ConstructorInject('seed') param2: number)
@Optional() @ConstructorInject('token') param1: string,
@Optional() @ConstructorInject('seed') param2: number)
{

@@ -310,7 +310,7 @@ if (param1 !== null) {

class Test {
@Optional
@Optional()
@Inject('classToken')
public classParam1: string = "default string";
@Optional
@Optional()
@Inject('servicePort')

@@ -317,0 +317,0 @@ public port: number = 80;

@@ -0,0 +0,0 @@ import {Definition, FactoryMethod, DefinitionObjectType} from './definition';

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

@@ -16,3 +16,2 @@ import 'reflect-metadata';

return targetOrFactoryMethodOrLiteral;
break;
// constructor (@ConstructorInject(FactoryMethod) param1: class, ...);

@@ -28,3 +27,2 @@ case 'number':

};
break;
// constructor (@ConstructorInject('literal',FactoryMethod) param1: class, ...);

@@ -41,3 +39,2 @@ case 'string':

};
break;
}

@@ -89,3 +86,2 @@ }

};
break;
// @Inject(FactoryMethod)

@@ -105,3 +101,2 @@ case 'number':

};
break;
}

@@ -116,19 +111,11 @@ }

export function Optional(...args: any[]): any {
let target;
switch (args.length) {
// Property @Optional
case 2:
target = args[0];
let propertyKey = args[1];
return function (target: Object, propertyKey: string, parameterIndex: number) {
if (typeof parameterIndex === "undefined") {
// Property @Optional()
Reflect.defineMetadata("inject:property:optional", true, target, propertyKey);
break;
// Constructor @Optional
case 3:
target = args[0];
let parameterIndex = args[2];
} else {
// Constructor @Optional()
let metadataName = 'inject:constructor:param' + parameterIndex + ':optional';
Reflect.defineMetadata(metadataName, true, target);
break;
default:
throw new Error("@Optional decorator is not allowed here");
}
}

@@ -148,3 +135,2 @@ }

return target;
break;
case 3:

@@ -155,6 +141,5 @@ target = args[0];

return args[2];
break;
default:
throw new Error("@Factory decorator is not allowed here");
}
}
}

@@ -0,0 +0,0 @@ export enum FactoryMethod {

@@ -0,0 +0,0 @@ import {ContainerResolver} from "./resolver";

@@ -1,4 +0,2 @@

/**
* Exporting library here
*/
"use strict";
var container_1 = require('./container');

@@ -5,0 +3,0 @@ exports.Container = container_1.Container;

@@ -0,0 +0,0 @@ /**

@@ -109,3 +109,2 @@ import 'es6-collections';

return this.singletonObjects.get(internalDefinition);
break;
case FactoryMethod.FACTORY:

@@ -119,6 +118,4 @@ if (internalDefinition.definitionObjectType == DefinitionObjectType.CALLABLE) {

}
break;
case FactoryMethod.OBJECT:
return constructor;
break;
}

@@ -125,0 +122,0 @@ }

@@ -0,0 +0,0 @@ import './bootstrap';

@@ -0,0 +0,0 @@ ///<reference path="../typings/tsd.d.ts"/>

@@ -0,0 +0,0 @@ import './bootstrap';

@@ -0,0 +0,0 @@ import './bootstrap';

@@ -145,4 +145,4 @@ import './bootstrap';

public constructor(
@ConstructorInject(FactoryMethod.SINGLETON) @Optional service: TestInterface,
@Optional @ConstructorInject('nonexist') num: number
@ConstructorInject(FactoryMethod.SINGLETON) @Optional() service: TestInterface,
@Optional() @ConstructorInject('nonexist') num: number
) {

@@ -156,7 +156,7 @@ this.test = service;

@Inject('nonexiststring')
@Optional
@Optional()
public str: string = "default";
@Inject('nonexistnumber')
@Optional
@Optional()
public num: number = 25;

@@ -269,6 +269,4 @@ }

describe("When property injection has @Optional decorator", () => {
let containerSpy;
beforeEach(() => {
container.register(PropertyInjectionOptional);
containerSpy = sinon.spy(container, 'resolve');
});

@@ -275,0 +273,0 @@ it("Should leave property original specified value", () => {

@@ -0,0 +0,0 @@ {

@@ -0,0 +0,0 @@ // Type definitions for chai 3.2.0

@@ -0,0 +0,0 @@ // Type definitions for es6-collections v0.5.1

@@ -0,0 +0,0 @@ declare module "harmony-reflect" {

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc