Nearly Perfected Mystique

    range-overlaps

    1.0.0 • Public • Published

    Range-Overlaps - check whether two intervals overlap

    Checks whether two numeric ranges overlap. For example, [0, 3] and [1, 6] do overlap, while [0, 3] and [4, 6] do not overlap.

    Usage

    rangeOverlaps(range1, range2, exclusive = false)

    The first two arguments are two intervals, each of which is an object with the start and end fields:

    const rangeOverlaps = require('range-overlaps');
    
    // Prints `true`:
    console.log(
        rangeOverlaps({start: 0, end: 3}, {start: 1, end: 6})
    );
    

    Options

    The third argument is a boolean value that indicates whether an exclusive search should be performed. For example, [0, 3] and [3, 6] would normally be considered overlapping. With exclusive search (true), these will not be considered overlapping.

    Install

    npm i range-overlaps

    DownloadsWeekly Downloads

    44

    Version

    1.0.0

    License

    Unlicense

    Last publish

    Collaborators

    • anton-ivanov