Resolves the conflict between a max-age and a max-age (m+N value) directive
543077
private void resolveMaxAgeConflicts() {
        long lastModified = requestFile.lastModified();
        String maxAgeString = EMPTY_STRING_VALUE;
        String maxAge = maxAgeDirectives.get(Directive.MAX_AGE);
        String maxAgeMPlus = maxAgeDirectives.get(Directive.MAX_AGE_MPLUS);

        if (maxAgeMPlus != null) {
            String maxAgeMPlusValue = parseMaxAgeMplus(maxAgeMPlus, lastModified);
            if (maxAge != null) {
                maxAgeString = Long.parseLong(maxAge) < Long.parseLong(maxAgeMPlusValue) ? maxAge : maxAgeMPlusValue;
            } else {
                maxAgeString = maxAgeMPlusValue;
            }
        } else if (maxAge != null) {
            maxAgeString = maxAge;
        }
        maxAgeResolvedValue = Long.parseLong(maxAgeString);
        isMaxAgeResolved = true;
    }
214704
function defaultConflictResolution(definition, name, type, tgt, src) {
  // TODO: Add support for type/field level conflict settings
  // TODO: Add support for extending types via extend key
  switch(type) {
    case 'type':
      const {
        query,
        mutation,
        subscription
      } = get(definition, [ 'schema' ]) || {};
      // always merge a rootTypes definition
      if ([ query, mutation, subscription].indexOf(name) !== -1) {
        return { name, config: merge(tgt, src) };
      }
      break;
    case 'function':
      return { name, config: Object.assign(tgt, src) };
    case 'context':
      return { name, config: merge(tgt, src) };
    default:
      break;
  }
  // emit a warning
  definition.emit(FactoryEvent.WARN, 'MergeConflict: Duplicate ' + type +
  ' with name "' + name + '" found. Using newer value');
  return { name, config: tgt };
}
1270929
def better(old_value, new_value, mode):
    
    if (old_value is None or np.isnan(old_value)) and (new_value is not None and not np.isnan(new_value)):
        return True

    if mode == 'min':
        return new_value < old_value
    elif mode == 'max':
        return new_value > old_value
    else:
        raise RuntimeError(f"Mode '{mode}' value is not supported")
402218
function updateSimple(newList, oldList, rawNewValue ){

    var nlen = newList.length;
    var olen = oldList.length;
    var mlen = Math.min(nlen, olen);

    updateRange(0, mlen, newList, rawNewValue)
    if(nlen < olen){ //need add
      removeRange(nlen, olen-nlen, children);
    }else if(nlen > olen){
      addRange(olen, nlen, newList, rawNewValue);
    }
  }
1201482
def _validate_max(self, max_value, field, value):
        
        try:
            if value > max_value:
                self._error(field, errors.MAX_VALUE)
        except TypeError:
            pass
1334510
public function rule_between_num( $key, $value, $min, $max )
	{
		if ( !$this->rule_min_num( $key, $value, $min ) )
		{
			return false;
		}
		if ( !$this->rule_max_num( $key, $value, $max ) )
		{
			return false;
		}
		return true;
	}
776978
def adjust_ages(AgesIn):
    
# get a list of age_units first
    age_units, AgesOut, factors, factor, maxunit, age_unit = [], [], [], 1, 1, "Ma"
    for agerec in AgesIn:
        if agerec[1] not in age_units:
            age_units.append(agerec[1])
            if agerec[1] == "Ga":
                factors.append(1e9)
                maxunit, age_unit, factor = 1e9, "Ga", 1e9
            if agerec[1] == "Ma":
                if maxunit == 1:
                    maxunit, age_unt, factor = 1e6, "Ma", 1e6
                factors.append(1e6)
            if agerec[1] == "Ka":
                factors.append(1e3)
                if maxunit == 1:
                    maxunit, age_unit, factor = 1e3, "Ka", 1e3
            if "Years" in agerec[1].split():
                factors.append(1)
    if len(age_units) == 1:  # all ages are of same type
        for agerec in AgesIn:
            AgesOut.append(agerec[0])
    elif len(age_units) > 1:
        for agerec in AgesIn:  # normalize all to largest age unit
            if agerec[1] == "Ga":
                AgesOut.append(agerec[0] * 1e9 / factor)
            if agerec[1] == "Ma":
                AgesOut.append(agerec[0] * 1e6 / factor)
            if agerec[1] == "Ka":
                AgesOut.append(agerec[0] * 1e3 / factor)
            if "Years" in agerec[1].split():
                if agerec[1] == "Years BP":
                    AgesOut.append(old_div(agerec[0], factor))
                if agerec[1] == "Years Cal BP":
                    AgesOut.append(old_div(agerec[0], factor))
                if agerec[1] == "Years AD (+/-)":
                    # convert to years BP first
                    AgesOut.append(old_div((1950 - agerec[0]), factor))
                if agerec[1] == "Years Cal AD (+/-)":
                    AgesOut.append(old_div((1950 - agerec[0]), factor))
    return AgesOut, age_unit
1285221
def __clip(val, minimum, maximum):
        
        if val is None or minimum is None or maximum is None:
            return None
        if val < minimum:
            return minimum
        if val > maximum:
            return maximum
        return val
506783
private void updateMinMax() {
    if(values.length == 0) {
      return; // Keep invalid.
    }
    min = max = values[0];
    for(int i = 1; i < values.length; i++) {
      int v = values[i];
      min = min < v ? min : v;
      max = max > v ? max : v;
    }
  }
1114591
public static long setMaxAge(HttpResponse response, int maxAge) {
        List<Directive> directives = new ArrayList<>();
        directives.add(new Directive("max-age", maxAge));
        response.setField(HttpField.CACHE_CONTROL, directives);
        return maxAge;
    }
238806
function resolveMiddlewareWrapper(resolve = defaultResolveFn, directives = {}) {
  const serverDirectives = parseSchemaDirectives(directives);

  return (source, args, context, info) => {
    const directives = serverDirectives.concat(
      (info.fieldASTs || info.fieldNodes)[0].directives,
    );
    const directive = directives.filter(
      d => DEFAULT_DIRECTIVES.indexOf(d.name.value) === -1,
    )[0];

    if (!directive) {
      return resolve(source, args, context, info);
    }

    let defer = resolveWithDirective(
      () => Promise.resolve(resolve(source, args, context, info)),
      source,
      directive,
      context,
      info,
    );
    defer.catch(e =>
      resolveWithDirective(
        /* istanbul ignore next */
        () => Promise.reject(e),
        source,
        directive,
        context,
        info,
      ),
    );

    if (directives.length <= 1) {
      return defer;
    }

    for (let directiveNext of directives.slice(1)) {
      defer = defer.then(result =>
        resolveWithDirective(
          () => Promise.resolve(result),
          source,
          directiveNext,
          context,
          info,
        ),
      );
      defer.catch(e =>
        resolveWithDirective(
          () => Promise.reject(e),
          source,
          directiveNext,
          context,
          info,
        ),
      );
    }

    return defer;
  };
}
896801
function rules () {
        var pub = {};
        pub.maxLength = function (val, max) {

            if (!Array.isArray(val) && typeof val !== 'string' || typeof max !== 'number') {
                return getResult(new Error('rules.maxLength(fail): value must be a string or array, max must be a number'));
            }

            if (val.length > max) {
                return getResult(getError('maxLength', max, val));
            }

            return getResult(null);
        };
        pub.minLength = function (val, min) {

            if (!Array.isArray(val) && typeof val !== 'string' || typeof min !== 'number') {
                return getResult(new Error('rules.minLength(fail): value must be a string or array, min must be a number'));
            }

            if (val.length < min) {
                return getResult(getError('minLength', min, val));
            }

            return getResult(null);
        };
        pub.minimum = function (val, min) {

            if (typeof val !== 'number' || typeof min !== 'number') {
                return getResult(new Error('rules.minimum(fail): value must be a number, min must be a number'));
            }

            if (val < min) {
                return getResult(getError('minimum', min, val));
            }

            return getResult(null);
        };
        pub.maximum = function (val, max) {

            if (typeof val !== 'number' || typeof max !== 'number') {
                return getResult(new Error('rules.maximum(fail): value must be a number, max must be a number'));
            }

            if (val > max) {
                return getResult(getError('maximum', max, val));
            }

            return getResult(null);
        };
        pub.exclusiveMinimum = function (val, min) {

            if (typeof val !== 'number' || typeof min !== 'number') {
                return getResult(new Error('rules.exclusiveMinimum(fail): value must be a number, min must be a number'));
            }

            if (val <= min) {
                return getResult(getError('exclusiveMinimum', min, val));
            }

            return getResult(null);
        };
        pub.exclusiveMaximum = function (val, max) {

            if (typeof val !== 'number' || typeof max !== 'number') {
                return getResult(new Error('rules.exclusiveMaximum(fail): value must be a number, max must be a number'));
            }

            if (val >= max) {
                return getResult(getError('exclusiveMinimum', max, val));
            }

            return getResult(null);
        };
        pub.divisibleBy = function (val, div) {

            if (typeof val !== 'number' || typeof div !== 'number') {
                return getResult(new Error('rules.divisibleBy(fail): value must be a number, div must be a number'));
            }

            var multiplier = Math.max((val - Math.floor(val)).toString().length - 2,
                (div - Math.floor(div)).toString().length - 2);
            multiplier = multiplier > 0 ? Math.pow(10, multiplier) : 1;

            if ((val * multiplier) % (div * multiplier) !== 0) {
                return getResult(getError('divisibleBy', div, val));
            }

            return getResult(null);
        };
        pub.minItems = function (val, min) {

            if (!Array.isArray(val) || typeof min !== 'number') {
                return getResult(new Error('rules.minItems(fail): value must be a array, min must be a number'));
            }

            if (val.length < min) {
                return getResult(getError('minItems', min, val.length));
            }

            return getResult(null);
        };
        pub.maxItems = function (val, max) {

            if (!Array.isArray(val) || typeof max !== 'number') {
                return getResult(new Error('rules.maxItems(fail): value must be a array, max must be a number'));
            }

            if (val.length > max) {
                return getResult(getError('maxItems', max, val.length));
            }

            return getResult(null);
        };
        pub.uniqueItems = function (val) {

            if (!Array.isArray(val)) {
                return getResult(new Error('rules.uniqueItems(fail): value must be a array'));
            }

            if (!(uniqueArrayHelper(val))) {
                return getResult(getError('uniqueItems', val, true));
            }

            return getResult(null);
        };
        pub['enum'] = function (val, en) {

            if (typeof val === 'undefined' || !Array.isArray(en)) {
                return getResult(new Error('rules.enum(fail): value must be a defined and enum mus be a array'));
            }

            if (en.indexOf(val) === -1) {
                return getResult(getError('enum', en, val));
            }

            return getResult(null);
        };

        return pub;
    }
529158
function (newValue) {
            if (!this._cfgOk) {
                return -1;
            }

            var cfg = this._cfg;
            var res = null;
            if (cfg !== null) {
                if (newValue !== null && newValue !== "" && newValue >= cfg.minValue && newValue <= cfg.maxValue) {
                    res = ((newValue - cfg.minValue) / Math.abs(this._cfg.maxValue - this._cfg.minValue)) * 100;
                } else {
                    res = -1;
                }
            }
            cfg = null;
            return res;
        }
1077407
function _ruleCheckMaxFileSize($elementValue, $maxSize)
    {
        if (!empty($elementValue['error']) && 
            (UPLOAD_ERR_FORM_SIZE == $elementValue['error'] || UPLOAD_ERR_INI_SIZE == $elementValue['error'])) {
            return false;
        }
        if (!HTML_QuickForm_file::_ruleIsUploadedFile($elementValue)) {
            return true;
        }
        return ($maxSize >= @filesize($elementValue['tmp_name']));
    }
1325803
private String parseMaxAgeMplus(String value, long lastModified) {
        long currentTimeMillis = System.currentTimeMillis();
        return Long.toString(Long.parseLong(value) + (lastModified - currentTimeMillis) / 1000);
    }
996029
public void setDateRangeLimits(LocalDate firstAllowedDate, LocalDate lastAllowedDate) {
        if (firstAllowedDate == null && lastAllowedDate == null) {
            throw new RuntimeException("DateVetoPolicyMinimumMaximumDate.setDateRangeLimits(),"
                    + "The variable firstAllowedDate can be null, or lastAllowedDate can be null, "
                    + "but both values cannot be null at the same time. "
                    + "If you wish to clear the veto policy, then call the function: "
                    + "'DatePickerSettings.setVetoPolicy(null)'.");
        }
        if (firstAllowedDate != null && lastAllowedDate != null
                && lastAllowedDate.isBefore(firstAllowedDate)) {
            throw new RuntimeException("\"DateVetoPolicyMinimumMaximumDate.setDateRangeLimits(),"
                    + "The lastAllowedDate must be greater than or equal to the firstAllowedDate.");
        }
        this.firstAllowedDate = firstAllowedDate;
        this.lastAllowedDate = lastAllowedDate;
    }
1291988
private void validateTableOptionRetentionAge(TableDefinition tableDef, String optValue) {
        RetentionAge retAge = new RetentionAge(optValue); // throws if invalid format
        optValue = retAge.toString();
        tableDef.setOption(CommonDefs.OPT_RETENTION_AGE, optValue); // rewrite value
        Utils.require(tableDef.getOption(CommonDefs.OPT_AGING_FIELD) != null,
                      "Option 'retention-age' requires option 'aging-field'");
    }