example/lib/requirejs/require.js
function configurePackageDir(pkgs, currentPackages, dir) {
        var i, location, pkgObj;

        for (i = 0; (pkgObj = currentPackages[i]); i++) {
            pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
            location = pkgObj.location;

            //Add dir to the path, but avoid paths that start with a slash
            //or have a colon (indicates a protocol)
            if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) {
                location = dir + "/" + (location || pkgObj.name);
            }

            //Create a brand new object on pkgs, since currentPackages can
            //be passed in again, and config.pkgs is the internal transformed
            //state for all package configs.
            pkgs[pkgObj.name] = {
                name: pkgObj.name,
                location: location || pkgObj.name,
                //Remove leading dot in main, so main paths are normalized,
                //and remove any trailing .js, since different package
                //envs have different conventions: some use a module name,
                //some use a file name.
                main: (pkgObj.main || "main")
                      .replace(currDirRegExp, '')
                      .replace(jsSuffixRegExp, '')
            };
        }
    }
function configurePackageDir(pkgs, currentPackages, dir) {
        var i, location, pkgObj;

        for (i = 0; (pkgObj = currentPackages[i]); i++) {
            pkgObj = typeof pkgObj === "string" ? { name: pkgObj } : pkgObj;
            location = pkgObj.location;

            //Add dir to the path, but avoid paths that start with a slash
            //or have a colon (indicates a protocol)
            if (dir && (!location || (location.indexOf("/") !== 0 && location.indexOf(":") === -1))) {
                location = dir + "/" + (location || pkgObj.name);
            }

            //Create a brand new object on pkgs, since currentPackages can
            //be passed in again, and config.pkgs is the internal transformed
            //state for all package configs.
            pkgs[pkgObj.name] = {
                name: pkgObj.name,
                location: location || pkgObj.name,
                //Remove leading dot in main, so main paths are normalized,
                //and remove any trailing .js, since different package
                //envs have different conventions: some use a module name,
                //some use a file name.
                main: (pkgObj.main || "main")
                      .replace(currDirRegExp, '')
                      .replace(jsSuffixRegExp, '')
            };
        }
    }
function configurePackageDir ( pkgs , currentPackages , dir ) { var i , location , pkgObj ; for ( i = 0 ; ( pkgObj = currentPackages [ i ] ) ; i ++ ) { pkgObj = typeof pkgObj === "string" ? { name : pkgObj } : pkgObj ; location = pkgObj . location ; //Add dir to the path, but avoid paths that start with a slash //or have a colon (indicates a protocol) if ( dir && ( ! location || ( location . indexOf ( "/" ) !== 0 && location . indexOf ( ":" ) === - 1 ) ) ) { location = dir + "/" + ( location || pkgObj . name ) ; } //Create a brand new object on pkgs, since currentPackages can //be passed in again, and config.pkgs is the internal transformed //state for all package configs. pkgs [ pkgObj . name ] = { name : pkgObj . name , location : location || pkgObj . name , //Remove leading dot in main, so main paths are normalized, //and remove any trailing .js, since different package //envs have different conventions: some use a module name, //some use a file name. main : ( pkgObj . main || "main" ) . replace ( currDirRegExp , '' ) . replace ( jsSuffixRegExp , '' ) } ; } }
Used to set up package paths from a packagePaths or packages config object.
@param {Object} pkgs the object to store the new package config
@param {Array} currentPackages an array of packages to configure
@param {String} [dir] a prefix dir to use.
Used to set up package paths from a packagePaths or packages config object .