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

dependency-injector-container

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dependency-injector-container - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

docs/api.js

29

Gruntfile.js

@@ -12,2 +12,3 @@ /*

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {

@@ -17,4 +18,29 @@ main: {

'main.min.js': 'main.js'
},
options: {
mangle: true,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true
}
}
}
},
yuidoc: {
compile: {
name: '<%= pkg.name %>',
description: '<%= pkg.description %>',
version: '<%= pkg.version %>',
url: '<%= pkg.homepage %>',
options: {
paths: './',
outdir: 'docs/'
}
}
}

@@ -25,5 +51,6 @@ });

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-yuidoc');
// By default, lint and run all tests.
grunt.registerTask('default', ['uglify']);
grunt.registerTask('default', ['yuidoc','uglify']);
};

28

main.js

@@ -26,7 +26,7 @@ /*

* @constructor
* @param {Object} namespaceRange Scope for namespaces.
* @param {Object} scope Scope for namespaces.
* @private
*/
function DependencyInjectorContainer(namespaceRange) {
this.scope = namespaceRange || {};
function DependencyInjectorContainer(scope) {
this.scope = scope || {};
}

@@ -38,14 +38,14 @@

* @method set
* @chainable
* @param {String} namespace Module namespace.
* @param {Object} module Module to set.
* @param {String} namespace Module namespace.
* @param {Boolean} [override] Should override namespace if set.
* @return {DependencyInjectorContainer}
*/
DependencyInjectorContainer.prototype.set = function(module, namespace, override) {
DependencyInjectorContainer.prototype.set = function(namespace, module, override) {
if (typeof namespace !== 'string') {
throw new TypeError('Second argument must be string');
throw new TypeError('Namespace has to be a string.');
}
if (override !== true && this.scope.hasOwnProperty(namespace) === true) {
throw new Error(namespace + ' is aready defined');
throw new Error(namespace + ' is aready defined.');
}

@@ -62,6 +62,6 @@

* @method extend
* @chainable
* @param {String} namespace Module namespace.
* @param {Array} [dependencies] Module dependencies.
* @param {Object} definition Module definition block.
* @return {DependencyInjectorContainer}
*/

@@ -76,3 +76,3 @@ DependencyInjectorContainer.prototype.extend = function(namespace, dependencies, definition) {

definition.isDefinition = true;
this.set(definition, namespace);
this.set(namespace, definition);

@@ -91,7 +91,7 @@ return this;

if (typeof namespace !== 'string') {
throw new TypeError('Namespace has to be a string');
throw new TypeError('Namespace has to be a string.');
}
if (typeof this.scope[namespace] === 'undefined') {
throw new Error(namespace + ' not found');
throw new Error(namespace + ' not found.');
}

@@ -106,3 +106,3 @@

* @method load
* @return {DependencyInjectorContainer}
* @chainable
*/

@@ -157,3 +157,3 @@ DependencyInjectorContainer.prototype.load = function() {

try {
this.set(definition.apply(this, args) || {}, namespace, true);
this.set(namespace, definition.apply(this, args) || {}, true);
} catch (e) {

@@ -160,0 +160,0 @@ console.error(namespace, e);

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

!function(a,b){var c=b(),d="function"==typeof define&&define.amd,e="undefined"!=typeof module&&module.exports;d?define(c):e?module.exports=c:window[a]=c}("DependencyInjectorContainer",function(){function a(a){this.scope=a||{}}return a.prototype.set=function(a,b,c){if("string"!=typeof b)throw new TypeError("Second argument must be string");if(c!==!0&&this.scope.hasOwnProperty(b)===!0)throw new Error(b+" is aready defined");return this.scope[b]=a,this},a.prototype.extend=function(a,b,c){return"function"==typeof b&&(c=b,b=void 0),c.__dependencies__=b||[],c.isDefinition=!0,this.set(c,a),this},a.prototype.get=function(a){if("string"!=typeof a)throw new TypeError("Namespace has to be a string");if("undefined"==typeof this.scope[a])throw new Error(a+" not found");return this.scope[a]},a.prototype.load=function(){for(var a=Object.keys(this.scope).filter(function(a){return this.get(a).isDefinition===!0},this),b=[],c=function(c){var d=[];return c.forEach(function(c){var e=a.some(function(a){return a!==c&&-1!==this.get(a).__dependencies__.indexOf(c)?-1!==this.get(c).__dependencies__.indexOf(a)?void console.error("Cyclic dependency in "+c+" and "+a+"."):!0:void 0},this);e===!0?d.push(c):b.unshift(c)},this),d}.bind(this);a.length>0;)a=c(a);return b.forEach(function(a){var b=this.get(a),c=b.__dependencies__,d=c.map(function(a){var b=this.get(a);return b.isDefinition===!0&&console.warn("Module "+a+" is not initialized."),b},this);try{this.set(b.apply(this,d)||{},a,!0)}catch(e){console.error(a,e)}},this),this},a});
!function(a,b){var c=b(),d="function"==typeof define&&define.amd,e="undefined"!=typeof module&&module.exports;d?define(c):e?module.exports=c:window[a]=c}("DependencyInjectorContainer",function(){function a(a){this.scope=a||{}}return a.prototype.set=function(a,b,c){if("string"!=typeof a)throw new TypeError("Namespace has to be a string.");if(c!==!0&&this.scope.hasOwnProperty(a)===!0)throw new Error(a+" is aready defined.");return this.scope[a]=b,this},a.prototype.extend=function(a,b,c){return"function"==typeof b&&(c=b,b=void 0),c.__dependencies__=b||[],c.isDefinition=!0,this.set(a,c),this},a.prototype.get=function(a){if("string"!=typeof a)throw new TypeError("Namespace has to be a string.");if("undefined"==typeof this.scope[a])throw new Error(a+" not found.");return this.scope[a]},a.prototype.load=function(){for(var a=Object.keys(this.scope).filter(function(a){return this.get(a).isDefinition===!0},this),b=[],c=function(c){var d=[];return c.forEach(function(c){var e=a.some(function(a){if(a!==c&&-1!==this.get(a).__dependencies__.indexOf(c)){if(-1!==this.get(c).__dependencies__.indexOf(a))return;return!0}},this);e===!0?d.push(c):b.unshift(c)},this),d}.bind(this);a.length>0;)a=c(a);return b.forEach(function(a){var b=this.get(a),c=b.__dependencies__,d=c.map(function(a){var b=this.get(a);return b.isDefinition===!0,b},this);try{this.set(a,b.apply(this,d)||{},!0)}catch(e){}},this),this},a});
{
"name": "dependency-injector-container",
"version": "1.0.0",
"description": "",
"version": "1.0.1",
"description": "Tiny library which does dependency injection. Basically same pattern like in AngularJS.",
"main": "main.js",

@@ -25,4 +25,5 @@ "scripts": {

"grunt": "^0.4.5",
"grunt-contrib-uglify": "^0.11.0"
"grunt-contrib-uglify": "^0.11.0",
"grunt-contrib-yuidoc": "^0.10.0"
}
}
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