Comparing version 0.5.5 to 0.5.6
32
index.js
@@ -43,3 +43,2 @@ /*-------------------------------------------------------------------------- | ||
} | ||
return null; | ||
@@ -67,11 +66,13 @@ }); | ||
Domain.prototype.factory = function (name, initializer) { | ||
if (!this.isfunction(initializer)) { | ||
throw Error('pang: initializer should be a function.'); | ||
} | ||
if (this.isfunction(initializer)) { | ||
var names = this.extractargs(initializer); | ||
var names = this.extractargs(initializer); | ||
this.dependencies.push(new Dependency(this, name, names, initializer, false, null)); | ||
var dependency = new Dependency(this, name, names, initializer, false, null); | ||
return this; | ||
} | ||
this.dependencies.push(dependency); | ||
this.dependencies.push(new Dependency(this, name, [], function () { | ||
return initializer; | ||
}, false, null)); | ||
@@ -103,5 +104,3 @@ return this; | ||
for (var i = 0; i < this.dependencies.length; i++) { | ||
var dependency = new Dependency(domain, this.dependencies[i].name, this.dependencies[i].names, this.dependencies[i].initializer, false, null); | ||
domain.dependencies.push(dependency); | ||
domain.dependencies.push(new Dependency(domain, this.dependencies[i].name, this.dependencies[i].names, this.dependencies[i].initializer, false, null)); | ||
} | ||
@@ -167,11 +166,8 @@ | ||
if (!match) { | ||
return []; | ||
if (match) { | ||
if (match[1]) { | ||
return match[1].split(/\s*,\s*/); | ||
} | ||
} | ||
if (match[1]) { | ||
var arguments = match[1].split(/\s*,\s*/); | ||
} | ||
return arguments; | ||
return []; | ||
}; | ||
@@ -178,0 +174,0 @@ return Domain; |
{ | ||
"name": "pang", | ||
"version": "0.5.5", | ||
"version": "0.5.6", | ||
"description": "A simple dependency injection library for node", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -9,3 +9,3 @@ # pang | ||
The following example illustates setting up a pang domain/kernel. | ||
The following example illustates setting up a pang domain/kernel. | ||
@@ -18,6 +18,3 @@ ```javascript | ||
domain.factory('configuration', function() { | ||
return new Configuration() | ||
}) | ||
domain.factory('http', require('http')) | ||
@@ -29,5 +26,5 @@ domain.factory('repository', function(configuration) { | ||
domain.factory('server', function(configuration, repository) { | ||
domain.factory('server', function(configuration, http, repository) { | ||
return new Server(configuration, repository) | ||
return new Server(configuration, http, repository) | ||
}) | ||
@@ -45,3 +42,3 @@ ``` | ||
var instance = domain.singleton('server') | ||
var instance = domain.singleton('repository') | ||
@@ -52,2 +49,2 @@ ### domain.transient() | ||
var instance = domain.transient('server') | ||
var instance = domain.transient('repository') |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10308
5
202
46