Recursively resolve a set of dependencies to fixed versions

@param {Object} dependencies - Dedendencies with ranges to resolve
@param {Boolean} root - Boolean indicating if these are root dependencies
@returns {void}
428859
async function recDependencies(dependencies, root) {
    let url;

    // TODO think about doing this in parallel using promises

    for (const dependency of Reflect.ownKeys(dependencies)) {
        const range = dependencies[dependency];
        url = `${constants.FIREBASE_DATABASE_URL}/package/${dependency}/versions.json`;
        const versions = await request({
            url,
            method: "GET",
            json: true,
            headers: {
                "content-type": "application/json",
            },
        });

        // Translate db versions to semver versions
        const semverVersions = {};
        for (const version of Reflect.ownKeys(versions)) {
            semverVersions[version.replace(/_/g, '.')] = true;
        }
        const semverMatch = semver.maxSatisfying(Reflect.ownKeys(semverVersions), range);
        const match = semverMatch.replace(/\./g, '_');
        const versionKey = `${dependency}_${match}`;

        // Set result
        if (dependencies[dependency]) {
            Reflect.deleteProperty(dependencies, dependency);
        }
        dependencies[versionKey] = true;

        // check if in dependency list yet
        if (!depencyList[versionKey]) {
            // Resolve new dependencies
            url = `${constants.FIREBASE_DATABASE_URL}/package/${dependency}/version/${match}/dependencies.json`;
            const newDependencies = await request({
                url,
                method: "GET",
                json: true,
                headers: {
                    "content-type": "application/json",
                },
            });

            // Add to dependencyList
            depencyList[versionKey] = {};

            // Resolve new dependencies
            if (newDependencies) {
                depencyList[versionKey].dependencies = await recDependencies(newDependencies);
            }
        }

        if (root) {
            depencyList[versionKey].isRootDependency = true;
        }
        depencyList[versionKey].packageName = dependency;
        depencyList[versionKey].version = match;
    }
    return dependencies;
}
766708
private void resolve(T element, List<T> result) {
        Set<T> dependencies = blockedBy.get(element);
        if (dependencies != null) {
            for (T dependency : dependencies) {
                resolve(dependency, result);
            }
            blockedBy.remove(element);
            result.add(element);
        }
    }
1104986
async function downloadDependencies(rootFolder, dependencyList) {
    const includeFolder = path.join(rootFolder, constants.INCLUDE_DIR);
    fs.removeSync(includeFolder);
    const contentPath = path.join(includeFolder, 'content.json');

    // Create new content.json
    createFile({
        name: contentPath,
        source: JSON.stringify(dependencyList),
    });

    // Extensions
    const extensions = eaft.getCodeExtensions();

    // Download new dependencies
    for (const dependency of Reflect.ownKeys(dependencyList)) {
        const dependencies = dependencyList[dependency].dependencies;
        const package = dependencyList[dependency].packageName;
        const version = dependencyList[dependency].version;
        const isRootDependency = dependencyList[dependency].isRootDependency;

        // Use package name as dependency if it is a root dependency
        let dependencyName;
        if (isRootDependency) {
            dependencyName = package;
        } else {
            dependencyName = dependency;
        }
        const packagePath = path.join(includeFolder, dependencyName);

        // Get library code
        url = `${constants.FIREBASE_DATABASE_URL}/package/${package}/version/${version}/code.json`;
        const library = await request({
            url,
            method: "GET",
            json: true,
            headers: {
                "content-type": "application/json",
            },
        });

        // Write library files
        for (const file of library.files) {
            const extension = eaft.getExtensionFromFiletype(file.type, extensions);
            const fileName = `${file.name}${extension}`;
            const source = processSource(file.source, dependencyList, dependency);
            createFile({
                name: path.join(packagePath, fileName),
                source,
            });
        }
    }
}
958064
function resolveDependencyPaths(options) {
  function init(items) {
    // Invalid if not Array
    if (Array.isArray(items)) {
      items.forEach((item, idx, items) => {
        const isArray = Array.isArray(item);
        const id = isArray ? item[0] : item;

        // Ignore already resolved
        if ('string' == typeof id) {
          const filepath = dependencies.find(id);

          if (!filepath) return warn(`unable to load plugin ${strong(id)}`, 1);

          if (isArray) {
            item[0] = require(filepath);
          } else {
            items[idx] = require(filepath);
          }
        }
      });
    }
  }

  if (options.plugins) init(options.plugins);
  if (options.presets) init(options.presets);
}
653077
@Override
    protected ResolutionResult resolveDependencies(String projectFolder, String topLevelFolder, Set<String> csprojFiles) {
        if (this.nugetRestoreDependencies) {
            this.resolveCollector.executeRestore(projectFolder, csprojFiles);
            Collection<AgentProjectInfo> projects = this.resolveCollector.collectDependencies(projectFolder);
            Collection<DependencyInfo> dependencies = projects.stream().flatMap(project -> project.getDependencies().stream()).collect(Collectors.toList());
            dependencies.addAll(parseNugetPackageFiles(csprojFiles, true));
            return new ResolutionResult(dependencies, new LinkedList<>(), getDependencyType(), topLevelFolder);
        } else {
            return getResolutionResultFromParsing(topLevelFolder, csprojFiles, false);
        }
    }
79697
def dependency_resolver(dependencies):
    

    items = dict((key, set(dependencies[key])) for key in dependencies)
    resolved_dependencies = []
    while items:
        batch = set(item for value in items.values() for item in value) - set(items.keys())
        batch.update(key for key, value in items.items() if not value)
        resolved_dependencies.append(batch)
        items = dict(((key, value - batch) for key, value in items.items() if value))
    return resolved_dependencies
495092
def resolve_dependencies(self, to_build, depender):
		
		shutit_global.shutit_global_object.yield_to_draw()
		self.log('In resolve_dependencies',level=logging.DEBUG)
		cfg = self.cfg
		for dependee_id in depender.depends_on:
			dependee = self.shutit_map.get(dependee_id)
			# Don't care if module doesn't exist, we check this later
			if (dependee and dependee not in to_build
			    and cfg[dependee_id]['shutit.core.module.build_ifneeded']):
				to_build.append(dependee)
				cfg[dependee_id]['shutit.core.module.build'] = True
		return True
681766
function Dependencies(module, dependencies) {
        "use strict";
    
        var modules = {};
        Object.defineProperty(this, 'modules', {
            'get': function () {
                return modules;
            }
        });
    
        this.set = function (value) {
    
            if (dependencies) {
                console.error('Module dependencies can only be set once')
                return;
            }
            dependencies = value;
            load();
    
        };
    
        var ready;
        Object.defineProperty(this, 'loaded', {
            'get': function () {
                return !!ready;
            }
        });
    
        var callbacks = [];
    
        function done() {
    
            ready = true;
            for (var i in callbacks) {
                callbacks[i](modules);
            }
            callbacks = [];
    
        }
    
        this.done = function (callback) {
    
            if (ready) {
                callback(modules);
                return;
            }
            callbacks.push(callback);
    
        };
    
        var coordinate = new Coordinate(
            'controls',
            'require',
            'react',
            done);
    
        function getResourcePath(resource) {
    
            if (resource.substr(0, 12) === 'application/') {
                return 'application/' + resource.substr(12);
            }
    
            if (resource.substr(0, 10) !== 'libraries/') {
                return resource;
            }
    
            var type;
    
            // Extract the type of the resource to get the moduleID
            var moduleID = (function (resource) {
    
                resource = resource.split('/');
                type = resource.pop();
                return resource.join('/');
    
            })(resource);
    
            var multilanguage = beyond.modules.multilanguage.get(moduleID);
            if (multilanguage && multilanguage.indexOf(type) !== -1) {
                return resource + '/' + beyond.params.language;
            }
            else {
                return resource;
            }
    
        }
    
        function load() {
    
            var mods = [];
    
            var dependency;
            for (var resource in dependencies.require) {
                mods.push(getResourcePath(resource));
            }
    
            // Wait for react to be ready if react is on the dependencies list
            if (mods.indexOf('react') !== -1) {
                module.react.done(coordinate.react);
            }
            else {
                coordinate.done('react');
            }
    
            if (mods.length) {
    
                require(mods, function () {
    
                    var args = [].slice.call(arguments);
    
                    var i = 0;
                    for (dependency in dependencies.require) {
    
                        var name = dependencies.require[dependency];
                        modules[name] = args[i];
                        i++;
    
                    }
    
                    coordinate.done('require');
    
                });
    
            }
            else {
                coordinate.done('require');
            }
    
            if (dependencies.controls instanceof Array && dependencies.controls.length) {
                beyond.controls.import(dependencies.controls, coordinate.controls);
            }
            else {
                coordinate.done('controls');
            }
    
        }
    
        if (dependencies) load();
    
    }
875894
function parseDependencies (source, root) {
  var dependencies = []
  var match = null
  while ((match = configCommentRegex.exec(source))) {
    var option = match[1]
    var value = match[2]
    switch (option) {
      case 'dependency':
      case 'dependencies':
        pushAll(dependencies, parseDependenciesList(root, value))
        break
      default:
        console.warn(
          'WARNING: Unrecognized configuration command ' +
          '"rails-erb-loader-' + option + '". Comment ignored.'
        )
    }
  }
  return dependencies
}
1129727
function(loader, packageJSON, isRoot){
		var deps = crawl.getDependencyMap(loader, packageJSON, isRoot);

		var dependencies = [];
		for(var name in deps) {
			dependencies.push(deps[name]);
		}

		return dependencies;
	}
420896
def resolve_dependencies(self):
    
    self._concatenate_inner(True)
    self._concatenate_inner(False)
    self._insert_breaklines()
71376
function() {
            var dependencies = Array.prototype.slice.call(arguments),
                dfd = $.Deferred();
            
            for (var i = 0; i < dependencies.length; i++) {
                dependencies[i] = this.basePath + dependencies[i];
            }
            
            require(dependencies, function() {
                dfd.resolve.apply(dfd, arguments);
            });
            
            return dfd.promise();
        }
831859
function dependencyLink (pkg, cb) {
  var dependencies = path.join(npm.dir, pkg.name, pkg.version, "node_modules")
    , depBin = path.join(npm.dir, pkg.name, pkg.version, "dep-bin")
  asyncMap(pkg._resolvedDeps, function (dep, cb) {
    log.silly(dep, "dependency")
    var fromRoot = path.join(npm.dir, dep.name, dep.version)
      , dependsOn = path.join( npm.dir, pkg.name, pkg.version
                             , "dependson", dep.name + "@" + dep.version
                             )
    link(fromRoot, dependsOn, cb)
  }, function (dep, cb) {
    var depDir = path.join(npm.dir, dep.name, dep.version, "package")
    readJson(path.join(depDir, "package.json"), function (er, dep) {
      if (er) return cb(er)
      loadPackageDefaults(dep, function (er, dep) {
        if (er) return cb(er)
        asyncMap([dep], function (dep) {
          var toLib = path.join(dependencies, dep.name)
          linkModules(dep, toLib, cb)
        }, function (dep, cb) {
          // link the bins to this pkg's "dep-bin" folder.
          linkBins(dep, depBin, false, cb)
        }, cb)
      })
    })
  }, cb)
}
1206512
function forcedByDependencies(filename) {
	if (!/\.ts$/.test(filename)) return null;
	var fs = require('fs');
	var fsp = require('path');
	function loadPackage(dir) {
		var path = fsp.join(dir, 'package.json');
		if (fs.existsSync(path)) return require(path);
		var ndir = fsp.join(dir, '..');
		if (ndir.length < dir.length && !/[\\\/]node_modules$/.test(ndir)) return loadPackage(ndir);
		else return null;
	}
	var pkg = loadPackage(fsp.resolve(fsp.dirname(filename)));
	if (!pkg) return false;
	return Object.keys(pkg.dependencies || {}).indexOf('streamline-runtime') >= 0 ||
		Object.keys(pkg.devDependencies || {}).indexOf('streamline-runtime') >= 0;
}
706692
function getDependents(dependencyName) {
  return Object.values(allPackages).filter(({info: pkg}) => {
    return (
      pkg.dependencies &&
      Object.keys(pkg.dependencies).indexOf(dependencyName) !== -1
    );
  });
}
342378
function buildDependencyPaths(self, context) {
  var dependencies = {};

  context.__dependencyPaths__.forEach(function (p) {
    var dep = new DependencyFile(p, self.environment.stat(p).mtime,
                                 self.environment.getFileDigest(p));
    dependencies[JSON.stringify(dep)] = dep;
  });

  _.forEach(context.__dependencyAssets__, function (p) {
    var dep, asset;

    if (p === self.pathname) {
      dep = new DependencyFile(p, self.environment.stat(p).mtime,
                               self.environment.getFileDigest(p));
      dependencies[JSON.stringify(dep)] = dep;
      return;
    }

    asset = self.environment.findAsset(p, { bundle: false });

    if (asset) {
      asset.dependencyPaths.forEach(function (dep) {
        dependencies[JSON.stringify(dep)] = dep;
      });
    }
  });

  prop(self, '__dependencyPaths__', _.values(dependencies));
}
171602
function(moduleName, deps, callback) {
  //if (moduleName === "jquery/selector") { debugger; }
  if (!deps && !callback) {
    return;
  }

  // Allow deps to be optional.
  if (!callback && typeof deps === "function") {
    callback = deps;
    deps = undefined;
  }

  // Ensure dependencies is never falsey.
  deps = deps || [];

  // Normalize the dependencies.
  deps = deps.map(function(dep) {
    if (dep.indexOf("./") === -1) {
      return dep;
    }

    // Take off the last path.
    var normalize = moduleName.split("/").slice(0, -1).join("/");

    //console.log(normalize, dep, define.join(normalize, dep));
    return define.join(normalize, dep);
  });

  // Attach to the module map.
  define.map[moduleName] = {
    moduleName: moduleName,
    deps: deps,
    callback: callback
  };
}