1 |
|
2 | function DeferredConfig() {}
|
3 | DeferredConfig.prototype.prepare = function() {};
|
4 | DeferredConfig.prototype.resolve = function() {};
|
5 |
|
6 |
|
7 | function deferConfig(func) {
|
8 | var obj = Object.create(DeferredConfig.prototype);
|
9 | obj.prepare = function(config, prop, property) {
|
10 | var original = prop[property]._original;
|
11 | obj.resolve = function() {
|
12 | var value = func.call(config, config, original);
|
13 | Object.defineProperty(prop, property, {value: value});
|
14 | return value;
|
15 | };
|
16 | Object.defineProperty(prop, property, {get: function() { return obj.resolve(); }});
|
17 | return obj;
|
18 | };
|
19 | return obj;
|
20 | }
|
21 |
|
22 | module.exports.deferConfig = deferConfig;
|
23 | module.exports.DeferredConfig = DeferredConfig;
|