Code coverage report for lib/common/decorators.js

Statements: 100% (26 / 26)      Branches: 100% (6 / 6)      Functions: 100% (5 / 5)      Lines: 100% (26 / 26)      Ignored: none     

All files » lib/common/ » decorators.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44    1 1 1 11 10 10 7 7 2   7 7 7 7 7 7     1 1   6 3 3 3 2     1         3       10     1  
///<reference path=".d.ts"/>
"use strict";
var Promise = require("bluebird");
var fiberBootstrap = require("./fiber-bootstrap");
function exported(moduleName) {
    return function (target, propertyKey, descriptor) {
        $injector.publicApi.__modules__[moduleName] = $injector.publicApi.__modules__[moduleName] || {};
        $injector.publicApi.__modules__[moduleName][propertyKey] = function () {
            var args = [];
            for (var _i = 0; _i < arguments.length; _i++) {
                args[_i - 0] = arguments[_i];
            }
            return new Promise(function (onFulfilled, onRejected) {
                var originalModule = $injector.resolve(moduleName);
                var originalMethod = originalModule[propertyKey];
                var result;
                try {
                    result = originalMethod.apply(originalModule, args);
                }
                catch (err) {
                    onRejected(err);
                    return;
                }
                if (result && typeof result.wait === "function") {
                    fiberBootstrap.run(function () {
                        try {
                            var realResult = result.wait();
                            onFulfilled(realResult);
                        }
                        catch (err) {
                            onRejected(err);
                        }
                    });
                }
                else {
                    onFulfilled(result);
                }
            });
        };
        return descriptor;
    };
}
exports.exported = exported;