@fedify/fedify 1.0.0-dev.410 → 1.0.0-dev.412
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGES.md +12 -0
- package/esm/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/_validate_binary_like.js +1 -1
- package/esm/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/base64.js +3 -5
- package/esm/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/base64url.js +3 -5
- package/esm/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/hex.js +7 -9
- package/esm/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/encoding.js +3 -1
- package/esm/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/language.js +2 -2
- package/esm/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/media_type.js +7 -7
- package/esm/deps/jsr.io/@std/semver/1.0.3/_constants.js +38 -0
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/_shared.js +3 -2
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/can_parse.js +4 -7
- package/esm/deps/jsr.io/@std/semver/1.0.3/compare.js +35 -0
- package/esm/deps/jsr.io/@std/semver/1.0.3/difference.js +41 -0
- package/esm/deps/jsr.io/@std/semver/1.0.3/equals.js +27 -0
- package/esm/deps/jsr.io/@std/semver/1.0.3/format.js +32 -0
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/format_range.js +5 -3
- package/esm/deps/jsr.io/@std/semver/1.0.3/greater_or_equal.js +26 -0
- package/esm/deps/jsr.io/@std/semver/1.0.3/greater_than.js +28 -0
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/greater_than_range.js +14 -13
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/increment.js +13 -14
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/is_range.js +4 -4
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/is_semver.js +3 -5
- package/esm/deps/jsr.io/@std/semver/1.0.3/less_or_equal.js +26 -0
- package/esm/deps/jsr.io/@std/semver/1.0.3/less_than.js +26 -0
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/less_than_range.js +14 -13
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/max_satisfying.js +2 -2
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/min_satisfying.js +2 -2
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/mod.js +25 -33
- package/esm/deps/jsr.io/@std/semver/1.0.3/not_equals.js +25 -0
- package/esm/deps/jsr.io/@std/semver/1.0.3/parse.js +44 -0
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/parse_range.js +18 -13
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/range_intersects.js +29 -28
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/satisfies.js +3 -3
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/try_parse.js +5 -8
- package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/try_parse_range.js +3 -3
- package/esm/federation/collection.js +1 -1
- package/esm/federation/handler.js +1 -1
- package/esm/nodeinfo/types.js +1 -1
- package/esm/runtime/key.js +3 -3
- package/esm/sig/http.js +1 -1
- package/esm/sig/ld.js +2 -2
- package/package.json +4 -4
- package/types/deps/jsr.io/@std/encoding/1.0.5/_validate_binary_like.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/base64.d.ts +2 -2
- package/types/deps/jsr.io/@std/encoding/1.0.5/base64.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/base64url.d.ts +2 -2
- package/types/deps/jsr.io/@std/encoding/1.0.5/base64url.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/hex.d.ts +2 -2
- package/types/deps/jsr.io/@std/encoding/1.0.5/hex.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/common.d.ts +2 -2
- package/types/deps/jsr.io/@std/http/1.0.6/_negotiation/common.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/http/1.0.6/_negotiation/encoding.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/http/1.0.6/_negotiation/language.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/http/1.0.6/_negotiation/media_type.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/negotiation.d.ts +13 -18
- package/types/deps/jsr.io/@std/http/1.0.6/negotiation.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/_constants.d.ts +16 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/_constants.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/_shared.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/_test_comparator_set.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/can_parse.d.ts +2 -2
- package/types/deps/jsr.io/@std/semver/1.0.3/can_parse.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/compare.d.ts +28 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/compare.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/difference.d.ts +27 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/difference.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/equals.d.ts +24 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/equals.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/format.d.ts +3 -7
- package/types/deps/jsr.io/@std/semver/1.0.3/format.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/format_range.d.ts +3 -2
- package/types/deps/jsr.io/@std/semver/1.0.3/format_range.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/greater_or_equal.d.ts +25 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/greater_or_equal.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/greater_than.d.ts +25 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/greater_than.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/greater_than_range.d.ts +8 -7
- package/types/deps/jsr.io/@std/semver/1.0.3/greater_than_range.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/increment.d.ts +11 -5
- package/types/deps/jsr.io/@std/semver/1.0.3/increment.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/is_range.d.ts +2 -2
- package/types/deps/jsr.io/@std/semver/1.0.3/is_range.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/is_semver.d.ts +2 -2
- package/types/deps/jsr.io/@std/semver/1.0.3/is_semver.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/less_or_equal.d.ts +25 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/less_or_equal.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/less_than.d.ts +25 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/less_than.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/less_than_range.d.ts +8 -7
- package/types/deps/jsr.io/@std/semver/1.0.3/less_than_range.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/max_satisfying.d.ts +2 -2
- package/types/deps/jsr.io/@std/semver/1.0.3/max_satisfying.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/min_satisfying.d.ts +2 -2
- package/types/deps/jsr.io/@std/semver/1.0.3/min_satisfying.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/mod.d.ts +25 -33
- package/types/deps/jsr.io/@std/semver/1.0.3/mod.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/not_equals.d.ts +24 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/not_equals.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/parse.d.ts +5 -5
- package/types/deps/jsr.io/@std/semver/1.0.3/parse.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/parse_range.d.ts +6 -5
- package/types/deps/jsr.io/@std/semver/1.0.3/parse_range.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/range_intersects.d.ts +25 -0
- package/types/deps/jsr.io/@std/semver/1.0.3/range_intersects.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/satisfies.d.ts +3 -3
- package/types/deps/jsr.io/@std/semver/1.0.3/satisfies.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/try_parse.d.ts +4 -4
- package/types/deps/jsr.io/@std/semver/1.0.3/try_parse.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/try_parse_range.d.ts +2 -2
- package/types/deps/jsr.io/@std/semver/1.0.3/try_parse_range.d.ts.map +1 -0
- package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/types.d.ts +23 -4
- package/types/deps/jsr.io/@std/semver/1.0.3/types.d.ts.map +1 -0
- package/types/nodeinfo/types.d.ts +1 -1
- package/types/nodeinfo/types.d.ts.map +1 -1
- package/esm/deps/jsr.io/@std/semver/0.224.3/_constants.js +0 -10
- package/esm/deps/jsr.io/@std/semver/0.224.3/compare.js +0 -35
- package/esm/deps/jsr.io/@std/semver/0.224.3/constants.js +0 -71
- package/esm/deps/jsr.io/@std/semver/0.224.3/difference.js +0 -37
- package/esm/deps/jsr.io/@std/semver/0.224.3/equals.js +0 -27
- package/esm/deps/jsr.io/@std/semver/0.224.3/format.js +0 -48
- package/esm/deps/jsr.io/@std/semver/0.224.3/greater_or_equal.js +0 -25
- package/esm/deps/jsr.io/@std/semver/0.224.3/greater_than.js +0 -27
- package/esm/deps/jsr.io/@std/semver/0.224.3/less_or_equal.js +0 -25
- package/esm/deps/jsr.io/@std/semver/0.224.3/less_than.js +0 -25
- package/esm/deps/jsr.io/@std/semver/0.224.3/not_equals.js +0 -24
- package/esm/deps/jsr.io/@std/semver/0.224.3/parse.js +0 -50
- package/esm/deps/jsr.io/@std/semver/0.224.3/range_max.js +0 -77
- package/esm/deps/jsr.io/@std/semver/0.224.3/range_min.js +0 -68
- package/esm/deps/jsr.io/@std/semver/0.224.3/test_range.js +0 -28
- package/types/deps/jsr.io/@std/encoding/0.224.3/_validate_binary_like.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/0.224.3/base64.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/0.224.3/base64url.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/encoding/0.224.3/hex.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/http/0.224.5/_negotiation/common.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/http/0.224.5/_negotiation/encoding.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/http/0.224.5/_negotiation/language.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/http/0.224.5/_negotiation/media_type.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/http/0.224.5/negotiation.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/_constants.d.ts +0 -2
- package/types/deps/jsr.io/@std/semver/0.224.3/_constants.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/_shared.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/_test_comparator_set.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/can_parse.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/compare.d.ts +0 -28
- package/types/deps/jsr.io/@std/semver/0.224.3/compare.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/constants.d.ts +0 -43
- package/types/deps/jsr.io/@std/semver/0.224.3/constants.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/difference.d.ts +0 -27
- package/types/deps/jsr.io/@std/semver/0.224.3/difference.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/equals.d.ts +0 -24
- package/types/deps/jsr.io/@std/semver/0.224.3/equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/format.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/format_range.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/greater_or_equal.d.ts +0 -24
- package/types/deps/jsr.io/@std/semver/0.224.3/greater_or_equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/greater_than.d.ts +0 -24
- package/types/deps/jsr.io/@std/semver/0.224.3/greater_than.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/greater_than_range.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/increment.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/is_range.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/is_semver.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/less_or_equal.d.ts +0 -24
- package/types/deps/jsr.io/@std/semver/0.224.3/less_or_equal.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/less_than.d.ts +0 -24
- package/types/deps/jsr.io/@std/semver/0.224.3/less_than.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/less_than_range.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/max_satisfying.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/min_satisfying.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/mod.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/not_equals.d.ts +0 -23
- package/types/deps/jsr.io/@std/semver/0.224.3/not_equals.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/parse.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/parse_range.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/range_intersects.d.ts +0 -24
- package/types/deps/jsr.io/@std/semver/0.224.3/range_intersects.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/range_max.d.ts +0 -25
- package/types/deps/jsr.io/@std/semver/0.224.3/range_max.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/range_min.d.ts +0 -25
- package/types/deps/jsr.io/@std/semver/0.224.3/range_min.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/satisfies.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/test_range.d.ts +0 -27
- package/types/deps/jsr.io/@std/semver/0.224.3/test_range.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/try_parse.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/try_parse_range.d.ts.map +0 -1
- package/types/deps/jsr.io/@std/semver/0.224.3/types.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/common.js +0 -0
- /package/esm/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/negotiation.js +0 -0
- /package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/_test_comparator_set.js +0 -0
- /package/esm/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/types.js +0 -0
- /package/types/deps/jsr.io/@std/encoding/{0.224.3 → 1.0.5}/_validate_binary_like.d.ts +0 -0
- /package/types/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/encoding.d.ts +0 -0
- /package/types/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/language.d.ts +0 -0
- /package/types/deps/jsr.io/@std/http/{0.224.5 → 1.0.6}/_negotiation/media_type.d.ts +0 -0
- /package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/_shared.d.ts +0 -0
- /package/types/deps/jsr.io/@std/semver/{0.224.3 → 1.0.3}/_test_comparator_set.d.ts +0 -0
@@ -29,7 +29,7 @@ function bumpPrerelease(prerelease = [], identifier) {
|
|
29
29
|
return values;
|
30
30
|
}
|
31
31
|
/**
|
32
|
-
* Returns the new
|
32
|
+
* Returns the new SemVer resulting from an increment by release type.
|
33
33
|
*
|
34
34
|
* `premajor`, `preminor` and `prepatch` will bump the version up to the next version,
|
35
35
|
* based on the type, and will also add prerelease metadata.
|
@@ -52,7 +52,7 @@ function bumpPrerelease(prerelease = [], identifier) {
|
|
52
52
|
* @example Usage
|
53
53
|
* ```ts
|
54
54
|
* import { increment, parse } from "@std/semver";
|
55
|
-
* import { assertEquals } from "@std/assert
|
55
|
+
* import { assertEquals } from "@std/assert";
|
56
56
|
*
|
57
57
|
* const version = parse("1.2.3");
|
58
58
|
* assertEquals(increment(version, "major"), parse("2.0.0"));
|
@@ -66,21 +66,20 @@ function bumpPrerelease(prerelease = [], identifier) {
|
|
66
66
|
*
|
67
67
|
* @param version The version to increment
|
68
68
|
* @param release The type of increment to perform
|
69
|
-
* @param
|
70
|
-
* @param buildmetadata The build metadata of the new version
|
69
|
+
* @param options Additional options
|
71
70
|
* @returns The new version
|
72
71
|
*/
|
73
|
-
export function increment(version, release,
|
74
|
-
const build =
|
75
|
-
? parseBuild(
|
76
|
-
: version.build;
|
72
|
+
export function increment(version, release, options = {}) {
|
73
|
+
const build = options.build !== undefined
|
74
|
+
? parseBuild(options.build)
|
75
|
+
: version.build ?? [];
|
77
76
|
switch (release) {
|
78
77
|
case "premajor":
|
79
78
|
return {
|
80
79
|
major: version.major + 1,
|
81
80
|
minor: 0,
|
82
81
|
patch: 0,
|
83
|
-
prerelease: bumpPrerelease(version.prerelease, prerelease),
|
82
|
+
prerelease: bumpPrerelease(version.prerelease, options.prerelease),
|
84
83
|
build,
|
85
84
|
};
|
86
85
|
case "preminor":
|
@@ -88,7 +87,7 @@ export function increment(version, release, prerelease, buildmetadata) {
|
|
88
87
|
major: version.major,
|
89
88
|
minor: version.minor + 1,
|
90
89
|
patch: 0,
|
91
|
-
prerelease: bumpPrerelease(version.prerelease, prerelease),
|
90
|
+
prerelease: bumpPrerelease(version.prerelease, options.prerelease),
|
92
91
|
build,
|
93
92
|
};
|
94
93
|
case "prepatch":
|
@@ -96,7 +95,7 @@ export function increment(version, release, prerelease, buildmetadata) {
|
|
96
95
|
major: version.major,
|
97
96
|
minor: version.minor,
|
98
97
|
patch: version.patch + 1,
|
99
|
-
prerelease: bumpPrerelease(version.prerelease, prerelease),
|
98
|
+
prerelease: bumpPrerelease(version.prerelease, options.prerelease),
|
100
99
|
build,
|
101
100
|
};
|
102
101
|
case "prerelease": {
|
@@ -107,7 +106,7 @@ export function increment(version, release, prerelease, buildmetadata) {
|
|
107
106
|
major: version.major,
|
108
107
|
minor: version.minor,
|
109
108
|
patch,
|
110
|
-
prerelease: bumpPrerelease(version.prerelease, prerelease),
|
109
|
+
prerelease: bumpPrerelease(version.prerelease, options.prerelease),
|
111
110
|
build,
|
112
111
|
};
|
113
112
|
}
|
@@ -167,11 +166,11 @@ export function increment(version, release, prerelease, buildmetadata) {
|
|
167
166
|
major: version.major,
|
168
167
|
minor: version.minor,
|
169
168
|
patch: version.patch,
|
170
|
-
prerelease: bumpPrerelease(version.prerelease, prerelease),
|
169
|
+
prerelease: bumpPrerelease(version.prerelease, options.prerelease),
|
171
170
|
build,
|
172
171
|
};
|
173
172
|
}
|
174
173
|
default:
|
175
|
-
throw new
|
174
|
+
throw new TypeError(`Cannot increment version: invalid argument ${release}`);
|
176
175
|
}
|
177
176
|
}
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { OPERATORS } from "./_constants.js";
|
2
|
-
import { ALL
|
2
|
+
import { ALL } from "./_constants.js";
|
3
3
|
import { isSemVer } from "./is_semver.js";
|
4
4
|
function isComparator(value) {
|
5
5
|
if (value === null || value === undefined || Array.isArray(value) ||
|
6
6
|
typeof value !== "object")
|
7
7
|
return false;
|
8
|
-
if (value ===
|
8
|
+
if (value === ALL)
|
9
9
|
return true;
|
10
10
|
const { operator } = value;
|
11
11
|
return ((operator === undefined ||
|
@@ -23,11 +23,11 @@ function isComparator(value) {
|
|
23
23
|
* @example Usage
|
24
24
|
* ```ts
|
25
25
|
* import { isRange } from "@std/semver/is-range";
|
26
|
-
* import { assert
|
26
|
+
* import { assert } from "@std/assert";
|
27
27
|
*
|
28
28
|
* const range = [[{ major: 1, minor: 2, patch: 3 }]];
|
29
29
|
* assert(isRange(range));
|
30
|
-
*
|
30
|
+
* assert(!isRange({}));
|
31
31
|
* ```
|
32
32
|
* @param value The value to check if its a valid Range
|
33
33
|
* @returns True if its a valid Range otherwise false.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
2
|
// This module is browser compatible.
|
3
|
-
import { ANY
|
3
|
+
import { ANY } from "./_constants.js";
|
4
4
|
import { isValidNumber, isValidString } from "./_shared.js";
|
5
5
|
/**
|
6
6
|
* Checks to see if value is a valid SemVer object. It does a check
|
@@ -18,7 +18,7 @@ import { isValidNumber, isValidString } from "./_shared.js";
|
|
18
18
|
* @example Usage
|
19
19
|
* ```ts
|
20
20
|
* import { isSemVer } from "@std/semver/is-semver";
|
21
|
-
* import { assert
|
21
|
+
* import { assert } from "@std/assert";
|
22
22
|
*
|
23
23
|
* const value = {
|
24
24
|
* major: 1,
|
@@ -27,7 +27,7 @@ import { isValidNumber, isValidString } from "./_shared.js";
|
|
27
27
|
* };
|
28
28
|
*
|
29
29
|
* assert(isSemVer(value));
|
30
|
-
*
|
30
|
+
* assert(!isSemVer({ major: 1, minor: 2 }));
|
31
31
|
* ```
|
32
32
|
*
|
33
33
|
* @param value The value to check to see if its a valid SemVer object
|
@@ -40,8 +40,6 @@ export function isSemVer(value) {
|
|
40
40
|
return false;
|
41
41
|
if (typeof value !== "object")
|
42
42
|
return false;
|
43
|
-
if (value === INVALID)
|
44
|
-
return true;
|
45
43
|
if (value === ANY)
|
46
44
|
return true;
|
47
45
|
const { major, minor, patch, build = [], prerelease = [], } = value;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { compare } from "./compare.js";
|
2
|
+
/**
|
3
|
+
* Less than or equal to comparison for two SemVers.
|
4
|
+
*
|
5
|
+
* This is equal to `compare(version1, version2) <= 0`.
|
6
|
+
*
|
7
|
+
* @example Usage
|
8
|
+
* ```ts
|
9
|
+
* import { parse, lessOrEqual } from "@std/semver";
|
10
|
+
* import { assert } from "@std/assert";
|
11
|
+
*
|
12
|
+
* const version1 = parse("1.2.3");
|
13
|
+
* const version2 = parse("1.2.4");
|
14
|
+
*
|
15
|
+
* assert(lessOrEqual(version1, version2));
|
16
|
+
* assert(!lessOrEqual(version2, version1));
|
17
|
+
* assert(lessOrEqual(version1, version1));
|
18
|
+
* ```
|
19
|
+
*
|
20
|
+
* @param version1 the first version to compare
|
21
|
+
* @param version2 the second version to compare
|
22
|
+
* @returns `true` if `version1` is less than or equal to `version2`, `false` otherwise
|
23
|
+
*/
|
24
|
+
export function lessOrEqual(version1, version2) {
|
25
|
+
return compare(version1, version2) <= 0;
|
26
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
import { compare } from "./compare.js";
|
2
|
+
/**
|
3
|
+
* Less than comparison for two SemVers.
|
4
|
+
*
|
5
|
+
* This is equal to `compare(version1, version2) < 0`.
|
6
|
+
*
|
7
|
+
* @example Usage
|
8
|
+
* ```ts
|
9
|
+
* import { parse, lessThan } from "@std/semver";
|
10
|
+
* import { assert } from "@std/assert";
|
11
|
+
*
|
12
|
+
* const version1 = parse("1.2.3");
|
13
|
+
* const version2 = parse("1.2.4");
|
14
|
+
*
|
15
|
+
* assert(lessThan(version1, version2));
|
16
|
+
* assert(!lessThan(version2, version1));
|
17
|
+
* assert(!lessThan(version1, version1));
|
18
|
+
* ```
|
19
|
+
*
|
20
|
+
* @param version1 the first version to compare
|
21
|
+
* @param version2 the second version to compare
|
22
|
+
* @returns `true` if `version1` is less than `version2`, `false` otherwise
|
23
|
+
*/
|
24
|
+
export function lessThan(version1, version2) {
|
25
|
+
return compare(version1, version2) < 0;
|
26
|
+
}
|
@@ -9,36 +9,37 @@ import { compare } from "./compare.js";
|
|
9
9
|
* @example Usage
|
10
10
|
* ```ts
|
11
11
|
* import { parse, parseRange, lessThanRange } from "@std/semver";
|
12
|
-
* import { assert
|
12
|
+
* import { assert } from "@std/assert";
|
13
13
|
*
|
14
|
-
* const
|
15
|
-
* const
|
14
|
+
* const version1 = parse("1.2.3");
|
15
|
+
* const version2 = parse("1.0.0");
|
16
16
|
* const range = parseRange(">=1.2.3 <1.2.4");
|
17
|
-
*
|
18
|
-
* assert(lessThanRange(
|
17
|
+
*
|
18
|
+
* assert(!lessThanRange(version1, range));
|
19
|
+
* assert(lessThanRange(version2, range));
|
19
20
|
* ```
|
20
21
|
*
|
21
|
-
* @param
|
22
|
+
* @param version The version to check.
|
22
23
|
* @param range The range to check against.
|
23
24
|
* @returns `true` if the SemVer is less than the range, `false` otherwise.
|
24
25
|
*/
|
25
|
-
export function lessThanRange(
|
26
|
-
return range.every((comparatorSet) => lessThanComparatorSet(
|
26
|
+
export function lessThanRange(version, range) {
|
27
|
+
return range.every((comparatorSet) => lessThanComparatorSet(version, comparatorSet));
|
27
28
|
}
|
28
|
-
function lessThanComparatorSet(
|
29
|
+
function lessThanComparatorSet(version, comparatorSet) {
|
29
30
|
// If the comparator set contains wildcard, then the semver is not greater than the range.
|
30
31
|
if (comparatorSet.some(isWildcardComparator))
|
31
32
|
return false;
|
32
33
|
// If the SemVer satisfies the comparator set, then it's not less than the range.
|
33
|
-
if (testComparatorSet(
|
34
|
+
if (testComparatorSet(version, comparatorSet))
|
34
35
|
return false;
|
35
36
|
// If the SemVer is greater than any of the comparator set, then it's not less than the range.
|
36
|
-
if (comparatorSet.some((comparator) => greaterThanComparator(
|
37
|
+
if (comparatorSet.some((comparator) => greaterThanComparator(version, comparator)))
|
37
38
|
return false;
|
38
39
|
return true;
|
39
40
|
}
|
40
|
-
function greaterThanComparator(
|
41
|
-
const cmp = compare(
|
41
|
+
function greaterThanComparator(version, comparator) {
|
42
|
+
const cmp = compare(version, comparator);
|
42
43
|
switch (comparator.operator) {
|
43
44
|
case "=":
|
44
45
|
case undefined:
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { satisfies } from "./satisfies.js";
|
2
2
|
import { greaterThan } from "./greater_than.js";
|
3
3
|
/**
|
4
|
-
* Returns the highest
|
4
|
+
* Returns the highest SemVer in the list that satisfies the range, or `undefined`
|
5
5
|
* if none of them do.
|
6
6
|
*
|
7
7
|
* @example Usage
|
8
8
|
* ```ts
|
9
9
|
* import { parse, parseRange, maxSatisfying } from "@std/semver";
|
10
|
-
* import { assertEquals } from "@std/assert
|
10
|
+
* import { assertEquals } from "@std/assert";
|
11
11
|
*
|
12
12
|
* const versions = ["1.2.3", "1.2.4", "1.3.0", "2.0.0", "2.1.0"].map(parse);
|
13
13
|
* const range = parseRange(">=1.0.0 <2.0.0");
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import { satisfies } from "./satisfies.js";
|
2
2
|
import { lessThan } from "./less_than.js";
|
3
3
|
/**
|
4
|
-
* Returns the lowest
|
4
|
+
* Returns the lowest SemVer in the list that satisfies the range, or `undefined` if
|
5
5
|
* none of them do.
|
6
6
|
*
|
7
7
|
* @example Usage
|
8
8
|
* ```ts
|
9
9
|
* import { parse, parseRange, minSatisfying } from "@std/semver";
|
10
|
-
* import { assertEquals } from "@std/assert
|
10
|
+
* import { assertEquals } from "@std/assert";
|
11
11
|
*
|
12
12
|
* const versions = ["0.2.0", "1.2.3", "1.3.0", "2.0.0", "2.1.0"].map(parse);
|
13
13
|
* const range = parseRange(">=1.0.0 <2.0.0");
|
@@ -14,7 +14,7 @@
|
|
14
14
|
* lessThan,
|
15
15
|
* format
|
16
16
|
* } from "@std/semver";
|
17
|
-
* import { assertEquals } from "@std/assert
|
17
|
+
* import { assertEquals } from "@std/assert";
|
18
18
|
*
|
19
19
|
* const semver = parse("1.2.3");
|
20
20
|
* assertEquals(semver, {
|
@@ -50,28 +50,28 @@
|
|
50
50
|
* formatting options.
|
51
51
|
*
|
52
52
|
* ```
|
53
|
-
*
|
54
|
-
*
|
55
|
-
*
|
56
|
-
*
|
57
|
-
*
|
58
|
-
*
|
59
|
-
*
|
60
|
-
*
|
61
|
-
*
|
62
|
-
*
|
63
|
-
*
|
64
|
-
*
|
65
|
-
*
|
53
|
+
* full
|
54
|
+
* ┌───┴───┐
|
55
|
+
* release │
|
56
|
+
* ┌───┴───┐ │
|
57
|
+
* primary │ │
|
58
|
+
* ┌─┴─┐ │ │
|
59
|
+
* 1.2.3-pre.1+b.1
|
60
|
+
* │ │ │ └─┬─┘ └┬┘
|
61
|
+
* │ │ │ │ └── build
|
62
|
+
* │ │ │ └─────── pre
|
63
|
+
* │ │ └─────────── patch
|
64
|
+
* │ └───────────── minor
|
65
|
+
* └─────────────── major
|
66
66
|
* ```
|
67
67
|
*
|
68
68
|
* ## Ranges
|
69
69
|
*
|
70
|
-
* A
|
71
|
-
* the range.
|
70
|
+
* A version {@linkcode Range} is a set of {@linkcode Comparator}s which specify
|
71
|
+
* versions that satisfy the range.
|
72
72
|
*
|
73
|
-
* A
|
74
|
-
* primitive `operators` is:
|
73
|
+
* A {@linkcode Comparator} is composed of an {@linkcode Operator} and a
|
74
|
+
* {@link SemVer}. The set of primitive `operators` is:
|
75
75
|
*
|
76
76
|
* - `<` Less than
|
77
77
|
* - `<=` Less than or equal to
|
@@ -122,12 +122,14 @@
|
|
122
122
|
*
|
123
123
|
* #### Prerelease Identifiers
|
124
124
|
*
|
125
|
-
* The method
|
126
|
-
* will append the value of the string as a prerelease identifier:
|
125
|
+
* The method {@linkcode increment} takes an additional `identifier` string
|
126
|
+
* argument that will append the value of the string as a prerelease identifier:
|
127
127
|
*
|
128
|
-
* ```
|
129
|
-
*
|
130
|
-
*
|
128
|
+
* ```ts
|
129
|
+
* import { increment, parse } from "@std/semver";
|
130
|
+
* import { assertEquals } from "@std/assert";
|
131
|
+
*
|
132
|
+
* assertEquals(increment(parse("1.2.3"), "prerelease", { prerelease: "alpha" }), parse("1.2.4-alpha.0"));
|
131
133
|
* ```
|
132
134
|
*
|
133
135
|
* ### Build Metadata
|
@@ -268,18 +270,12 @@
|
|
268
270
|
*
|
269
271
|
* If you want to know if a version satisfies or does not satisfy a range, use the
|
270
272
|
* {@linkcode satisfies} function.
|
271
|
-
*
|
272
|
-
*
|
273
|
-
*
|
274
|
-
|
275
273
|
*
|
276
274
|
* @module
|
277
275
|
*/
|
278
276
|
export * from "./compare.js";
|
279
|
-
export * from "./constants.js";
|
280
277
|
export * from "./difference.js";
|
281
278
|
export * from "./format.js";
|
282
|
-
export * from "./test_range.js";
|
283
279
|
export * from "./satisfies.js";
|
284
280
|
export * from "./increment.js";
|
285
281
|
export * from "./is_semver.js";
|
@@ -288,8 +284,6 @@ export * from "./min_satisfying.js";
|
|
288
284
|
export * from "./parse_range.js";
|
289
285
|
export * from "./parse.js";
|
290
286
|
export * from "./range_intersects.js";
|
291
|
-
export * from "./range_max.js";
|
292
|
-
export * from "./range_min.js";
|
293
287
|
export * from "./types.js";
|
294
288
|
export * from "./try_parse_range.js";
|
295
289
|
export * from "./is_range.js";
|
@@ -304,5 +298,3 @@ export * from "./greater_or_equal.js";
|
|
304
298
|
export * from "./less_than.js";
|
305
299
|
export * from "./less_than_range.js";
|
306
300
|
export * from "./less_or_equal.js";
|
307
|
-
/** The SemVer spec version */
|
308
|
-
export const SEMVER_SPEC_VERSION = "2.0.0";
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { compare } from "./compare.js";
|
2
|
+
/**
|
3
|
+
* Not equal comparison for two SemVers.
|
4
|
+
*
|
5
|
+
* This is equal to `compare(version1, version2) !== 0`.
|
6
|
+
*
|
7
|
+
* @example Usage
|
8
|
+
* ```ts
|
9
|
+
* import { parse, notEquals } from "@std/semver";
|
10
|
+
* import { assert } from "@std/assert";
|
11
|
+
*
|
12
|
+
* const version1 = parse("1.2.3");
|
13
|
+
* const version2 = parse("1.2.4");
|
14
|
+
*
|
15
|
+
* assert(notEquals(version1, version2));
|
16
|
+
* assert(!notEquals(version1, version1));
|
17
|
+
* ```
|
18
|
+
*
|
19
|
+
* @param version1 The first version to compare
|
20
|
+
* @param version2 The second version to compare
|
21
|
+
* @returns `true` if `version1` is not equal to `version2`, `false` otherwise
|
22
|
+
*/
|
23
|
+
export function notEquals(version1, version2) {
|
24
|
+
return compare(version1, version2) !== 0;
|
25
|
+
}
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import { parseBuild, parseNumber, parsePrerelease } from "./_shared.js";
|
2
|
+
import { FULL_REGEXP, MAX_LENGTH } from "./_shared.js";
|
3
|
+
/**
|
4
|
+
* Attempt to parse a string as a semantic version, returning a SemVer object.
|
5
|
+
*
|
6
|
+
* @example Usage
|
7
|
+
* ```ts
|
8
|
+
* import { parse } from "@std/semver/parse";
|
9
|
+
* import { assertEquals } from "@std/assert";
|
10
|
+
*
|
11
|
+
* const version = parse("1.2.3");
|
12
|
+
* assertEquals(version, {
|
13
|
+
* major: 1,
|
14
|
+
* minor: 2,
|
15
|
+
* patch: 3,
|
16
|
+
* prerelease: [],
|
17
|
+
* build: [],
|
18
|
+
* });
|
19
|
+
* ```
|
20
|
+
*
|
21
|
+
* @throws {TypeError} If the input string is invalid.
|
22
|
+
* @param value The version string to parse
|
23
|
+
* @returns A valid SemVer
|
24
|
+
*/
|
25
|
+
export function parse(value) {
|
26
|
+
if (typeof value !== "string") {
|
27
|
+
throw new TypeError(`Cannot parse version as version must be a string: received ${typeof value}`);
|
28
|
+
}
|
29
|
+
if (value.length > MAX_LENGTH) {
|
30
|
+
throw new TypeError(`Cannot parse version as version length is too long: length is ${value.length}, max length is ${MAX_LENGTH}`);
|
31
|
+
}
|
32
|
+
value = value.trim();
|
33
|
+
const groups = value.match(FULL_REGEXP)?.groups;
|
34
|
+
if (!groups)
|
35
|
+
throw new TypeError(`Cannot parse version: ${value}`);
|
36
|
+
const major = parseNumber(groups.major, `Cannot parse version ${value}: invalid major version`);
|
37
|
+
const minor = parseNumber(groups.minor, `Cannot parse version ${value}: invalid minor version`);
|
38
|
+
const patch = parseNumber(groups.patch, `Cannot parse version ${value}: invalid patch version`);
|
39
|
+
const prerelease = groups.prerelease
|
40
|
+
? parsePrerelease(groups.prerelease)
|
41
|
+
: [];
|
42
|
+
const build = groups.buildmetadata ? parseBuild(groups.buildmetadata) : [];
|
43
|
+
return { major, minor, patch, prerelease, build };
|
44
|
+
}
|
@@ -1,18 +1,18 @@
|
|
1
1
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
2
|
// This module is browser compatible.
|
3
3
|
import { COMPARATOR_REGEXP, OPERATOR_XRANGE_REGEXP, parseBuild, parseNumber, parsePrerelease, XRANGE, } from "./_shared.js";
|
4
|
-
import { ALL, ANY
|
4
|
+
import { ALL, ANY } from "./_constants.js";
|
5
5
|
function parseComparator(comparator) {
|
6
6
|
const match = comparator.match(COMPARATOR_REGEXP);
|
7
7
|
const groups = match?.groups;
|
8
8
|
if (!groups)
|
9
|
-
return
|
9
|
+
return null;
|
10
10
|
const { operator, prerelease, buildmetadata } = groups;
|
11
11
|
const semver = groups.major
|
12
12
|
? {
|
13
|
-
major: parseNumber(groups.major,
|
14
|
-
minor: parseNumber(groups.minor,
|
15
|
-
patch: parseNumber(groups.patch,
|
13
|
+
major: parseNumber(groups.major, `Cannot parse comparator ${comparator}: invalid major version`),
|
14
|
+
minor: parseNumber(groups.minor, `Cannot parse comparator ${comparator}: invalid minor version`),
|
15
|
+
patch: parseNumber(groups.patch, `Cannot parse comparator ${comparator}: invalid patch version`),
|
16
16
|
prerelease: prerelease ? parsePrerelease(prerelease) : [],
|
17
17
|
build: buildmetadata ? parseBuild(buildmetadata) : [],
|
18
18
|
}
|
@@ -317,19 +317,19 @@ function parseOperatorRange(string) {
|
|
317
317
|
case "":
|
318
318
|
return handleEqualOperator(groups);
|
319
319
|
default:
|
320
|
-
throw new Error(`'${groups.operator}' is not a valid operator
|
320
|
+
throw new Error(`Cannot parse version range: '${groups.operator}' is not a valid operator`);
|
321
321
|
}
|
322
322
|
}
|
323
323
|
function parseOperatorRanges(string) {
|
324
324
|
return string.split(/\s+/).flatMap(parseOperatorRange);
|
325
325
|
}
|
326
326
|
/**
|
327
|
-
* Parses a range string into a Range object
|
327
|
+
* Parses a range string into a {@linkcode Range} object.
|
328
328
|
*
|
329
329
|
* @example Usage
|
330
330
|
* ```ts
|
331
331
|
* import { parseRange } from "@std/semver/parse-range";
|
332
|
-
* import { assertEquals } from "@std/assert
|
332
|
+
* import { assertEquals } from "@std/assert";
|
333
333
|
*
|
334
334
|
* const range = parseRange(">=1.0.0 <2.0.0 || >=3.0.0");
|
335
335
|
* assertEquals(range, [
|
@@ -343,13 +343,18 @@ function parseOperatorRanges(string) {
|
|
343
343
|
* ]);
|
344
344
|
* ```
|
345
345
|
*
|
346
|
-
* @
|
347
|
-
* @
|
346
|
+
* @throws {TypeError} If the input range is invalid.
|
347
|
+
* @param value The range set string
|
348
|
+
* @returns A valid SemVer range
|
348
349
|
*/
|
349
|
-
export function parseRange(
|
350
|
-
|
350
|
+
export function parseRange(value) {
|
351
|
+
const result = value
|
351
352
|
// remove spaces between operators and versions
|
352
|
-
.replaceAll(/(
|
353
|
+
.replaceAll(/(?<=<|>|=|~|\^)(\s+)/g, "")
|
353
354
|
.split(/\s*\|\|\s*/)
|
354
355
|
.map((string) => parseHyphenRange(string) || parseOperatorRanges(string));
|
356
|
+
if (result.some((r) => r.includes(null))) {
|
357
|
+
throw new TypeError(`Cannot parse version range: range "${value}" is invalid`);
|
358
|
+
}
|
359
|
+
return result;
|
355
360
|
}
|
@@ -3,21 +3,21 @@
|
|
3
3
|
import { isWildcardComparator } from "./_shared.js";
|
4
4
|
import { compare } from "./compare.js";
|
5
5
|
import { satisfies } from "./satisfies.js";
|
6
|
-
function comparatorIntersects(
|
7
|
-
const op0 =
|
8
|
-
const op1 =
|
6
|
+
function comparatorIntersects(comparator1, comparator2) {
|
7
|
+
const op0 = comparator1.operator;
|
8
|
+
const op1 = comparator2.operator;
|
9
9
|
if (op0 === undefined) {
|
10
|
-
// if
|
11
|
-
if (isWildcardComparator(
|
10
|
+
// if comparator1 is empty comparator, then returns true
|
11
|
+
if (isWildcardComparator(comparator1))
|
12
12
|
return true;
|
13
|
-
return satisfies(
|
13
|
+
return satisfies(comparator1, [[comparator2]]);
|
14
14
|
}
|
15
15
|
if (op1 === undefined) {
|
16
|
-
if (isWildcardComparator(
|
16
|
+
if (isWildcardComparator(comparator2))
|
17
17
|
return true;
|
18
|
-
return satisfies(
|
18
|
+
return satisfies(comparator2, [[comparator1]]);
|
19
19
|
}
|
20
|
-
const cmp = compare(
|
20
|
+
const cmp = compare(comparator1, comparator2);
|
21
21
|
const sameDirectionIncreasing = (op0 === ">=" || op0 === ">") &&
|
22
22
|
(op1 === ">=" || op1 === ">");
|
23
23
|
const sameDirectionDecreasing = (op0 === "<=" || op0 === "<") &&
|
@@ -46,9 +46,9 @@ function rangesSatisfiable(ranges) {
|
|
46
46
|
function comparatorsSatisfiable(comparators) {
|
47
47
|
// Comparators are satisfiable if they all intersect with each other
|
48
48
|
for (let i = 0; i < comparators.length - 1; i++) {
|
49
|
-
const
|
50
|
-
for (const
|
51
|
-
if (!comparatorIntersects(
|
49
|
+
const comparator1 = comparators[i];
|
50
|
+
for (const comparator2 of comparators.slice(i + 1)) {
|
51
|
+
if (!comparatorIntersects(comparator1, comparator2)) {
|
52
52
|
return false;
|
53
53
|
}
|
54
54
|
}
|
@@ -56,32 +56,33 @@ function comparatorsSatisfiable(comparators) {
|
|
56
56
|
return true;
|
57
57
|
}
|
58
58
|
/**
|
59
|
-
* The ranges intersect every range of AND comparators intersects with a least
|
59
|
+
* The ranges intersect every range of AND comparators intersects with a least
|
60
|
+
* one range of OR ranges.
|
60
61
|
*
|
61
62
|
* @example Usage
|
62
63
|
* ```ts
|
63
64
|
* import { parseRange, rangeIntersects } from "@std/semver";
|
64
|
-
* import { assert
|
65
|
+
* import { assert } from "@std/assert";
|
65
66
|
*
|
66
|
-
* const
|
67
|
-
* const
|
68
|
-
* const
|
67
|
+
* const range1 = parseRange(">=1.0.0 <2.0.0");
|
68
|
+
* const range2 = parseRange(">=1.0.0 <1.2.3");
|
69
|
+
* const range3 = parseRange(">=1.2.3 <2.0.0");
|
69
70
|
*
|
70
|
-
* assert(rangeIntersects(
|
71
|
-
* assert(rangeIntersects(
|
72
|
-
*
|
71
|
+
* assert(rangeIntersects(range1, range2));
|
72
|
+
* assert(rangeIntersects(range1, range3));
|
73
|
+
* assert(!rangeIntersects(range2, range3));
|
73
74
|
* ```
|
74
75
|
*
|
75
|
-
* @param
|
76
|
-
* @param
|
76
|
+
* @param range1 range 0
|
77
|
+
* @param range2 range 1
|
77
78
|
* @returns returns true if the given ranges intersect, false otherwise
|
78
79
|
*/
|
79
|
-
export function rangeIntersects(
|
80
|
-
return rangesSatisfiable([
|
81
|
-
|
82
|
-
return
|
83
|
-
return
|
84
|
-
return r11.every((
|
80
|
+
export function rangeIntersects(range1, range2) {
|
81
|
+
return rangesSatisfiable([range1, range2]) &&
|
82
|
+
range1.some((range10) => {
|
83
|
+
return range2.some((r11) => {
|
84
|
+
return range10.every((comparator1) => {
|
85
|
+
return r11.every((comparator2) => comparatorIntersects(comparator1, comparator2));
|
85
86
|
});
|
86
87
|
});
|
87
88
|
});
|
@@ -1,12 +1,12 @@
|
|
1
1
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2
2
|
import { testComparatorSet } from "./_test_comparator_set.js";
|
3
3
|
/**
|
4
|
-
* Test to see if the
|
4
|
+
* Test to see if the SemVer satisfies the range.
|
5
5
|
*
|
6
6
|
* @example Usage
|
7
7
|
* ```ts
|
8
8
|
* import { parse, parseRange, satisfies } from "@std/semver";
|
9
|
-
* import { assert
|
9
|
+
* import { assert } from "@std/assert";
|
10
10
|
*
|
11
11
|
* const version = parse("1.2.3");
|
12
12
|
* const range0 = parseRange(">=1.0.0 <2.0.0");
|
@@ -15,7 +15,7 @@ import { testComparatorSet } from "./_test_comparator_set.js";
|
|
15
15
|
*
|
16
16
|
* assert(satisfies(version, range0));
|
17
17
|
* assert(satisfies(version, range1));
|
18
|
-
*
|
18
|
+
* assert(!satisfies(version, range2));
|
19
19
|
* ```
|
20
20
|
* @param version The version to test
|
21
21
|
* @param range The range to check
|