vector icon indicating copy to clipboard operation
vector copied to clipboard

Add Remap function for comparing semantic versions

Open lucperkins opened this issue 3 years ago • 0 comments

I'm not sure I can think of an absolute must-have use case, but we should enable users to compare versions of things, like so:

semver::compare(v1, v2)

This idea is inspired by Rego's semver.compare function, which returns three possible integers:

  • 1 if v1 is later than v2
  • 0 if the two versions are the same
  • -1 if v1 is earler than v2

This would allow for constructing Boolean expressions:

if (semver::compare(.version, "1.0") == -1) {
    .deprecated = true
}

I'm open to other interfaces for this, for example:

semver::compare(v1, v2, expect = ["gt"]) // Boolean

semver::parse(v1) > semver::parse(v2)

lucperkins avatar Dec 15 '20 15:12 lucperkins