| @@ -84,7 +84,7 | |||||
| 84 | }, |
|
84 | }, | |
| 85 | "duplexer": { |
|
85 | "duplexer": { | |
| 86 | "version": "0.1.1", |
|
86 | "version": "0.1.1", | |
| 87 |
"resolved": "http |
|
87 | "resolved": "http://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz", | |
| 88 | "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", |
|
88 | "integrity": "sha1-rOb/gIwc5mtX0ev5eXessCM0z8E=", | |
| 89 | "dev": true |
|
89 | "dev": true | |
| 90 | }, |
|
90 | }, | |
| @@ -129,7 +129,7 | |||||
| 129 | "dependencies": { |
|
129 | "dependencies": { | |
| 130 | "tape": { |
|
130 | "tape": { | |
| 131 | "version": "2.3.3", |
|
131 | "version": "2.3.3", | |
| 132 |
"resolved": "http |
|
132 | "resolved": "http://registry.npmjs.org/tape/-/tape-2.3.3.tgz", | |
| 133 | "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=", |
|
133 | "integrity": "sha1-Lnzgox3wn41oUWZKcYQuDKUFevc=", | |
| 134 | "dev": true, |
|
134 | "dev": true, | |
| 135 | "requires": { |
|
135 | "requires": { | |
| @@ -289,7 +289,7 | |||||
| 289 | }, |
|
289 | }, | |
| 290 | "path-is-absolute": { |
|
290 | "path-is-absolute": { | |
| 291 | "version": "1.0.1", |
|
291 | "version": "1.0.1", | |
| 292 |
"resolved": "http |
|
292 | "resolved": "http://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", | |
| 293 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", |
|
293 | "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", | |
| 294 | "dev": true |
|
294 | "dev": true | |
| 295 | }, |
|
295 | }, | |
| @@ -301,7 +301,7 | |||||
| 301 | }, |
|
301 | }, | |
| 302 | "readable-stream": { |
|
302 | "readable-stream": { | |
| 303 | "version": "1.1.14", |
|
303 | "version": "1.1.14", | |
| 304 |
"resolved": "http |
|
304 | "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", | |
| 305 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", |
|
305 | "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", | |
| 306 | "dev": true, |
|
306 | "dev": true, | |
| 307 | "requires": { |
|
307 | "requires": { | |
| @@ -354,7 +354,7 | |||||
| 354 | }, |
|
354 | }, | |
| 355 | "string_decoder": { |
|
355 | "string_decoder": { | |
| 356 | "version": "0.10.31", |
|
356 | "version": "0.10.31", | |
| 357 |
"resolved": "http |
|
357 | "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", | |
| 358 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", |
|
358 | "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=", | |
| 359 | "dev": true |
|
359 | "dev": true | |
| 360 | }, |
|
360 | }, | |
| @@ -411,13 +411,13 | |||||
| 411 | }, |
|
411 | }, | |
| 412 | "through": { |
|
412 | "through": { | |
| 413 | "version": "2.3.8", |
|
413 | "version": "2.3.8", | |
| 414 |
"resolved": "http |
|
414 | "resolved": "http://registry.npmjs.org/through/-/through-2.3.8.tgz", | |
| 415 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", |
|
415 | "integrity": "sha1-DdTJ/6q8NXlgsbckEV1+Doai4fU=", | |
| 416 | "dev": true |
|
416 | "dev": true | |
| 417 | }, |
|
417 | }, | |
| 418 | "through2": { |
|
418 | "through2": { | |
| 419 | "version": "0.2.3", |
|
419 | "version": "0.2.3", | |
| 420 |
"resolved": "http |
|
420 | "resolved": "http://registry.npmjs.org/through2/-/through2-0.2.3.tgz", | |
| 421 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", |
|
421 | "integrity": "sha1-6zKE2k6jEbbMis42U3SKUqvyWj8=", | |
| 422 | "dev": true, |
|
422 | "dev": true, | |
| 423 | "requires": { |
|
423 | "requires": { | |
| @@ -140,7 +140,7 export class Configuration { | |||||
| 140 | } |
|
140 | } | |
| 141 |
|
141 | |||
| 142 | async _loadModule(moduleName: string) { |
|
142 | async _loadModule(moduleName: string) { | |
| 143 |
trace. |
|
143 | trace.debug("loadModule {0}", moduleName); | |
| 144 |
|
144 | |||
| 145 | const m = await new Promise(fulfill => { |
|
145 | const m = await new Promise(fulfill => { | |
| 146 | this._require([moduleName], fulfill); |
|
146 | this._require([moduleName], fulfill); | |
| @@ -229,7 +229,6 export class ServiceDescriptor implement | |||||
| 229 | injectMethod(instance, m, context, spec[m]); |
|
229 | injectMethod(instance, m, context, spec[m]); | |
| 230 | }); |
|
230 | }); | |
| 231 | } |
|
231 | } | |
| 232 |
|
||||
| 233 | return instance; |
|
232 | return instance; | |
| 234 | } |
|
233 | } | |
| 235 | } |
|
234 | } | |
| @@ -15,13 +15,19 export class TypeServiceDescriptor exten | |||||
| 15 |
|
15 | |||
| 16 | const ctor = this._type = opts.type; |
|
16 | const ctor = this._type = opts.type; | |
| 17 |
|
17 | |||
| 18 |
if (this._params |
|
18 | if (this._params) { | |
|
|
19 | if (this._params.length) { | |||
| 19 | this._factory = (...args) => { |
|
20 | this._factory = (...args) => { | |
| 20 | const t = Object.create(ctor.prototype); |
|
21 | const t = Object.create(ctor.prototype); | |
| 21 | const inst = ctor.apply(t, args); |
|
22 | const inst = ctor.apply(t, args); | |
| 22 | return isPrimitive(inst) ? t : inst; |
|
23 | return isPrimitive(inst) ? t : inst; | |
| 23 | }; |
|
24 | }; | |
| 24 | } else { |
|
25 | } else { | |
|
|
26 | this._factory = arg => { | |||
|
|
27 | return new ctor(arg); | |||
|
|
28 | }; | |||
|
|
29 | } | |||
|
|
30 | } else { | |||
| 25 | this._factory = () => { |
|
31 | this._factory = () => { | |
| 26 | return new ctor(); |
|
32 | return new ctor(); | |
| 27 | }; |
|
33 | }; | |
| @@ -10,6 +10,9 define({ | |||||
| 10 | provider: { |
|
10 | provider: { | |
| 11 | $dependency: "db" |
|
11 | $dependency: "db" | |
| 12 | } |
|
12 | } | |
|
|
13 | }, | |||
|
|
14 | foo: { | |||
|
|
15 | $type: "./Foo:Foo" | |||
| 13 | } |
|
16 | } | |
| 14 | } |
|
17 | } | |
| 15 | }, |
|
18 | }, | |
| @@ -87,7 +87,8 test("Load configuration from module", a | |||||
| 87 |
|
87 | |||
| 88 | t.assert(!isNull(f1), "foo should be not null"); |
|
88 | t.assert(!isNull(f1), "foo should be not null"); | |
| 89 |
|
89 | |||
| 90 | const b1 = container.resolve("bar"); |
|
90 | const b1 = container.resolve("bar") as Bar; | |
| 91 |
|
91 | |||
| 92 |
t.assert(!isNull(b1), " |
|
92 | t.assert(!isNull(b1), "bar should not be null"); | |
|
|
93 | t.assert(!isNull(b1.foo), "bar.foo should not be null"); | |||
| 93 | }); |
|
94 | }); | |
General Comments 0
You need to be logged in to leave comments.
Login now
