Function clean

Returns cleaned (removed leading/trailing whitespace, remove '=', 'v' prefixes) and parsed version, or null if version is invalid.

clean('  =v1.2.3  ') // '1.2.3'
  • Parameters

    • version: string

      version string

    • OptionaloptionsOrLoose: boolean | Options

      an options object { loose } (where loose is the only available option) or a boolean indicating whether to enable loose mode. In loose mode, the parser is more forgiving with imperfectly formatted semver strings

    Returns null | string

    cleaned version string or null if version is invalid