semver

package module
v0.0.5-alpha Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 13, 2025 License: AGPL-3.0 Imports: 4 Imported by: 8

README

codeclarity-logo

Secure your software empower your team.

License

Table of Contents

CodeClarity Utility - Semver

Contributing

If you'd like to contribute code or documentation, please see CONTRIBUTING.md for guidelines on how to do so.

Reporting Issues

Please report any issues with the setup process or other problems encountered while using this repository by opening a new issue in this project's GitHub page.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaxSatisfying

func MaxSatisfying(versions []versions.Semver, c constraints.Constraint, includePreReleases bool) versions.Semver

Evaluates the given constraints for each provided version and returns the hightest version that satisfies this constraint (if any)

func MaxSatisfyingStrings

func MaxSatisfyingStrings(versions []string, c constraints.Constraint, includePreReleases bool) (versions.Semver, error)

Evaluates the given constraints for each provided version and returns the hightest version that satisfies this constraint (if any) Equivalent to MaxSatisfying, but this function allows users to pass in versions as strings

func ParseConstraint

func ParseConstraint(constraintString string) (constraints.Constraint, error)

Parses a given node semver constraint string into a constraint object

func ParseSemver

func ParseSemver(versionLiteral string) (versions.Semver, error)

Parses a semver string into a semver object

func Satisfies

func Satisfies(v versions.Semver, c constraints.Constraint, includePreReleases bool) bool

Takes a version and semver constraint Returns true if the version satisfies the constraint and false otherwise

ex: constraint '>= 5.0.0' and version '5.0.0' would return true

As per node semver spec includePreReleases can be used to allow prerelease versions with different [major,minor,patch] tuple to satify the given constraint

ex: includePreReleases 'false' constraint '<= 5.0.0' and version '5.0.0-beta.2' would return true
ex: includePreReleases 'false' constraint '<= 5.0.0' and version '4.0.0-beta.2' would return false
ex: includePreReleases 'true' constraint '<= 5.0.0' and version '4.0.0-beta.2' would return true

func Sort

func Sort(sortOrder int, versions []versions.Semver) []versions.Semver

Sort sortes a given array of versions

descending sort if sort order == -1

ascending sort otherwise

func SortStrings

func SortStrings(sortOrder int, versionStrings []string) ([]string, error)

SortString sortes a given array of versions Equivalent to Sort, but this function allows users to pass in versions as strings

descending sort if sort order == -1

ascending sort otherwise

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL