Vinyl
    Preparing search index...

    A collection of Range start/end tuples. When ranges are added they are merged and sorted, making for fast within range checks.

    Implements

    Index

    Constructors

    • Parameters

      • ranges: readonly Range[] = []

        The non-normalized ranges to add.

      Returns RangesImpl

      #add

    Properties

    ranges: Range[] = []

    The ranges array like this reader encapsulates. Ranges are [start, end] tuples, they will always be ordered, never touch, and never overlap.

    Accessors

    • get empty(): boolean

      Returns true if there are zero ranges.

      Returns boolean

    Methods

    • Adds the given range to this list. If end is less than start, the range will not be added. Ranges will be merged when there is overlap or touching. Example, add(1, 4); add(2, 5) results in the final ranges: [1, 5]

      Parameters

      • start: number
      • end: number

      Returns void

    • Clears all ranges.

      Returns void

    • Returns the range at the given value, or null if all ranges are outside the given tolerance. Range values are considered inclusive. That is, a ReadonlyRanges with [0, 1] will return [0, 1] for value 1.

      Parameters

      • value: number

        The value to compare to current ranges.

      • tolerance: number = 0

        The tolerance the value may be outside a range and still considered to be within. Default: 0

      Returns null | Range

    • Returns the range that includes the entire from-to span, within a given tolerance.

      Range values are considered inclusive. That is, a ReadonlyRanges with [0, 2] will return [0, 2] for getRangeContaining(2, 2) or getRangeContaining(0, 0).

      from does not need to be lesser than to.

      Parameters

      • from: number
      • to: number
      • Optionaltolerance: number

      Returns null | Range

    • Returns all ranges where at least part of the range is within the given from-to span.

      from does not need to be lesser than to.

      Parameters

      • from: number
      • to: number
      • Optionaltolerance: number

      Returns Range[]

    • Removes the given range span from this list. Ranges partially intersecting will be changed to not include the start-end span. If start is after end, nothing will be removed.

      Parameters

      • start: number
      • end: number

      Returns void

    • Returns a string representation of an object.

      Returns string