build/packages.js
function definePackage(name, dependencies, callback) {
    // Adjust arguments
    if (typeof name === "function") {
        callback = name;
        name = null;
        dependencies = null;
    } else if (typeof dependencies === "function") {
        callback = dependencies;
        dependencies = null;

        if (name instanceof Array) {
            dependencies = name;
            name = null;
        }
    }

    // Check name conflicts
    if (typeof name === "string") {
        if (packages.has(name)) {
            throw new Error("Package '" + name + "' is already loaded!");
        }
    }

    // Resolve timeout
    var timeout = _config2.default.get('package_timeout', 5000),
        timer = null;

    return new _es6Promise.Promise(function (succeed, fail) {

        // Start timeout
        if (typeof timeout === "number") {
            timer = setTimeout(function () {
                timer = null;

                if (_config2.default.get("debug", true)) {
                    throw new Error("Package '" + name + "' timed out!");
                }
            }, timeout);
        }

        // Resolve dependencies
        requireDependencies(dependencies).then(function (requirements) {
            try {

                // register package
                var register = function register(pack) {
                    // cancel timeout
                    if (timer) {
                        clearTimeout(timer);
                        timer = null;
                    }

                    if (pack === false) {
                        return;
                    }

                    if (typeof name === "string") {
                        packages.set(name, pack);
                        events.emit("load:" + name, packages.get(name));
                    }

                    return succeed(pack);
                };

                // Check boot response


                var bootResponse = typeof callback === "function" ? callback(requirements) : callback;return bootResponse instanceof _es6Promise.Promise ? bootResponse.then(register) : register(bootResponse);
            } catch (ex) {
                if (_config2.default.get("debug", true)) {
                    console.error(ex);
                }

                return fail(ex);
            }
        });
    });
}
function definePackage(name, dependencies, callback) {
    // Adjust arguments
    if (typeof name === "function") {
        callback = name;
        name = null;
        dependencies = null;
    } else if (typeof dependencies === "function") {
        callback = dependencies;
        dependencies = null;

        if (name instanceof Array) {
            dependencies = name;
            name = null;
        }
    }

    // Check name conflicts
    if (typeof name === "string") {
        if (packages.has(name)) {
            throw new Error("Package '" + name + "' is already loaded!");
        }
    }

    // Resolve timeout
    var timeout = _config2.default.get('package_timeout', 5000),
        timer = null;

    return new _es6Promise.Promise(function (succeed, fail) {

        // Start timeout
        if (typeof timeout === "number") {
            timer = setTimeout(function () {
                timer = null;

                if (_config2.default.get("debug", true)) {
                    throw new Error("Package '" + name + "' timed out!");
                }
            }, timeout);
        }

        // Resolve dependencies
        requireDependencies(dependencies).then(function (requirements) {
            try {

                // register package
                var register = function register(pack) {
                    // cancel timeout
                    if (timer) {
                        clearTimeout(timer);
                        timer = null;
                    }

                    if (pack === false) {
                        return;
                    }

                    if (typeof name === "string") {
                        packages.set(name, pack);
                        events.emit("load:" + name, packages.get(name));
                    }

                    return succeed(pack);
                };

                // Check boot response


                var bootResponse = typeof callback === "function" ? callback(requirements) : callback;return bootResponse instanceof _es6Promise.Promise ? bootResponse.then(register) : register(bootResponse);
            } catch (ex) {
                if (_config2.default.get("debug", true)) {
                    console.error(ex);
                }

                return fail(ex);
            }
        });
    });
}
function definePackage ( name , dependencies , callback ) { // Adjust arguments if ( typeof name === "function" ) { callback = name ; name = null ; dependencies = null ; } else if ( typeof dependencies === "function" ) { callback = dependencies ; dependencies = null ; if ( name instanceof Array ) { dependencies = name ; name = null ; } } // Check name conflicts if ( typeof name === "string" ) { if ( packages . has ( name ) ) { throw new Error ( "Package '" + name + "' is already loaded!" ) ; } } // Resolve timeout var timeout = _config2 . default . get ( 'package_timeout' , 5000 ) , timer = null ; return new _es6Promise . Promise ( function ( succeed , fail ) { // Start timeout if ( typeof timeout === "number" ) { timer = setTimeout ( function ( ) { timer = null ; if ( _config2 . default . get ( "debug" , true ) ) { throw new Error ( "Package '" + name + "' timed out!" ) ; } } , timeout ) ; } // Resolve dependencies requireDependencies ( dependencies ) . then ( function ( requirements ) { try { // register package var register = function register ( pack ) { // cancel timeout if ( timer ) { clearTimeout ( timer ) ; timer = null ; } if ( pack === false ) { return ; } if ( typeof name === "string" ) { packages . set ( name , pack ) ; events . emit ( "load:" + name , packages . get ( name ) ) ; } return succeed ( pack ) ; } ; // Check boot response var bootResponse = typeof callback === "function" ? callback ( requirements ) : callback ; return bootResponse instanceof _es6Promise . Promise ? bootResponse . then ( register ) : register ( bootResponse ) ; } catch ( ex ) { if ( _config2 . default . get ( "debug" , true ) ) { console . error ( ex ) ; } return fail ( ex ) ; } } ) ; } ) ; }
Define a package

@param name
@param dependencies
@param callback
@returns {Promise.<TResult>}
Define a package