node-semver icon indicating copy to clipboard operation
node-semver copied to clipboard

[DOCS] No mention of ranges such as `>3`.

Open coreyfarrell opened this issue 6 years ago • 3 comments

$ node -e "console.log(require('semver').Range('>3'))"
Range {
  options: { loose: false, includePrerelease: false },
  loose: false,
  includePrerelease: false,
  raw: '>3',
  set: [ [ [Comparator] ] ],
  range: '>=4.0.0' }

This behavior of the greater than range with missing minor/patch is not documented. Based on the documentation I had expected that >3 and >3.0.0 were the same range.

A similar thing happens with >3.0 becoming >=3.1.0, though >3.0.0 remains >3.0.0.

coreyfarrell avatar Apr 01 '19 15:04 coreyfarrell

Yes, this should be documented, but kind of makes sense if you think about it. >3.x means "greater than any version matching 3.x", so if 3.0.1 matched it, then that would be surprising, since 3.0.1 isn't "greater than" 3.x, it is 3.x.

isaacs avatar Apr 01 '19 15:04 isaacs

Also, >n should be equivalent to >=(n+1) so >3 should be equivalent to >=4

isaacs avatar Apr 01 '19 15:04 isaacs

Thank you for the 'greater than any version matching 3.x' explanation, that makes sense to me. Ultimately >3 is the same as >3.x or >3.x.x, not the same as >3.0 or >3.0.0.

coreyfarrell avatar Apr 01 '19 15:04 coreyfarrell