angular-architecture-graph
Version:
Create a graph of an angular project's architecture
35 lines (31 loc) • 945 B
JavaScript
function parseAngularDeps (angularDeps) {
var deps, definition, angularDepsStr, depsProcessed = [];
if (angularDeps instanceof Array) {
definition = angularDeps.pop();
deps = angularDeps;
} else if (angularDeps instanceof Function) {
definition = angularDeps;
// We just care about the wrapper function to the dependencies
angularDepsStr = "" + angularDeps;
angularDepsStr = angularDepsStr.slice(0, angularDepsStr.indexOf("{"));
deps = /\(([^)]+)/.exec(angularDepsStr);
if (deps && deps.length && deps[ 1 ]) {
deps = deps[1].split(/\s*,\s*/);
} else {
deps = [];
}
}
if (deps && deps.length) {
deps.forEach(function (dep) {
dep = dep.trim();
depsProcessed.push(dep);
});
}
return { deps: depsProcessed, definition: definition };
}
var noop = function() {};
module.exports = {
parseAngularDeps: parseAngularDeps,
noop : noop
};
;