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

cheap-di

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cheap-di - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

32

dist/container.js

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

const dependencies = new Map();
function makeInstance(instanceType, args) {
const implementation = dependencies.get(instanceType);
if (typeof implementation !== "function") {
return implementation;
}
const injectionParams = implementation.__injectionParams || [];
return new implementation(...[
...injectionParams,
...args,
]);
}
const container = {

@@ -44,15 +33,20 @@ registerType: function (implementationType) {

resolve: function (type, ...args) {
let implementation = type;
if (dependencies.has(type)) {
return makeInstance(type, args);
implementation = dependencies.get(type);
}
if (!type.__constructorParams || !Array.isArray(type.__constructorParams)) {
throw new Error(`The ${type.name} cannot be resolved by Dependency Injection`);
if (typeof implementation !== 'function') {
return implementation;
}
const dependencyArguments = [];
type.__constructorParams.forEach((type) => {
const instance = container.resolve(type);
dependencyArguments.push(instance);
});
return new type(...[
if (implementation.__constructorParams) {
implementation.__constructorParams.forEach((type) => {
const instance = container.resolve(type);
dependencyArguments.push(instance);
});
}
const injectionParams = implementation.__injectionParams || [];
return new implementation(...[
...dependencyArguments,
...injectionParams,
...args,

@@ -59,0 +53,0 @@ ]);

{
"name": "cheap-di",
"version": "0.1.4",
"version": "0.1.5",
"description": "JavaScript dependency injection like Autofac in .Net",

@@ -5,0 +5,0 @@ "scripts": {

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