MCPcopy Create free account
hub / github.com/MikeRyanDev/angular-decorators / DecoratedModule

Class DecoratedModule

src/module.js:5–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3let _parsers = {};
4
5class DecoratedModule{
6 constructor(name, modules = false){
7 this.name = name;
8 this.moduleList(modules);
9
10 if(modules)
11 {
12 this._module = angular.module(name, this._dependencies);
13 }
14 else
15 {
16 this._module = angular.module(name);
17 }
18 }
19
20 add(...providers){
21 for(let provider of providers)
22 {
23 if( !providerWriter.has('type', provider) ){
24 throw new Error(`Cannot read provider metadata. Are you adding a class that hasn't been decorated yet?`);
25 }
26
27 let type = providerWriter.get('type', provider);
28 let name = providerWriter.get('name', provider);
29 let inject = baseWriter.get('$inject', provider) || [];
30
31 if(_parsers[type]){
32 _parsers[type](provider, name, inject, this._module);
33 }
34 else{
35 throw new Error(`No parser registered for type '${type}'`);
36 }
37 }
38
39 return this;
40 }
41
42 publish(){
43 return this._module;
44 }
45
46 moduleList(modules){
47 this._dependencies = [];
48
49 if(modules && modules.length !== 0){
50 for(let i = 0; i < modules.length; i++)
51 {
52 if(modules[i] && modules[i].name)
53 {
54 this._dependencies.push(modules[i].name);
55 }
56 else if(typeof modules[i] === 'string')
57 {
58 this._dependencies.push(modules[i]);
59 }
60 else
61 {
62 throw new Error(`Cannot read module: Unknown module in ${this.name}`);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected