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

inversify

Package Overview
Dependencies
Maintainers
1
Versions
88
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inversify - npm Package Compare versions

Comparing version 3.0.0-beta.3 to 3.0.0-rc.1

amd/annotation/optional.js

1

amd/constants/metadata_keys.js

@@ -6,2 +6,3 @@ define(["require", "exports"], function (require, exports) {

exports.UNMANAGED_TAG = "unmanaged";
exports.OPTIONAL_TAG = "optional";
exports.INJECT_TAG = "inject";

@@ -8,0 +9,0 @@ exports.MULTI_INJECT_TAG = "multi_inject";

3

amd/inversify.js

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

define(["require", "exports", "./container/container", "./container/container_module", "./annotation/injectable", "./annotation/tagged", "./annotation/named", "./annotation/inject", "./annotation/unmanaged", "./annotation/multi_inject", "./annotation/target_name", "./utils/guid", "./annotation/decorator_utils", "./syntax/constraint_helpers", "./utils/serialization"], function (require, exports, container_1, container_module_1, injectable_1, tagged_1, named_1, inject_1, unmanaged_1, multi_inject_1, target_name_1, guid_1, decorator_utils_1, constraint_helpers_1, serialization_1) {
define(["require", "exports", "./container/container", "./container/container_module", "./annotation/injectable", "./annotation/tagged", "./annotation/named", "./annotation/inject", "./annotation/optional", "./annotation/unmanaged", "./annotation/multi_inject", "./annotation/target_name", "./utils/guid", "./annotation/decorator_utils", "./syntax/constraint_helpers", "./utils/serialization"], function (require, exports, container_1, container_module_1, injectable_1, tagged_1, named_1, inject_1, optional_1, unmanaged_1, multi_inject_1, target_name_1, guid_1, decorator_utils_1, constraint_helpers_1, serialization_1) {
"use strict";

@@ -9,2 +9,3 @@ exports.Container = container_1.Container;

exports.inject = inject_1.inject;
exports.optional = optional_1.optional;
exports.unmanaged = unmanaged_1.unmanaged;

@@ -11,0 +12,0 @@ exports.multiInject = multi_inject_1.multiInject;

@@ -35,7 +35,12 @@ define(["require", "exports", "./plan", "./context", "./request", "./target", "../bindings/binding_count", "./reflection_utils", "../planning/metadata", "../constants/error_msgs", "../constants/metadata_keys", "../constants/literal_types", "../utils/serialization"], function (require, exports, plan_1, context_1, request_1, target_1, binding_count_1, reflection_utils_1, metadata_1, ERROR_MSGS, METADATA_KEY, literal_types_1, serialization_1) {

case binding_count_1.BindingCount.NoBindingsAvailable:
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier);
var msg = ERROR_MSGS.NOT_REGISTERED;
msg += serialization_1.listMetadataForTarget(serviceIdentifierString, target);
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
if (target.isOptional() === true) {
return bindings;
}
else {
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier);
var msg = ERROR_MSGS.NOT_REGISTERED;
msg += serialization_1.listMetadataForTarget(serviceIdentifierString, target);
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
}
case binding_count_1.BindingCount.OnlyOneBindingAvailable:

@@ -48,5 +53,5 @@ if (target.isArray() === false) {

if (target.isArray() === false) {
var serviceIdentifierString_1 = serialization_1.getServiceIdentifierAsString(serviceIdentifier), msg_1 = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString_1;
msg_1 += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString_1, getBindings);
throw new Error(msg_1);
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier), msg = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString;
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
}

@@ -53,0 +58,0 @@ else {

@@ -48,2 +48,5 @@ define(["require", "exports", "../planning/metadata", "./queryable_string", "../utils/guid", "../constants/metadata_keys"], function (require, exports, metadata_1, queryable_string_1, guid_1, METADATA_KEY) {

};
Target.prototype.isOptional = function () {
return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true);
};
Target.prototype.getNamedTag = function () {

@@ -50,0 +53,0 @@ if (this.isNamed()) {

@@ -18,2 +18,5 @@ define(["require", "exports", "../constants/literal_types", "../utils/serialization", "./instantiation", "../constants/error_msgs"], function (require, exports, literal_types_1, serialization_1, instantiation_1, ERROR_MSGS) {

var result = null;
if (request.target.isOptional() === true && bindings.length === 0) {
return undefined;
}
var binding = bindings[0];

@@ -20,0 +23,0 @@ var isSingleton = binding.scope === literal_types_1.BindingScopeEnum.Singleton;

export declare const NAMED_TAG = "named";
export declare const NAME_TAG = "name";
export declare const UNMANAGED_TAG = "unmanaged";
export declare const OPTIONAL_TAG = "optional";
export declare const INJECT_TAG = "inject";

@@ -5,0 +6,0 @@ export declare const MULTI_INJECT_TAG = "multi_inject";

@@ -123,2 +123,3 @@ declare namespace interfaces {

isTagged(): boolean;
isOptional(): boolean;
matchesNamedTag(name: string): boolean;

@@ -125,0 +126,0 @@ matchesTag(key: string | number | symbol): (value: any) => boolean;

@@ -7,2 +7,3 @@ export { Container } from "./container/container";

export { inject } from "./annotation/inject";
export { optional } from "./annotation/optional";
export { unmanaged } from "./annotation/unmanaged";

@@ -9,0 +10,0 @@ export { multiInject } from "./annotation/multi_inject";

@@ -15,2 +15,3 @@ import { interfaces } from "../interfaces/interfaces";

isTagged(): boolean;
isOptional(): boolean;
getNamedTag(): interfaces.Metadata | null;

@@ -17,0 +18,0 @@ getCustomTags(): interfaces.Metadata[] | null;

export var NAMED_TAG = "named";
export var NAME_TAG = "name";
export var UNMANAGED_TAG = "unmanaged";
export var OPTIONAL_TAG = "optional";
export var INJECT_TAG = "inject";

@@ -5,0 +6,0 @@ export var MULTI_INJECT_TAG = "multi_inject";

@@ -7,2 +7,3 @@ export { Container } from "./container/container";

export { inject } from "./annotation/inject";
export { optional } from "./annotation/optional";
export { unmanaged } from "./annotation/unmanaged";

@@ -9,0 +10,0 @@ export { multiInject } from "./annotation/multi_inject";

@@ -43,7 +43,12 @@ import { Plan } from "./plan";

case BindingCount.NoBindingsAvailable:
var serviceIdentifierString = getServiceIdentifierAsString(serviceIdentifier);
var msg = ERROR_MSGS.NOT_REGISTERED;
msg += listMetadataForTarget(serviceIdentifierString, target);
msg += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
if (target.isOptional() === true) {
return bindings;
}
else {
var serviceIdentifierString = getServiceIdentifierAsString(serviceIdentifier);
var msg = ERROR_MSGS.NOT_REGISTERED;
msg += listMetadataForTarget(serviceIdentifierString, target);
msg += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
}
case BindingCount.OnlyOneBindingAvailable:

@@ -56,5 +61,5 @@ if (target.isArray() === false) {

if (target.isArray() === false) {
var serviceIdentifierString_1 = getServiceIdentifierAsString(serviceIdentifier), msg_1 = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString_1;
msg_1 += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString_1, getBindings);
throw new Error(msg_1);
var serviceIdentifierString = getServiceIdentifierAsString(serviceIdentifier), msg = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString;
msg += listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
}

@@ -61,0 +66,0 @@ else {

@@ -50,2 +50,5 @@ import { Metadata } from "../planning/metadata";

};
Target.prototype.isOptional = function () {
return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true);
};
Target.prototype.getNamedTag = function () {

@@ -52,0 +55,0 @@ if (this.isNamed()) {

@@ -20,2 +20,5 @@ import { BindingScopeEnum, BindingTypeEnum } from "../constants/literal_types";

var result = null;
if (request.target.isOptional() === true && bindings.length === 0) {
return undefined;
}
var binding = bindings[0];

@@ -22,0 +25,0 @@ var isSingleton = binding.scope === BindingScopeEnum.Singleton;

@@ -5,2 +5,3 @@ "use strict";

exports.UNMANAGED_TAG = "unmanaged";
exports.OPTIONAL_TAG = "optional";
exports.INJECT_TAG = "inject";

@@ -7,0 +8,0 @@ exports.MULTI_INJECT_TAG = "multi_inject";

@@ -14,2 +14,4 @@ "use strict";

exports.inject = inject_1.inject;
var optional_1 = require("./annotation/optional");
exports.optional = optional_1.optional;
var unmanaged_1 = require("./annotation/unmanaged");

@@ -16,0 +18,0 @@ exports.unmanaged = unmanaged_1.unmanaged;

@@ -45,7 +45,12 @@ "use strict";

case binding_count_1.BindingCount.NoBindingsAvailable:
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier);
var msg = ERROR_MSGS.NOT_REGISTERED;
msg += serialization_1.listMetadataForTarget(serviceIdentifierString, target);
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
if (target.isOptional() === true) {
return bindings;
}
else {
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier);
var msg = ERROR_MSGS.NOT_REGISTERED;
msg += serialization_1.listMetadataForTarget(serviceIdentifierString, target);
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
}
case binding_count_1.BindingCount.OnlyOneBindingAvailable:

@@ -58,5 +63,5 @@ if (target.isArray() === false) {

if (target.isArray() === false) {
var serviceIdentifierString_1 = serialization_1.getServiceIdentifierAsString(serviceIdentifier), msg_1 = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString_1;
msg_1 += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString_1, getBindings);
throw new Error(msg_1);
var serviceIdentifierString = serialization_1.getServiceIdentifierAsString(serviceIdentifier), msg = ERROR_MSGS.AMBIGUOUS_MATCH + " " + serviceIdentifierString;
msg += serialization_1.listRegisteredBindingsForServiceIdentifier(container, serviceIdentifierString, getBindings);
throw new Error(msg);
}

@@ -63,0 +68,0 @@ else {

@@ -51,2 +51,5 @@ "use strict";

};
Target.prototype.isOptional = function () {
return this.matchesTag(METADATA_KEY.OPTIONAL_TAG)(true);
};
Target.prototype.getNamedTag = function () {

@@ -53,0 +56,0 @@ if (this.isNamed()) {

@@ -21,2 +21,5 @@ "use strict";

var result = null;
if (request.target.isOptional() === true && bindings.length === 0) {
return undefined;
}
var binding = bindings[0];

@@ -23,0 +26,0 @@ var isSingleton = binding.scope === literal_types_1.BindingScopeEnum.Singleton;

{
"name": "inversify",
"version": "3.0.0-beta.3",
"version": "3.0.0-rc.1",
"description": "A powerful and lightweight inversion of control container for JavaScript and Node.js apps powered by TypeScript.",

@@ -5,0 +5,0 @@ "main": "lib/inversify.js",

@@ -238,2 +238,3 @@ # InversifyJS

- [Controlling the scope of the dependencies](https://github.com/inversify/InversifyJS/blob/master/wiki/scope.md)
- [Declaring optional dependencies](https://github.com/inversify/InversifyJS/blob/master/wiki/optional_dependencies.md)
- [Injecting a constant or dynamic value](https://github.com/inversify/InversifyJS/blob/master/wiki/value_injection.md)

@@ -240,0 +241,0 @@ - [Injecting a class constructor](https://github.com/inversify/InversifyJS/blob/master/wiki/constructor_injection.md)

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