Name: js-handler/node_modules/restify/node_modules/semver/README.md
| 1: | semver(1) -- The semantic versioner for npm |
| 2: | =========================================== |
| 3: | |
| 4: | ## Usage |
| 5: | |
| 6: | $ npm install semver |
| 7: | |
| 8: | semver.valid('1.2.3') // '1.2.3' |
| 9: | semver.valid('a.b.c') // null |
| 10: | semver.clean(' =v1.2.3 ') // '1.2.3' |
| 11: | semver.satisfies('1.2.3', '1.x || >=2.5.0 || 5.0.0 - 7.2.3') // true |
| 12: | semver.gt('1.2.3', '9.8.7') // false |
| 13: | semver.lt('1.2.3', '9.8.7') // true |
| 14: | |
| 15: | As a command-line utility: |
| 16: | |
| 17: | $ semver -h |
| 18: | |
| 19: | Usage: semver -v <version> [-r <range>] |
| 20: | Test if version(s) satisfy the supplied range(s), |
| 21: | and sort them. |
| 22: | |
| 23: | Multiple versions or ranges may be supplied. |
| 24: | |
| 25: | Program exits successfully if any valid version satisfies |
| 26: | all supplied ranges, and prints all satisfying versions. |
| 27: | |
| 28: | If no versions are valid, or ranges are not satisfied, |
| 29: | then exits failure. |
| 30: | |
| 31: | Versions are printed in ascending order, so supplying |
| 32: | multiple versions to the utility will just sort them. |
| 33: | |
| 34: | ## Versions |
| 35: | |
| 36: | A version is the following things, in this order: |
| 37: | |
| 38: | * a number (Major) |
| 39: | * a period |
| 40: | * a number (minor) |
| 41: | * a period |
| 42: | * a number (patch) |
| 43: | * OPTIONAL: a hyphen, followed by a number (build) |
| 44: | * OPTIONAL: a collection of pretty much any non-whitespace characters |
| 45: | (tag) |
| 46: | |
| 47: | A leading `"="` or `"v"` character is stripped off and ignored. |
| 48: | |
| 49: | ## Comparisons |
| 50: | |
| 51: | The ordering of versions is done using the following algorithm, given |
| 52: | two versions and asked to find the greater of the two: |
| 53: | |
| 54: | * If the majors are numerically different, then take the one |
| 55: | with a bigger major number. `2.3.4 > 1.3.4` |
| 56: | * If the minors are numerically different, then take the one |
| 57: | with the bigger minor number. `2.3.4 > 2.2.4` |
| 58: | * If the patches are numerically different, then take the one with the |
| 59: | bigger patch number. `2.3.4 > 2.3.3` |
| 60: | * If only one of them has a build number, then take the one with the |
| 61: | build number. `2.3.4-0 > 2.3.4` |
| 62: | * If they both have build numbers, and the build numbers are numerically |
| 63: | different, then take the one with the bigger build number. |
| 64: | `2.3.4-10 > 2.3.4-9` |
| 65: | * If only one of them has a tag, then take the one without the tag. |
| 66: | `2.3.4 > 2.3.4-beta` |
| 67: | * If they both have tags, then take the one with the lexicographically |
| 68: | larger tag. `2.3.4-beta > 2.3.4-alpha` |
| 69: | * At this point, they're equal. |
| 70: | |
| 71: | ## Ranges |
| 72: | |
| 73: | The following range styles are supported: |
| 74: | |
| 75: | * `>1.2.3` Greater than a specific version. |
| 76: | * `<1.2.3` Less than |
| 77: | * `1.2.3 - 2.3.4` := `>=1.2.3 <=2.3.4` |
| 78: | * `~1.2.3` := `>=1.2.3 <1.3.0` |
| 79: | * `~1.2` := `>=1.2.0 <1.3.0` |
| 80: | * `~1` := `>=1.0.0 <2.0.0` |
| 81: | * `1.2.x` := `>=1.2.0 <1.3.0` |
| 82: | * `1.x` := `>=1.0.0 <2.0.0` |
| 83: | |
| 84: | Ranges can be joined with either a space (which implies "and") or a |
| 85: | `||` (which implies "or"). |
| 86: | |
| 87: | ## Functions |
| 88: | |
| 89: | * valid(v): Return the parsed version, or null if it's not valid. |
| 90: | * inc(v, release): Return the version incremented by the release type |
| 91: | (major, minor, patch, or build), or null if it's not valid. |
| 92: | |
| 93: | ### Comparison |
| 94: | |
| 95: | * gt(v1, v2): `v1 > v2` |
| 96: | * gte(v1, v2): `v1 >= v2` |
| 97: | * lt(v1, v2): `v1 < v2` |
| 98: | * lte(v1, v2): `v1 <= v2` |
| 99: | * eq(v1, v2): `v1 == v2` This is true if they're logically equivalent, |
| 100: | even if they're not the exact same string. You already know how to |
| 101: | compare strings. |
| 102: | * neq(v1, v2): `v1 != v2` The opposite of eq. |
| 103: | * cmp(v1, comparator, v2): Pass in a comparison string, and it'll call |
| 104: | the corresponding function above. `"==="` and `"!=="` do simple |
| 105: | string comparison, but are included for completeness. Throws if an |
| 106: | invalid comparison string is provided. |
| 107: | * compare(v1, v2): Return 0 if v1 == v2, or 1 if v1 is greater, or -1 if |
| 108: | v2 is greater. Sorts in ascending order if passed to Array.sort(). |
| 109: | * rcompare(v1, v2): The reverse of compare. Sorts an array of versions |
| 110: | in descending order when passed to Array.sort(). |
| 111: | |
| 112: | |
| 113: | ### Ranges |
| 114: | |
| 115: | * validRange(range): Return the valid range or null if it's not valid |
| 116: | * satisfies(version, range): Return true if the version satisfies the |
| 117: | range. |
| 118: | * maxSatisfying(versions, range): Return the highest version in the list |
| 119: | that satisfies the range, or null if none of them do. |
