boxed-injector
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -179,25 +179,31 @@ 'use strict'; | ||
if (!this.factories[name] && !this.instances[name]) { | ||
if (!Array.isArray(name) && !this.factories[name] && !this.instances[name]) { | ||
return []; | ||
} | ||
var entity = this.factories[name] ? this.factories[name] : this.instances[name]; | ||
var entityKeys = Array.isArray(name) ? name : [name]; | ||
var deps = entityKeys.reduce(function (children, key) { | ||
var entity = _this4.factories[key] ? _this4.factories[key] : _this4.instances[key]; | ||
return children.concat(entity.depends); | ||
}, []); | ||
var graph = entity.depends.reduce(function (obj, elem) { | ||
if (!obj.hash[elem]) { | ||
obj.all.push(elem); | ||
obj.hash[elem] = true; | ||
} | ||
var graph = deps.reduce(function (obj, elem) { | ||
var add = function add(e) { | ||
if (!obj.hash[e]) { | ||
obj.all.push(e); | ||
obj.hash[e] = true; | ||
} | ||
}; | ||
add(elem); | ||
var child = _this4.graph(elem, true); | ||
child.all.forEach(function (childDep) { | ||
if (!obj.hash[childDep]) { | ||
obj.all.push(childDep); | ||
obj.hash[childDep] = true; | ||
} | ||
add(childDep); | ||
}); | ||
return obj; | ||
}, { all: [], hash: {} }); | ||
}, { | ||
all: [], | ||
hash: {} | ||
}); | ||
@@ -204,0 +210,0 @@ if (!nested) { |
@@ -188,3 +188,2 @@ 'use strict'; | ||
injector.factory('foo', function (txt) { | ||
console.log(txt); | ||
this.bar = txt; | ||
@@ -233,2 +232,5 @@ }, { depends: ['asdf'] }); | ||
}, { depends: [], function: true }); | ||
injector.factory('g', function () { | ||
return 'g'; | ||
}, { depends: [], function: true }); | ||
injector.factory('b', function (x) { | ||
@@ -246,2 +248,5 @@ return x; | ||
}, { depends: ['d', 'a'], function: true }); | ||
injector.factory('f', function (x) { | ||
return x; | ||
}, { depends: ['d', 'g'], function: true }); | ||
expect(injector.graph('a')).toEqual([]); | ||
@@ -254,2 +259,3 @@ expect(injector.graph('asdf')).toEqual([]); | ||
expect(eResult).toEqual(['d', 'c', 'b', 'a']); | ||
expect(injector.graph(['e', 'f'])).toEqual(['d', 'c', 'b', 'a', 'g']); | ||
}); | ||
@@ -256,0 +262,0 @@ }); |
{ | ||
"name": "boxed-injector", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Dependency Injection Tools", | ||
@@ -5,0 +5,0 @@ "homepage": "", |
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
36636
739