function initModule(module) {

        var index = 0;
        var envModule = {};

        // call body to create a service
        Sylx.log("Sylx: Initializing module " + module.name);

        // determine whether module body was provided as an object or a function
        if (typeof module.body === 'function') {
            // functions need their dependencies to be provided
            var moduleArgs = [];
            if (module.dependencies.length) {
                for (index = 0; index < module.dependencies.length; index++) {
                    // content module?
                    var dependency = modules[module.dependencies[index]];
                    if (dependency.contents)
                        moduleArgs.push(dependency.contents);
                    else
                        moduleArgs.push(dependency.body);
                }
            }
            module.body = module.body.apply(environment, moduleArgs) || {};
        }

        // create new object for the module in the environment
        // set our own proto only if original object has no "custom" prototype
        if (Object.getPrototypeOf(module.body) === Object.prototype) {
            envModule = Object.assign(Object.create(environment), module.body);
        } else {
            envModule = module.body;
        }

        // determine namespacing and store new module
        var split = module.name.split('.');
        var parent = environment;
        var path = '',
            parentPath = '';
        for (index = 0; index < split.length; index++) {
            var current = split[index];
            path += current;
            if (parseInt(index) === (split.length - 1)) {
                parent[current] = envModule;
                if (parentPath && modules[parentPath])
                    modules[parentPath].contents[current] = envModule;
            } else {
                // Create new content module (folder) if needed
                modules[path] = modules[path] || {
                    contents: {}
                };
                parent[current] = parent[current] || {};
                parent = parent[current];
            }
            parentPath = path;
            path += '.';
        }

        // execute the onload method if it exists and is a function
        if (typeof envModule.onload === 'function') envModule.onload();

        // flag as loaded
        module.loaded = true;

        // see if any previously loaded module was waiting for this module and try to init it
        if (dependenciesQueue[module.name]) {
            // iterate through dependencies backwards
            for (index = dependenciesQueue[module.name].length - 1; index >= 0; index--) {
                checkForDependencies(modules[dependenciesQueue[module.name][index]], module.name);
            }
        }
    }
/**
     * Initializes a module once all of its dependencies have been loaded
     * @param {object} module - The module to load
     */
Initializes a module once all of its dependencies have been loaded
@param {object} module - The module to load
Initializes a module once all of its dependencies have been loaded @param { object } module - The module to load
function initModule(module) {
        var index = 0;
        var envModule = {};
        Sylx.log("Sylx: Initializing module " + module.name);
        if (typeof module.body === 'function') {
            var moduleArgs = [];
            if (module.dependencies.length) {
                for (index = 0; index < module.dependencies.length; index++) {
                    var dependency = modules[module.dependencies[index]];
                    if (dependency.contents)
                        moduleArgs.push(dependency.contents);
                    else
                        moduleArgs.push(dependency.body);
                }
            }
            module.body = module.body.apply(environment, moduleArgs) || {};
        }
        if (Object.getPrototypeOf(module.body) === Object.prototype) {
            envModule = Object.assign(Object.create(environment), module.body);
        } else {
            envModule = module.body;
        }
        var split = module.name.split('.');
        var parent = environment;
        var path = '',
            parentPath = '';
        for (index = 0; index < split.length; index++) {
            var current = split[index];
            path += current;
            if (parseInt(index) === (split.length - 1)) {
                parent[current] = envModule;
                if (parentPath && modules[parentPath])
                    modules[parentPath].contents[current] = envModule;
            } else {
                modules[path] = modules[path] || {
                    contents: {}
                };
                parent[current] = parent[current] || {};
                parent = parent[current];
            }
            parentPath = path;
            path += '.';
        }
        if (typeof envModule.onload === 'function') envModule.onload();
        module.loaded = true;
        if (dependenciesQueue[module.name]) {
            for (index = dependenciesQueue[module.name].length - 1; index >= 0; index--) {
                checkForDependencies(modules[dependenciesQueue[module.name][index]], module.name);
            }
        }
    }
function initModule ( module ) { var index = 0 ; var envModule = { } ; Sylx . log ( "Sylx: Initializing module " + module . name ) ; if ( typeof module . body === 'function' ) { var moduleArgs = [ ] ; if ( module . dependencies . length ) { for ( index = 0 ; index < module . dependencies . length ; index ++ ) { var dependency = modules [ module . dependencies [ index ] ] ; if ( dependency . contents ) moduleArgs . push ( dependency . contents ) ; else moduleArgs . push ( dependency . body ) ; } } module . body = module . body . apply ( environment , moduleArgs ) || { } ; } if ( Object . getPrototypeOf ( module . body ) === Object . prototype ) { envModule = Object . assign ( Object . create ( environment ) , module . body ) ; } else { envModule = module . body ; } var split = module . name . split ( '.' ) ; var parent = environment ; var path = '' , parentPath = '' ; for ( index = 0 ; index < split . length ; index ++ ) { var current = split [ index ] ; path += current ; if ( parseInt ( index ) === ( split . length - 1 ) ) { parent [ current ] = envModule ; if ( parentPath && modules [ parentPath ] ) modules [ parentPath ] . contents [ current ] = envModule ; } else { modules [ path ] = modules [ path ] || { contents : { } } ; parent [ current ] = parent [ current ] || { } ; parent = parent [ current ] ; } parentPath = path ; path += '.' ; } if ( typeof envModule . onload === 'function' ) envModule . onload ( ) ; module . loaded = true ; if ( dependenciesQueue [ module . name ] ) { for ( index = dependenciesQueue [ module . name ] . length - 1 ; index >= 0 ; index -- ) { checkForDependencies ( modules [ dependenciesQueue [ module . name ] [ index ] ] , module . name ) ; } } }
Initializes a module once all of its dependencies have been loaded
 @param {object} module - The module to load
Initializes a module once all of its dependencies have been loaded @param { object } module - The module to load
// call body to create a service // determine whether module body was provided as an object or a function // functions need their dependencies to be provided // content module? // create new object for the module in the environment // set our own proto only if original object has no "custom" prototype // determine namespacing and store new module // Create new content module (folder) if needed // execute the onload method if it exists and is a function // flag as loaded // see if any previously loaded module was waiting for this module and try to init it // iterate through dependencies backwards