function validTicks(scale, ticks, count) {
    let range = scale.range(),
      lo = range[0],
      hi = peek$1(range),
      cmp = ascending;
    if (lo > hi) {
      range = hi;
      hi = lo;
      lo = range;
      cmp = descending;
    }
    lo = Math.floor(lo);
    hi = Math.ceil(hi);

    // filter ticks to valid values within the range
    // additionally sort ticks in range order (#2579)
    ticks = ticks.map(v => [v, scale(v)]).filter(_ => lo <= _[1] && _[1] <= hi).sort(cmp).map(_ => _[0]);
    if (count > 0 && ticks.length > 1) {
      const endpoints = [ticks[0], peek$1(ticks)];
      while (ticks.length > count && ticks.length >= 3) {
        ticks = ticks.filter((_, i) => !(i % 2));
      }
      if (ticks.length < 3) {
        ticks = endpoints;
      }
    }
    return ticks;
  }
Filter a set of candidate tick values, ensuring that only tick values
that lie within the scale range are included.
@param {Scale} scale - The scale for which to generate tick values.
@param {Array<*>} ticks - The candidate tick values.
@param {*} count - The tick count or interval function.
@return {Array<*>} - The filtered tick values.