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

@injex/core

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@injex/core - npm Package Compare versions

Comparing version 2.0.0-alpha.4 to 2.0.0-alpha.5

5

lib/injex.d.ts
import { IConstructor, Logger } from "@injex/stdlib";
import { IModule, ModuleName, IInjexHooks, IContainerConfig } from "./interfaces";
import { IModule, ModuleName, IInjexHooks, IContainerConfig, AliasMap, AliasFactory } from "./interfaces";
export default abstract class InjexContainer<T extends IContainerConfig> {

@@ -37,3 +37,3 @@ private _moduleRegistry;

private _createInstance;
getModuleDefinition(moduleNameOrType: string | IConstructor): IModule;
getModuleDefinition(moduleNameOrType: ModuleName | IConstructor): IModule;
private _injectModuleDependencies;

@@ -55,2 +55,3 @@ private _register;

get<K = any>(itemNameOrType: ModuleName | IConstructor): K;
getAlias<K extends string = string, V = any>(alias: string, keyBy: string): AliasMap<K, V> | AliasFactory<K, V>;
}

33

lib/injex.js

@@ -268,20 +268,11 @@ "use strict";

var _a = dependencies_1[_i], label = _a.label, value = _a.value;
var dependencyDefinition = this.getModuleDefinition(value);
if (!dependencyDefinition) {
var dependency = this.get(value);
if (!dependency) {
throw new errors_1.ModuleDependencyNotFoundError(metadata.name, value);
}
module[label] = dependencyDefinition.module;
module[label] = dependency;
}
for (var _b = 0, aliasDependencies_1 = aliasDependencies; _b < aliasDependencies_1.length; _b++) {
var _c = aliasDependencies_1[_b], label = _c.label, alias = _c.alias, keyBy = _c.keyBy;
var aliasModules = this._aliases.get(alias);
if (!aliasModules) {
throw new errors_1.ModuleDependencyNotFoundError(metadata.name, alias);
}
module[label] = {};
for (var _d = 0, aliasModules_1 = aliasModules; _d < aliasModules_1.length; _d++) {
var aliasModule = aliasModules_1[_d];
var keyValue = aliasModule.metadata.singleton ? aliasModule.module[keyBy] : aliasModule.metadata.item[keyBy];
module[label][keyValue] = aliasModule.module;
}
module[label] = this.getAlias(alias, keyBy);
}

@@ -320,8 +311,18 @@ };

InjexContainer.prototype.get = function (itemNameOrType) {
if (!this._modules.has(itemNameOrType)) {
var definition = this.getModuleDefinition(itemNameOrType);
if (!definition) {
return constants_1.UNDEFINED;
}
var module = this._modules.get(itemNameOrType).module;
return module;
return definition.module;
};
InjexContainer.prototype.getAlias = function (alias, keyBy) {
var aliasModules = this._aliases.get(alias);
var map = {};
for (var _i = 0, aliasModules_1 = aliasModules; _i < aliasModules_1.length; _i++) {
var aliasModule = aliasModules_1[_i];
var keyValue = aliasModule.metadata.singleton ? aliasModule.module[keyBy] : aliasModule.metadata.item[keyBy];
map[keyValue] = aliasModule.module;
}
return map;
};
return InjexContainer;

@@ -328,0 +329,0 @@ }());

@@ -54,4 +54,4 @@ import { Hook, IConstructor, LogLevel } from "@injex/stdlib";

}
export declare type AliasFactory<T> = {
[index: string]: () => T;
export declare type AliasFactory<K extends string, T> = {
[key in K]: () => T;
};

@@ -58,0 +58,0 @@ export declare type AliasMap<K extends string, T> = {

{
"name": "@injex/core",
"version": "2.0.0-alpha.4",
"version": "2.0.0-alpha.5",
"description": "Simple, Decorated, Pluggable dependency-injection framework for TypeScript apps",

@@ -46,3 +46,3 @@ "keywords": [

"dependencies": {
"@injex/stdlib": "^2.0.0-alpha.4",
"@injex/stdlib": "^2.0.0-alpha.5",
"tslib": "^2.0.1"

@@ -56,3 +56,3 @@ },

},
"gitHead": "8654c3279900f3686b905a3e72ebf8b75f694ecc"
"gitHead": "d7c4a8314ca8f1f70c4c67145932af8ef27ceddc"
}

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