Class VersionRange

Represents a set of version requirements.

Constructors

  • Constructs a range of versions as specified by the given requirements.

    If you wish to construct this object from a string representation, then use [[fromRequirementString]].

    Parameters

    • requirements: Requirement[][]

      Requirements to set this range by

    Returns VersionRange

Properties

requirements: Requirement[][]

The list of requirements used by this version range.

This is a disjunctive normal form - that is, an OR of ANDs.

If all requirements of a single inner array match, the range is considered successful.

Methods

  • Parse a requirement string into a version range.

    Parameters

    • requirement: string

      The version requirements, consisting of a series of space-separated strings, each one being a semver version optionally prefixed by a comparator or a separator.

      Valid comparators are:

      • "" or "=": Precisely this version
      • ">": A version newer than this one
      • ">=": A version newer or equal to this one
      • "<": A version older than this one
      • "<=": A version older or equal to this one
      • "^": A version that is compatible with this one

      A separator is "||" which splits the requirement string into left OR right.

    Returns VersionRange

    A version range object.

  • Determine if a given version satisfies this range.

    Parameters

    • fver: Version

      A version object to test against.

    Returns boolean

    Whether or not the given version matches this range