diff --git a/semver/_constants.ts b/semver/_constants.ts index e6acb108705f..a0bdac5d1d2b 100644 --- a/semver/_constants.ts +++ b/semver/_constants.ts @@ -1,5 +1,70 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. +import type { Comparator, SemVer } from "./types.ts"; + +/** + * MAX is a sentinel value used by some range calculations. + * It is equivalent to `∞.∞.∞`. + */ +export const MAX: SemVer = { + major: Number.POSITIVE_INFINITY, + minor: Number.POSITIVE_INFINITY, + patch: Number.POSITIVE_INFINITY, + prerelease: [], + build: [], +}; + +/** + * The minimum valid SemVer object. Equivalent to `0.0.0`. + */ +export const MIN: SemVer = { + major: 0, + minor: 0, + patch: 0, + prerelease: [], + build: [], +}; + +/** + * A sentinel value used to denote an invalid SemVer object + * which may be the result of impossible ranges or comparator operations. + */ +export const INVALID: SemVer = { + major: Number.NEGATIVE_INFINITY, + minor: Number.POSITIVE_INFINITY, + patch: Number.POSITIVE_INFINITY, + prerelease: [], + build: [], +}; + +/** + * ANY is a sentinel value used by some range calculations. It is not a valid + * SemVer object and should not be used directly. + */ +export const ANY: SemVer = { + major: Number.NaN, + minor: Number.NaN, + patch: Number.NaN, + prerelease: [], + build: [], +}; + +/** + * A comparator which will span all valid semantic versions + */ +export const ALL: Comparator = { + operator: undefined, + ...ANY, +}; + +/** + * A comparator which will not span any semantic versions + */ +export const NONE: Comparator = { + operator: "<", + ...MIN, +}; + export const OPERATORS = [ undefined, "=", diff --git a/semver/constants.ts b/semver/constants.ts deleted file mode 100644 index fba7106ba900..000000000000 --- a/semver/constants.ts +++ /dev/null @@ -1,80 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -// This module is browser compatible. -import type { Comparator, SemVer } from "./types.ts"; - -/** - * MAX is a sentinel value used by some range calculations. - * It is equivalent to `∞.∞.∞`. - */ -export const MAX: SemVer = { - major: Number.POSITIVE_INFINITY, - minor: Number.POSITIVE_INFINITY, - patch: Number.POSITIVE_INFINITY, - prerelease: [], - build: [], -}; - -/** - * The minimum valid SemVer object. Equivalent to `0.0.0`. - */ -export const MIN: SemVer = { - major: 0, - minor: 0, - patch: 0, - prerelease: [], - build: [], -}; - -/** - * A sentinel value used to denote an invalid SemVer object - * which may be the result of impossible ranges or comparator operations. - * @example - * ```ts - * import { equals } from "@std/semver/equals"; - * import { parse } from "@std/semver/parse"; - * import { INVALID } from "@std/semver/constants" - * equals(parse("1.2.3"), INVALID); - * ``` - */ -export const INVALID: SemVer = { - major: Number.NEGATIVE_INFINITY, - minor: Number.POSITIVE_INFINITY, - patch: Number.POSITIVE_INFINITY, - prerelease: [], - build: [], -}; - -/** - * ANY is a sentinel value used by some range calculations. It is not a valid - * SemVer object and should not be used directly. - * @example - * ```ts - * import { equals } from "@std/semver/equals"; - * import { parse } from "@std/semver/parse"; - * import { ANY } from "@std/semver/constants" - * equals(parse("1.2.3"), ANY); // false - * ``` - */ -export const ANY: SemVer = { - major: Number.NaN, - minor: Number.NaN, - patch: Number.NaN, - prerelease: [], - build: [], -}; - -/** - * A comparator which will span all valid semantic versions - */ -export const ALL: Comparator = { - operator: undefined, - ...ANY, -}; - -/** - * A comparator which will not span any semantic versions - */ -export const NONE: Comparator = { - operator: "<", - ...MIN, -}; diff --git a/semver/deno.json b/semver/deno.json index d5ca060018b5..199fbe167d3b 100644 --- a/semver/deno.json +++ b/semver/deno.json @@ -5,7 +5,6 @@ ".": "./mod.ts", "./can-parse": "./can_parse.ts", "./compare": "./compare.ts", - "./constants": "./constants.ts", "./difference": "./difference.ts", "./equals": "./equals.ts", "./format": "./format.ts", diff --git a/semver/format_test.ts b/semver/format_test.ts index 314d9f68a57f..497294350a9a 100644 --- a/semver/format_test.ts +++ b/semver/format_test.ts @@ -3,7 +3,7 @@ import { assertEquals } from "@std/assert"; import { format } from "./format.ts"; import { parse } from "./parse.ts"; -import { INVALID, MAX, MIN } from "./constants.ts"; +import { INVALID, MAX, MIN } from "./_constants.ts"; import type { SemVer } from "./types.ts"; Deno.test("format()", async (t) => { diff --git a/semver/is_range.ts b/semver/is_range.ts index 953226f5af5a..28bb91dd504d 100644 --- a/semver/is_range.ts +++ b/semver/is_range.ts @@ -2,7 +2,7 @@ // This module is browser compatible. import type { Comparator, Range } from "./types.ts"; import { OPERATORS } from "./_constants.ts"; -import { ALL, NONE } from "./constants.ts"; +import { ALL, NONE } from "./_constants.ts"; import { isSemVer } from "./is_semver.ts"; function isComparator(value: unknown): value is Comparator { diff --git a/semver/is_range_test.ts b/semver/is_range_test.ts index d1a79963ef0d..a25918bd7fc0 100644 --- a/semver/is_range_test.ts +++ b/semver/is_range_test.ts @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { assert } from "@std/assert"; -import { ALL, MIN } from "./constants.ts"; +import { ALL, MIN } from "./_constants.ts"; import { formatRange } from "./format_range.ts"; import { isRange } from "./is_range.ts"; import type { Range } from "./types.ts"; diff --git a/semver/is_semver.ts b/semver/is_semver.ts index a26a0853aa10..8edfaae0dec8 100644 --- a/semver/is_semver.ts +++ b/semver/is_semver.ts @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. -import { ANY, INVALID } from "./constants.ts"; +import { ANY, INVALID } from "./_constants.ts"; import type { SemVer } from "./types.ts"; import { isValidNumber, isValidString } from "./_shared.ts"; diff --git a/semver/is_semver_test.ts b/semver/is_semver_test.ts index d16147d7cebd..9a809e155b37 100644 --- a/semver/is_semver_test.ts +++ b/semver/is_semver_test.ts @@ -1,6 +1,6 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. import { assert } from "@std/assert"; -import { MAX, MIN } from "./constants.ts"; +import { MAX, MIN } from "./_constants.ts"; import { isSemVer } from "./is_semver.ts"; Deno.test({ diff --git a/semver/max_satisfying_test.ts b/semver/max_satisfying_test.ts index 5de75f493f7a..d684dee5bf36 100644 --- a/semver/max_satisfying_test.ts +++ b/semver/max_satisfying_test.ts @@ -4,7 +4,7 @@ import { assertEquals } from "@std/assert"; import { parse } from "./parse.ts"; import { parseRange } from "./parse_range.ts"; import { maxSatisfying } from "./max_satisfying.ts"; -import { MAX, MIN } from "./constants.ts"; +import { MAX, MIN } from "./_constants.ts"; Deno.test({ name: "maxSatisfying()", diff --git a/semver/min_satisfying_test.ts b/semver/min_satisfying_test.ts index f10137c787ee..cf068d19d652 100644 --- a/semver/min_satisfying_test.ts +++ b/semver/min_satisfying_test.ts @@ -4,7 +4,7 @@ import { assertEquals } from "@std/assert"; import { parse } from "./parse.ts"; import { parseRange } from "./parse_range.ts"; import { minSatisfying } from "./min_satisfying.ts"; -import { MAX, MIN } from "./constants.ts"; +import { MAX, MIN } from "./_constants.ts"; Deno.test("minSatisfying()", async (t) => { const versions: [string[], string, string][] = [ diff --git a/semver/mod.ts b/semver/mod.ts index c0288ca6fb59..a561d9658dd5 100644 --- a/semver/mod.ts +++ b/semver/mod.ts @@ -277,7 +277,6 @@ * @module */ export * from "./compare.ts"; -export * from "./constants.ts"; export * from "./difference.ts"; export * from "./format.ts"; export * from "./satisfies.ts"; diff --git a/semver/parse_range.ts b/semver/parse_range.ts index 257732695c59..635a144df46d 100644 --- a/semver/parse_range.ts +++ b/semver/parse_range.ts @@ -9,7 +9,7 @@ import { parsePrerelease, XRANGE, } from "./_shared.ts"; -import { ALL, ANY, NONE } from "./constants.ts"; +import { ALL, ANY, NONE } from "./_constants.ts"; import type { Comparator, Operator, Range } from "./types.ts"; type ComparatorRegExpGroup = {