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

hekdi

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hekdi - npm Package Compare versions

Comparing version 1.3.5 to 1.3.6

src/utils/resolution_checker.js

0

docs/koa.md

@@ -0,0 +0,0 @@ # Koa.js usage:

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

2

package.json
{
"name": "hekdi",
"version": "1.3.5",
"version": "1.3.6",
"description": "Depedency injection framework for node.js",

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

@@ -0,0 +0,0 @@ [![Build Status](https://travis-ci.org/IvanProdaiko94/hekdi.svg?branch=master)](https://travis-ci.org/IvanProdaiko94/hekdi)

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

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

'use strict';
const errors = require('./utils/errors');
const strategies = require('./utils/strategies');
const resolutionChecker = require('./utils/resolution_checker');

@@ -20,3 +21,3 @@ /**

Injector.prototype.resolve = function(dependencyName) {
if (this.dependencies.has(dependencyName)) {
if (this.dependencies.has(dependencyName) && resolutionChecker.call(this, null, dependencyName)) {
return this.dependencies.get(dependencyName).resolver();

@@ -63,3 +64,2 @@ }

dependencies.forEach(config => {
const inject = config.value.$inject || [];
const dConf = this.getConfigOf(config.name);

@@ -70,13 +70,3 @@ if (dConf && dConf.strategy === 'constant') {

throw new Error(errors.incorrectResolutionStrategy(config.strategy, strategies));
} else if (inject.indexOf(config.name) !== -1) {
throw new Error(errors.selfDependency(config.name));
}
inject.forEach(dep => {
if (this.dependencies.has(dep)) {
const depsToCheck = this.getConfigOf(dep).value.$inject || [];
if (depsToCheck.indexOf(config.name) !== -1) {
throw new Error(errors.circularDependency(config.name, dep));
}
}
});
config.resolver = strategies[config.strategy](config.name).bind(this);

@@ -83,0 +73,0 @@ config.belongTo = this.belongTo;

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

@@ -6,4 +6,3 @@ 'use strict';

unmetDependency: (moduleName, dependencyName) => `Unmet dependency '${dependencyName}' in module '${moduleName}'`,
selfDependency: dependencyName => `'${dependencyName}' can't be a dependency of itself`,
circularDependency: (main, dep) => `Circular dependency found in '${dep}' while registering '${main}'`,
circularDependency: (list, dep) => `Circular dependency found while resolving ${dep}: ${list}`,
incorrectResolutionStrategy: (strategy, strategies) => (

@@ -10,0 +9,0 @@ `strategy ${strategy} is incorrect. Allowable values are ${Object.keys(strategies).join(', ')}`

@@ -6,5 +6,14 @@ /**

const inject = function(dependencyName) {
const errors = require('./errors');
const resolveHelper = function(dependencyName) {
if (this.dependencies.has(dependencyName)) {
return this.dependencies.get(dependencyName).resolver();
}
throw new ReferenceError(errors.unmetDependency(this.belongTo, dependencyName));
};
const resolveDependency = function(dependencyName) {
const config = this.getConfigOf(dependencyName);
return new config.value(...(config.value.$inject || []).map(name => this.resolve(name)));
return new config.value(...(config.value.$inject || []).map(name => resolveHelper.call(this, name)));
};

@@ -18,3 +27,3 @@

factory: dependencyName => function() {
return inject.call(this, dependencyName);
return resolveDependency.call(this, dependencyName);
},

@@ -29,3 +38,3 @@ /**

if (!instance) {
instance = inject.call(this, dependencyName);
instance = resolveDependency.call(this, dependencyName);
}

@@ -56,4 +65,4 @@ return instance;

const { name } = this.getConfigOf(value);
return this.resolve(name);
return resolveHelper.call(this, name);
}
};
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