ixfx
    Preparing search index...

    Function rangeIsWithin

    • Returns true if range 'a' is within or same as range 'b'. Returns false if not or if either/both ranges are undefined

      rangeIsWithin({ min: 5, max: 10 }, { min: 0, max: 10 }); // true
      rangeIsWithin({ min: 5, max: 10 }, { min: 6, max: 20 }); // false

      By default the matching is inclusive, in that a could share a min/max with b. If you want to check whether a is strictly within b, with a higher min and lower max, set exclusive to true.

      rangeIsWithin({ min: 5, max: 10 }, { min: 0, max: 10 }, true); // false
      rangeIsWithin({ min: 5, max: 9 }, { min: 0, max: 10 }, true); // true

      If either a or b is undefined, the function returns false.

      Parameters

      • a: Readonly<{ max: number; min: number }> | undefined

        Range

      • b: Readonly<{ max: number; min: number }> | undefined

        Parent

      • exclusive: boolean = false

        If true,

      Returns boolean