Check if one of the scopes is in the allowedScopes array
@param {String[]} allowedScopes An array of required scopes
@param {String[]} scopes An array of granted scopes
@returns {boolean}
434658
function isScopeAllowed(allowedScopes, tokenScopes) {
    allowedScopes = normalizeScope(allowedScopes);
    tokenScopes = normalizeScope(tokenScopes);
    if (allowedScopes.length === 0) {
        return true;
    }
    for (var i = 0, n = allowedScopes.length; i < n; i++) {
        if (tokenScopes.indexOf(allowedScopes[i]) !== -1) {
            return true;
        }
    }
    return false;
}
742528
function fileScope(filename) {
    filename = path.resolve('', filename || '');
    var result = scopes[filename];
    if (!result) {
      result = create({
        clean: clean,
        removeList: removeList,
        excludeList: excludeList,
        rootScope: rootScope,
        filename: filename,
        argv: argv,
        scopes: scopes,
        processors: processors,
        variants: variants,
        cacheKeys: cacheKeys,
        tags: tags
      });
    }
    return result;
  }
282832
def validate_scopes(self, request):
        
        if not request.scopes:
            request.scopes = utils.scope_to_list(request.scope) or utils.scope_to_list(
                self.request_validator.get_default_scopes(request.client_id, request))
        log.debug('Validating access to scopes %r for client %r (%r).',
                  request.scopes, request.client_id, request.client)
        if not self.request_validator.validate_scopes(request.client_id,
                                                      request.scopes, request.client, request):
            raise errors.InvalidScopeError(request=request)
92511
func (r *Rule) CheckScopes(scopes []string) error {
	var notAllowed []string
	for _, scope := range scopes {
		if !r.AllowedScopes.Has(scope) {
			notAllowed = append(notAllowed, scope)
		}
	}
	if len(notAllowed) != 0 {
		return fmt.Errorf("following scopes are not allowed by the rule %q - %q", r.Rule.Name, notAllowed)
	}
	return nil
}
362588
protected function validateScopes($psr, $scopes)
    {
        if (in_array('*', $tokenScopes = $psr->getAttribute('oauth_scopes'))) {
            return true;
        }

        foreach ($scopes as $scope) {
            if (in_array($scope, $tokenScopes)) {
                return true;
            }
        }

        return false;
    }
485378
public function scopeExists($scope)
    {
        // Check reserved scopes first.
        $scope = explode(' ', trim($scope));
        $reservedScope = $this->getReservedScopes();
        $nonReservedScopes = array_diff($scope, $reservedScope);
        if (count($nonReservedScopes) == 0) {
            return true;
        } else {
            // Check the storage for non-reserved scopes.
            $nonReservedScopes = implode(' ', $nonReservedScopes);

            return $this->storage->scopeExists($nonReservedScopes);
        }
    }
523630
private Map<Object, CacheItem> getScopeCache(String scope) throws InvalidScopeException {
        Map<Object, CacheItem> scopeCache = scopeCaches.get(scope);
        if (scopeCache == null) {
            throw new InvalidScopeException("The scope " + scope + " doesn't exist");
        } else {
            return scopeCache;
        }
    }
1063843
function findVariablesInScope(scope) {
				scope.variables.forEach(function(variable) {
					var hasBuiltin = options.builtinGlobals && "writeable" in variable;
					var count = (hasBuiltin ? 1 : 0) + variable.identifiers.length;

					if (count >= 2) {
						variable.identifiers.sort(function(a, b) {
							return a.range[1] - b.range[1];
						});

						for (var i = hasBuiltin ? 0 : 1, l = variable.identifiers.length; i < l; i++) {
							context.report(
								variable.identifiers[i],
								ProblemMessages['no-redeclare'], {0:variable.name});
						}
					}
				});

			}
564495
function nodeIsUnscopedBinding(item: Node): boolean {
  const value = getValue(item);
  return value && value.unscoped;
}
831188
function(url) {
  if (!allowedResources) {
    return true;
  }
  for (var i=0; i<allowedResources.length; i++) {
    var allow = allowedResources[i];
    var index = url.indexOf(allow);
    if (index == 0) {
      return true;
    }
  }
  return false;
}
324538
protected function validateTokenScopes(array $scopes)
    {
        $scopes = array_map(function ($scope) {
            return (string) $scope;
        }, $scopes);

        $registeredScopes = $this->scopeService->getAll();

        $registeredScopes = array_map(function ($scope) {
            return (string) $scope;
        }, $registeredScopes);

        $diff = array_diff($scopes, $registeredScopes);

        if (count($diff) > 0) {
            throw OAuth2Exception::invalidScope(sprintf(
                'Some scope(s) do not exist: %s',
                implode(', ', $diff)
            ));
        }
    }
1270728
function validateScopeValues(scope, pageCount) {
                // Block where the page is larger than the pageCount
                if (scope.page > pageCount) {
                    scope.page = pageCount;
                }

                // Block where the page is less than 0
                if (scope.page <= 0) {
                    scope.page = 1;
                }

                // Block where adjacent value is 0 or below
                if (scope.adjacent <= 0) {
                    scope.adjacent = 2;
                }

                // Hide from page if we have 1 or less pages
                // if directed to hide empty
                if (pageCount <= 1) {
                    scope.Hide = scope.hideIfEmpty;
                }
            }
511674
private boolean isDomainInScope(String domain) {
		for (String scope : scopes) {
			if (domain.matches(scope)) {
				return true;
			}
		}
		return false;
	}
1368607
@SuppressWarnings("unchecked")
    public <S extends Scope> Set<S> getScopesByType(Class<S> scopeType) {
        Set<S> typedScopes = new HashSet<>();
        for (Scope scope : getScopes()) {
            if (scopeType.isInstance(scope)) {
                typedScopes.add((S) scope);
            }
        }
        return typedScopes;
    }
1104182
def has_visible_scopes?(resource)
      resource.participatory_space.scopes_enabled? &&
        resource.scope.present? &&
        resource.participatory_space.scope != resource.scope
    end
1125106
public function matchScopes($scopes): bool
    {
        $scopes = is_string($scopes) ? explode(' ', $scopes) : $scopes;
        $diff = array_diff($scopes, $this->scopes);

        return empty($diff);
    }
169353
function loadScopes(scopes) {
  var scopeMapping = {};
  if (typeof scopes === 'object') {
    for (var s in scopes) {
      var routes = [];
      var entries = scopes[s];
      debug('Scope: %s routes: %j', s, entries);
      if (Array.isArray(entries)) {
        for (var j = 0, k = entries.length; j < k; j++) {
          var route = entries[j];
          if (typeof route === 'string') {
            routes.push({methods: ['all'], path: route,
              regexp: pathToRegexp(route, [], {end: false})});
          } else {
            var methods = helpers.normalizeList(methods);
            if (methods.length === 0) {
              methods.push('all');
            }
            methods = methods.map(toLowerCase);
            routes.push({methods: methods,
              path: route.path,
              regexp: pathToRegexp(route.path, [], {end: false})});
          }
        }
      } else {
        debug('Routes must be an array: %j', entries);
      }
      scopeMapping[s] = routes;
    }
  } else if (typeof scopes === 'string') {
    scopes = helpers.normalizeList(scopes);
    for (var i = 0, n = scopes.length; i < n; i++) {
      scopeMapping[scopes[i]] = [
        {methods: 'all', path: '/.+', regexp: /\/.+/}
      ];
    }
  }
  return scopeMapping;
}