Skip to content

Commit

Permalink
[unstable] BREAKING(semver): remove deprecated operators (#4423)
Browse files Browse the repository at this point in the history
* BREAKING(semver): remove deprecated operators

* fix
  • Loading branch information
iuioiua authored Mar 7, 2024
1 parent e78961b commit 7d718a1
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 25 deletions.
8 changes: 1 addition & 7 deletions semver/_constants.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.

/**
* @deprecated (will be removed in 0.219.0) `"=="`, `"==="`, `"!=="` and `""` operators are deprecated. Use `"="`, `"!="` or `undefined` instead.
*/
export const OPERATORS = [
"",
undefined,
"=",
"==",
"===",
"!==",
"!=",
">",
">=",
Expand Down
2 changes: 1 addition & 1 deletion semver/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const ANY: SemVer = {
* A comparator which will span all valid semantic versions
*/
export const ALL: Comparator = {
operator: "",
operator: undefined,
...ANY,
semver: ANY,
};
Expand Down
2 changes: 1 addition & 1 deletion semver/parse_range_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ Deno.test("parseRange() parses ranges with x", () => {
["*", [
[
{
operator: "",
operator: undefined,
major: NaN,
minor: NaN,
patch: NaN,
Expand Down
4 changes: 2 additions & 2 deletions semver/range_intersects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function comparatorIntersects(
const op0 = c0.operator;
const op1 = c1.operator;

if (op0 === "" || op0 === undefined) {
if (op0 === undefined) {
// if c0 is empty comparator, then returns true
if (isWildcardComparator(c0)) return true;
return testRange(c0, [[c1]]);
}
if (op1 === "" || op1 === undefined) {
if (op1 === undefined) {
if (isWildcardComparator(c1)) return true;
return testRange(c1, [[c0]]);
}
Expand Down
4 changes: 0 additions & 4 deletions semver/range_max.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ function comparatorMax(comparator: Comparator): SemVer {
if (semver === ANY) return MAX;
switch (comparator.operator) {
case "!=":
case "!==":
case ">":
case ">=":
return MAX;
case "":
case "==":
case "===":
case undefined:
case "=":
case "<=":
Expand Down
4 changes: 0 additions & 4 deletions semver/range_min.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ function comparatorMin(comparator: Comparator): SemVer {
? increment(semver, "pre")
: increment(semver, "patch");
case "!=":
case "!==":
case "<=":
case "<":
// The min(<0.0.0) is MAX
return greaterThan(semver, MIN) ? MIN : MAX;
case ">=":
case undefined:
case "":
case "=":
case "==":
case "===":
return {
major: semver.major,
minor: semver.minor,
Expand Down
6 changes: 1 addition & 5 deletions semver/test_range.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,11 @@ function testComparator(version: SemVer, comparator: Comparator): boolean {
}
const cmp = compare(version, comparator.semver ?? comparator);
switch (comparator.operator) {
case "":
case "=":
case "==":
case "===":
case undefined: {
return cmp === 0;
}
case "!=":
case "!==": {
case "!=": {
return cmp !== 0;
}
case ">": {
Expand Down
1 change: 0 additions & 1 deletion semver/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type ReleaseType =

/**
* SemVer comparison operators.
* @deprecated (will be removed in 0.219.0) `"=="`, `"==="`, `"!=="` and `""` operators are deprecated. Use `"="`, `"!="` or `undefined` instead.
*/
export type Operator = typeof OPERATORS[number];

Expand Down

0 comments on commit 7d718a1

Please sign in to comment.