Check if the given dependency is installed.
Checks against `dependencies`, `devDependencies` in project `package.json`.

@param {string} dep Name of the dependency
@returns {boolean} `true` if installed, `false` if not
779311
function isInstalled(dep) {
    if (_.has(exceptions, dep)) return exceptions[dep];
    return installedDeps.has(dep);
}
303655
public static function checkPlatformDependencies($dependencies) {
        if (is_array($dependencies)) {
            foreach ($dependencies as $depName => $depRequire) {
                switch ($depName) {
                    case 'php':
                        if (self::satisfies(PHP_VERSION, $depRequire)) {
                            unset($dependencies[$depName]);
                        }
                        break;
                    default:
                        break;
                }
            }
        }
        return $dependencies;
    }
619667
function getDirectRequires(p) {
      return p.dependencies.filter(function(d) {
        return DIRECT_REQUIRES_REG.test(d);
      }).map(function(d) {
        return "require('"+ getDependencyPath(d, p) +"');";
      }).join('\n');
    }
31094
def is_installed(name):
    
    pkgs = installed_packages()
    for pkge in pkgs:
        if pkge.name == name:
            return True
    return False
1357372
function filterDepWithoutEntryPoints(dep) {
  // Return true if we want to add a dependency to externals
  try {
    // If the root of the dependency has an index.js, return true
    if (fs.existsSync(path.join(__dirname, `node_modules/${dep}/index.js`))) {
      return false;
    }
    const pgkString = fs
      .readFileSync(path.join(__dirname, `node_modules/${dep}/package.json`))
      .toString();
    const pkg = JSON.parse(pgkString);
    const fields = ['main', 'module', 'jsnext:main', 'browser'];
    return !fields.some(field => field in pkg);
  } catch (e) {
    console.log(e);
    return true;
  }
}
572981
def check_dependency(self, dependency_path):
        """"""
        stored_hash = self._stamp_file_hashes.get(dependency_path)

        # This file was newly added, or we don't have a file
        # with stored hashes yet. Assume out of date.
        if not stored_hash:
            return False

        return stored_hash == _sha1_for_file(dependency_path)
25814
public function checkPhpDependencies()
    {
        $errors = array();
        foreach($this->getDependencyPhpExtensions() as $dep)
        {
            if(!extension_loaded($dep['name'])) {
                $errors[] = $dep;
            }
        }
        if(count($errors)) {
            return $errors;
        }
        return true;
    }
629964
public boolean dependsOn(AddOn addOn) {
		if (dependencies == null || dependencies.getAddOns().isEmpty()) {
			return false;
		}

		return dependsOn(dependencies.getAddOns(), addOn);
	}
583408
function processSource(code, dependencyList, depedencyName) {
    // Replace function declarations
    const packageName = dependencyList[depedencyName].packageName;
    code = code.replace(/(\s*)function\s([A-z]*)\s*\(*/g, `$1function ${packageName}_$2(`);

    // TODO replace function calls to dependencies
    const dependencies = dependencyList[depedencyName].dependencies;
    if (dependencies) {
        for (const dependency of Reflect.ownKeys(dependencies)) {
            const oldPrefix = dependencyList[dependency].packageName;
            console.log(oldPrefix);
            var re = new RegExp(`[ ]*${oldPrefix}_([A-z]*)[ ]*\\(`, "g");
            code = code.replace(re, ` ${dependency}_$1(`);
        }
    }
    return code;
}
1092202
def is_deb_package_installed(pkg):
    

    with settings(hide('warnings', 'running', 'stdout', 'stderr'),
                  warn_only=True, capture=True):

        result = sudo('dpkg-query -l "%s" | grep -q ^.i' % pkg)
        return not bool(result.return_code)
218689
function getUnsatisfiedDeps(deps, versions, options) {
	const ownDependencies = getOwnDependencies(options);

	return deps.filter(dep => {
		const required = versions[dep];

		if (required && !semver.validRange(required)) {
			throw new MrmError(
				`Invalid npm version: ${required}. Use proper semver range syntax.`
			);
		}

		const installed = getInstalledVersion(dep);

		// Package isn’t installed yet
		if (!installed) {
			return true;
		}

		// Module is installed but not in package.json dependencies
		if (!ownDependencies[dep]) {
			return true;
		}

		// No required version specified
		if (!required) {
			// Install if the pacakge isn’t installed
			return !installed;
		}

		// Install if installed version doesn't satisfy range
		return !semver.satisfies(installed, required);
	});
}
585162
public void addDependency(JSModule dep) {
    checkNotNull(dep);
    Preconditions.checkState(dep != this, "Cannot add dependency on self", this);
    deps.add(dep);
  }
791155
function (packageList)
		{
			if (!_.isObject(packageList))
				return false;

			var pkgList = _.keys(packageList);
			var pkgRequire;
			var pkgName;
			var pkgInfo;
			var depName;
			var depVersion;
			var i=0;
			var valid;
			var error;
			while (pkgList.length > 0)
			{
				valid=true;
				error=[];
				pkgName=pkgList[i];
				pkgInfo=packageList[pkgName];
				pkgRequire=pkgInfo.require;

				for (p in pkgRequire)
				{
					depName = p;
					depVersion = pkgRequire[p];
					if (packageList[depName]==undefined)
					{ error.push(depName+'@'+depVersion+' is not installed.'); continue; }
					if (depVersion!=="*" && packageList[depName].version!=depVersion)
					{ error.push(depName+' needs to be '+depVersion); }
				}

				if (valid||error.length>0)
				{
					if (error.length>0)
					{
						delete packageList[pkgName];
						for (e in error)
							self.e.log('Error on loading `'+pkgName+'`: '+error[e],'error');
					}
				
					pkgList.splice(i,1);
				}

				i++;
				if (i>=pkgList.length)
					i=0;
			}
		}
1070658
function dependenciesExists(schema) {
    var deps = DependenciesMap[schema];
    var f = false;
    deps.forEach(function (d) {
        f = SavedSchemas.indexOf(d) > -1
    });
    return f;
}
794629
function findDependency(name, packageJson) {
  if (packageJson.dependencies && packageJson.dependencies[name]) {
    return packageJson.dependencies[name];
  }
  if (packageJson.devDependencies && packageJson.devDependencies[name]) {
    return packageJson.devDependencies[name];
  }
  return null;
}
369454
function validateDependencies(configDir) {
  const packageJsonPath = path.join(findup.sync(configDir, 'package.json'), 'package.json');
  const packageJson = require(packageJsonPath);
  DEPENDENCIES.forEach(validateDependency.bind(null, packageJson));
}
408033
function isPackageAlreadyInstalled(packageInstallFolder) {
    try {
        const flagFilePath = path.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
        if (!fs.existsSync(flagFilePath)) {
            return false;
        }
        const fileContents = fs.readFileSync(flagFilePath).toString();
        return fileContents.trim() === process.version;
    }
    catch (e) {
        return false;
    }
}