# All files / src/utils getRangeDefaultValue.ts

100% Statements 28/28
100% Branches 4/4
100% Functions 1/1
100% Lines 28/28

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    291x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    1x
    107x
    107x
    107x
    107x
    51x
    51x
    56x
    56x
    56x
     import { type UseStateInitializer } from "../types.js";
    import {
      getMiddleOfRange,
      type GetMiddleOfRangeOptions,
    } from "./getMiddleOfRange.js";

    /**
     * @internal
     * @remarks \@since 6.0.0
     */
    export interface RangeDefaultValueOptions extends GetMiddleOfRangeOptions {
      defaultValue?: UseStateInitializer<number>;
    }

    /**
     * @internal
     * @remarks \@since 6.0.0
     */
    export function getRangeDefaultValue(
      options: RangeDefaultValueOptions
    ): UseStateInitializer<number> {
      const { defaultValue } = options;
      if (typeof defaultValue !== "undefined") {
        return defaultValue;
      }

      return () => getMiddleOfRange(options);
    }