@lazy-node/semver-ampersand 3.0.11 → 3.0.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +61 -20
  3. package/lib/Range.d.ts +111 -0
  4. package/lib/Range.js +136 -0
  5. package/lib/Range.js.map +1 -1
  6. package/lib/comparator/detect.d.ts +14 -0
  7. package/lib/comparator/detect.js +14 -0
  8. package/lib/comparator/detect.js.map +1 -1
  9. package/lib/const.d.ts +38 -0
  10. package/lib/const.js +38 -0
  11. package/lib/const.js.map +1 -1
  12. package/lib/handleAmpersandAndSpaces.d.ts +16 -0
  13. package/lib/handleAmpersandAndSpaces.js +16 -0
  14. package/lib/handleAmpersandAndSpaces.js.map +1 -1
  15. package/lib/internal/parseOptionsOrLoose.d.ts +20 -0
  16. package/lib/internal/parseOptionsOrLoose.js +20 -0
  17. package/lib/internal/parseOptionsOrLoose.js.map +1 -1
  18. package/lib/maxSatisfying.d.ts +15 -0
  19. package/lib/maxSatisfying.js +15 -0
  20. package/lib/maxSatisfying.js.map +1 -1
  21. package/lib/minSatisfying.d.ts +15 -0
  22. package/lib/minSatisfying.js +15 -0
  23. package/lib/minSatisfying.js.map +1 -1
  24. package/lib/range/buildRangeSet.d.ts +13 -0
  25. package/lib/range/buildRangeSet.js +15 -0
  26. package/lib/range/buildRangeSet.js.map +1 -1
  27. package/lib/range/cache.d.ts +10 -0
  28. package/lib/range/cache.js +10 -0
  29. package/lib/range/cache.js.map +1 -1
  30. package/lib/range/fixComparatorSet.d.ts +50 -0
  31. package/lib/range/fixComparatorSet.js +50 -0
  32. package/lib/range/fixComparatorSet.js.map +1 -1
  33. package/lib/range/normalizeRangeInput.d.ts +14 -0
  34. package/lib/range/normalizeRangeInput.js +16 -0
  35. package/lib/range/normalizeRangeInput.js.map +1 -1
  36. package/lib/range/options.d.ts +38 -0
  37. package/lib/range/options.js +38 -0
  38. package/lib/range/options.js.map +1 -1
  39. package/lib/range/parseRange.d.ts +67 -0
  40. package/lib/range/parseRange.js +84 -0
  41. package/lib/range/parseRange.js.map +1 -1
  42. package/lib/range/stringifyRangeSet.d.ts +12 -0
  43. package/lib/range/stringifyRangeSet.js +12 -0
  44. package/lib/range/stringifyRangeSet.js.map +1 -1
  45. package/lib/range/toRangeString.d.ts +12 -0
  46. package/lib/range/toRangeString.js +12 -0
  47. package/lib/range/toRangeString.js.map +1 -1
  48. package/lib/range/util.d.ts +133 -0
  49. package/lib/range/util.js +213 -0
  50. package/lib/range/util.js.map +1 -1
  51. package/lib/satisfies.d.ts +17 -0
  52. package/lib/satisfies.js +17 -0
  53. package/lib/satisfies.js.map +1 -1
  54. package/lib/simplifyRange.d.ts +15 -0
  55. package/lib/simplifyRange.js +15 -0
  56. package/lib/simplifyRange.js.map +1 -1
  57. package/lib/types.d.ts +30 -0
  58. package/lib/types.js.map +1 -1
  59. package/lib/util/array.d.ts +14 -0
  60. package/lib/util/array.js +14 -0
  61. package/lib/util/array.js.map +1 -1
  62. package/lib/util/assert.d.ts +42 -0
  63. package/lib/util/assert.js +42 -0
  64. package/lib/util/assert.js.map +1 -1
  65. package/lib/util/fixBooleanProperty.d.ts +15 -0
  66. package/lib/util/fixBooleanProperty.js +18 -0
  67. package/lib/util/fixBooleanProperty.js.map +1 -1
  68. package/lib/util/index.d.ts +24 -0
  69. package/lib/util/index.js +24 -0
  70. package/lib/util/index.js.map +1 -1
  71. package/lib/util/split.d.ts +17 -0
  72. package/lib/util/split.js +17 -0
  73. package/lib/util/split.js.map +1 -1
  74. package/lib/util/stringifyComparators.d.ts +18 -0
  75. package/lib/util/stringifyComparators.js +18 -0
  76. package/lib/util/stringifyComparators.js.map +1 -1
  77. package/lib/validRange.d.ts +15 -1
  78. package/lib/validRange.js +15 -1
  79. package/lib/validRange.js.map +1 -1
  80. package/package.json +7 -5
@@ -1,41 +1,174 @@
1
1
  import { IOptions } from '../types';
2
2
  /**
3
+ * 這是傳給 string.replace(re[t.HYPHENRANGE]) 的回呼函式
3
4
  * This function is passed to string.replace(re[t.HYPHENRANGE])
4
5
  * M, m, patch, prerelease, build
5
6
  * 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
6
7
  * 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
7
8
  * 1.2 - 3.4 => >=1.2.0 <3.5.0-0
9
+ *
10
+ * 上界與下界分開推導:hyphen 範圍的兩端可各自是萬用字元,
11
+ * 必須先各自補成完整邊界,才能轉成等價的比較器組合。
12
+ * The lower and upper bounds are derived separately: either side of a hyphen
13
+ * range may be a wildcard, so each side must first be completed into an exact
14
+ * boundary before it can become an equivalent comparator pair.
15
+ *
16
+ * @param incPr - 是否將預發布版本納入比較 / Whether to include pre-release versions in the comparison
17
+ * @returns replace 用的回呼 / A callback for use with `replace`
8
18
  */
9
19
  export declare function hyphenReplace(incPr: boolean): ($0: string, from: string, fM: string, fm: string, fp: string, fpr: string, fb: string, to: string, tM: string, tm: string, tp: string, tpr: string, tb: string) => string;
20
+ /**
21
+ * 判斷版本段落是否為萬用字元
22
+ * Check whether a version segment is a wildcard
23
+ *
24
+ * 空字串也算萬用,因為正則在缺少該段時捕獲的是 '',
25
+ * 與 'x' / '*' 表達的是同一件事(任意值)。
26
+ * An empty string also counts as a wildcard: the regex captures '' when the
27
+ * segment is absent, and that means the same as 'x' / '*' (any value).
28
+ *
29
+ * @param id - 版本段落 / Version segment
30
+ * @returns 是否為萬用字元 / Whether it is a wildcard
31
+ */
10
32
  export declare function isX(id: string): id is '' | '0' | '*' | 'x';
33
+ /**
34
+ * 移除 >=0.0.0 這類無意義的下界
35
+ * Strip meaningless lower bounds such as >=0.0.0
36
+ *
37
+ * includePrerelease 時會改用允許預發布的樣式,
38
+ * 否則刪錯樣式會把 `-0` 一併吃掉,反而改變邊界。
39
+ * With includePrerelease the pre-release-friendly pattern is used; deleting
40
+ * the wrong pattern would swallow the `-0` suffix and change the boundary.
41
+ *
42
+ * @param comp - 比較器字串 / Comparator string
43
+ * @param options - 解析選項 / Parse options
44
+ * @returns 整理後的比較器字串 / Tidied comparator string
45
+ */
11
46
  export declare function replaceGTE0(comp: string, options: IOptions): string;
12
47
  /**
48
+ * 展開單一比較器為純比較器字串
49
+ * Expand a single comparator into plain comparators
50
+ *
13
51
  * comprised of xranges, tildes, stars, and gtlt's at this point.
14
52
  * already replaced the hyphen ranges
15
53
  * turn into a set of JUST comparators.
54
+ *
55
+ * 順序刻意為 caret → tilde → xrange → star:前者的輸出可能仍含後者
56
+ * 語法,逐一往下傳遞可避免重複處理或漏處理。
57
+ * The order is deliberately caret → tilde → xrange → star: an earlier step may
58
+ * emit syntax handled by a later one, so chaining downward avoids both
59
+ * double-processing and missed cases.
60
+ *
61
+ * @param comp - 比較器字串 / Comparator string
62
+ * @param options - 解析選項 / Parse options
63
+ * @returns 純比較器字串 / Plain comparator string
16
64
  */
17
65
  export declare function parseComparator(comp: string, options: IOptions): string;
18
66
  /**
67
+ * 展開 tilde(`~` / `~>`)語法
68
+ * Expand tilde (`~` / `~>`) syntax
69
+ *
19
70
  * ~, ~> --> * (any, kinda silly)
20
71
  * ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
21
72
  * ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
22
73
  * ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
74
+ *
75
+ * 以空白切割後逐段轉換再接回,可同時處理 `>=1.0.0 ~2.0.0` 這類混合字串。
76
+ * Splitting on whitespace, converting each piece, then rejoining lets mixed
77
+ * strings such as `>=1.0.0 ~2.0.0` be handled in one pass.
78
+ *
79
+ * @param comp - 比較器字串 / Comparator string
80
+ * @param options - 解析選項 / Parse options
81
+ * @returns 展開後的比較器字串 / Expanded comparator string
23
82
  */
24
83
  export declare function replaceTildes(comp: string, options: IOptions): string;
84
+ /**
85
+ * 展開單一 tilde 比較器
86
+ * Expand a single tilde comparator
87
+ *
88
+ * 分支由粗到細(major → minor → patch → 有無 prerelease),
89
+ * 一旦判定為萬用段落就不再往下檢查,確保每種寫法只會命中一個分支。
90
+ * Branches run coarse → fine (major → minor → patch → presence of a
91
+ * pre-release); once a wildcard segment matches, later checks are skipped so
92
+ * each spelling hits exactly one branch.
93
+ *
94
+ * @param comp - 比較器字串 / Comparator string
95
+ * @param options - 解析選項(loose 決定用哪組正則)/ Parse options (loose picks the regex flavour)
96
+ * @returns 展開後的比較器字串 / Expanded comparator string
97
+ */
25
98
  export declare function replaceTilde(comp: string, options: IOptions): string;
26
99
  /**
100
+ * 展開 caret(`^`)語法
101
+ * Expand caret (`^`) syntax
102
+ *
27
103
  * ^ --> * (any, kinda silly)
28
104
  * ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
29
105
  * ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
30
106
  * ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
31
107
  * ^1.2.3 --> >=1.2.3 <2.0.0-0
32
108
  * ^1.2.0 --> >=1.2.0 <2.0.0-0
109
+ *
110
+ * 與 replaceTildes 同樣以空白切割逐段轉換,保留混合字串的可讀性。
111
+ * Like replaceTildes, this splits on whitespace and converts piecewise so
112
+ * mixed strings stay supported.
113
+ *
114
+ * @param comp - 比較器字串 / Comparator string
115
+ * @param options - 解析選項 / Parse options
116
+ * @returns 展開後的比較器字串 / Expanded comparator string
33
117
  */
34
118
  export declare function replaceCarets(comp: string, options: IOptions): string;
119
+ /**
120
+ * 展開單一 caret 比較器
121
+ * Expand a single caret comparator
122
+ *
123
+ * caret 的上界取決於 major 是否為 0:`0.x` 代表尚未穩定,
124
+ * 只能保證 patch/minor 以下的相容性;`>=1` 則可放寬到下一個 major。
125
+ * The upper bound of a caret depends on whether major is 0: `0.x` means the
126
+ * API is not yet stable, so only patch/minor compatibility is promised, while
127
+ * `>=1` may relax up to the next major.
128
+ *
129
+ * @param comp - 比較器字串 / Comparator string
130
+ * @param options - 解析選項(loose 決定用哪組正則)/ Parse options (loose picks the regex flavour)
131
+ * @returns 展開後的比較器字串 / Expanded comparator string
132
+ */
35
133
  export declare function replaceCaret(comp: string, options: IOptions): string;
134
+ /**
135
+ * 展開 xrange(如 `>=1.2.x`、`1.x`)語法
136
+ * Expand xrange syntax (e.g. `>=1.2.x`, `1.x`)
137
+ *
138
+ * 以空白切割逐段轉換再接回,與 replaceTildes / replaceCarets 一致。
139
+ * Splitting on whitespace, converting piecewise, then rejoining — same
140
+ * strategy as replaceTildes / replaceCarets.
141
+ *
142
+ * @param comp - 比較器字串 / Comparator string
143
+ * @param options - 解析選項 / Parse options
144
+ * @returns 展開後的比較器字串 / Expanded comparator string
145
+ */
36
146
  export declare function replaceXRanges(comp: string, options: IOptions): string;
147
+ /**
148
+ * 展開單一 xrange 比較器
149
+ * Expand a single xrange comparator
150
+ *
151
+ * 萬用段落會連鎖展開(xM ⇒ xm ⇒ xp),讓「哪一段是萬用」只需要判斷一次;
152
+ * 運算子 `>` / `<=` 遇到萬用段落時必須改寫成等價的 `>=` / `<`,
153
+ * 因為萬用本身沒有明確邊界,直接輸出會得到不可比較的結果。
154
+ * Wildcards cascade (xM ⇒ xm ⇒ xp) so "which segment is a wildcard" is decided
155
+ * once; operators `>` / `<=` must be rewritten into the equivalent `>=` / `<`
156
+ * because a wildcard has no exact boundary and would otherwise produce a
157
+ * non-comparable result.
158
+ *
159
+ * @param comp - 比較器字串 / Comparator string
160
+ * @param options - 解析選項 / Parse options
161
+ * @returns 展開後的比較器字串 / Expanded comparator string
162
+ */
37
163
  export declare function replaceXRange(comp: string, options: IOptions): string;
38
164
  /**
165
+ * 移除星號萬用字元
166
+ * Strip star wildcards
167
+ *
39
168
  * and '' means "any version", just remove the *s entirely.
169
+ *
170
+ * @param comp - 比較器字串 / Comparator string
171
+ * @param options - 解析選項(此處刻意忽略)/ Parse options (deliberately ignored here)
172
+ * @returns 移除萬用字元後的字串 / String without wildcards
40
173
  */
41
174
  export declare function replaceStars(comp: string, options: IOptions): string;
package/lib/range/util.js CHANGED
@@ -11,16 +11,46 @@ exports.replaceCaret = replaceCaret;
11
11
  exports.replaceXRanges = replaceXRanges;
12
12
  exports.replaceXRange = replaceXRange;
13
13
  exports.replaceStars = replaceStars;
14
+ /**
15
+ * 範圍解析內部工具(移植自 semver/internal)
16
+ * Internal range parsing utilities (ported from semver/internal)
17
+ *
18
+ * 這裡是把 semver 的範圍語法(hyphen、tilde、caret、xrange、star)
19
+ * 展開成純比較器字串的核心;保留英文原註解以利與上游對照,
20
+ * 並以中文補充分支取捨的理由。
21
+ * These functions expand semver range syntax (hyphen, tilde, caret, xrange,
22
+ * star) into plain comparator strings. Upstream English comments are kept for
23
+ * easier diffing against the original; Chinese notes explain the rationale of
24
+ * each branch.
25
+ *
26
+ * @packageDocumentation
27
+ */
14
28
  const re_1 = require("semver/internal/re");
15
29
  /**
30
+ * 這是傳給 string.replace(re[t.HYPHENRANGE]) 的回呼函式
16
31
  * This function is passed to string.replace(re[t.HYPHENRANGE])
17
32
  * M, m, patch, prerelease, build
18
33
  * 1.2 - 3.4.5 => >=1.2.0 <=3.4.5
19
34
  * 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do
20
35
  * 1.2 - 3.4 => >=1.2.0 <3.5.0-0
36
+ *
37
+ * 上界與下界分開推導:hyphen 範圍的兩端可各自是萬用字元,
38
+ * 必須先各自補成完整邊界,才能轉成等價的比較器組合。
39
+ * The lower and upper bounds are derived separately: either side of a hyphen
40
+ * range may be a wildcard, so each side must first be completed into an exact
41
+ * boundary before it can become an equivalent comparator pair.
42
+ *
43
+ * @param incPr - 是否將預發布版本納入比較 / Whether to include pre-release versions in the comparison
44
+ * @returns replace 用的回呼 / A callback for use with `replace`
21
45
  */
22
46
  function hyphenReplace(incPr) {
23
47
  return ($0, from, fM, fm, fp, fpr, fb, to, tM, tm, tp, tpr, tb) => {
48
+ /**
49
+ * 下界(from):由粗到細檢查萬用字元,
50
+ * 越粗的段落(major → minor → patch)需要越寬的下界。
51
+ * Lower bound (from): wildcards are checked coarse → fine; the coarser
52
+ * the wildcard (major → minor → patch), the wider the lower bound must be.
53
+ */
24
54
  if (isX(fM)) {
25
55
  from = '';
26
56
  }
@@ -36,6 +66,13 @@ function hyphenReplace(incPr) {
36
66
  else {
37
67
  from = `>=${from}${incPr ? '-0' : ''}`;
38
68
  }
69
+ /**
70
+ * 上界(to):與下界相反,這裡一律補成「下一個版本之前」,
71
+ * 萬用段落要進位(如 3.4 → <3.5.0-0),已知段落則直接含入(<=)。
72
+ * Upper bound (to): mirrored against the lower bound — wildcards are
73
+ * rounded up (e.g. 3.4 → <3.5.0-0) while exact segments are included
74
+ * (<=).
75
+ */
39
76
  if (isX(tM)) {
40
77
  to = '';
41
78
  }
@@ -57,17 +94,55 @@ function hyphenReplace(incPr) {
57
94
  return (`${from} ${to}`).trim();
58
95
  };
59
96
  }
97
+ /**
98
+ * 判斷版本段落是否為萬用字元
99
+ * Check whether a version segment is a wildcard
100
+ *
101
+ * 空字串也算萬用,因為正則在缺少該段時捕獲的是 '',
102
+ * 與 'x' / '*' 表達的是同一件事(任意值)。
103
+ * An empty string also counts as a wildcard: the regex captures '' when the
104
+ * segment is absent, and that means the same as 'x' / '*' (any value).
105
+ *
106
+ * @param id - 版本段落 / Version segment
107
+ * @returns 是否為萬用字元 / Whether it is a wildcard
108
+ */
60
109
  function isX(id) {
61
110
  return !id || id.toLowerCase() === 'x' || id === '*';
62
111
  }
112
+ /**
113
+ * 移除 >=0.0.0 這類無意義的下界
114
+ * Strip meaningless lower bounds such as >=0.0.0
115
+ *
116
+ * includePrerelease 時會改用允許預發布的樣式,
117
+ * 否則刪錯樣式會把 `-0` 一併吃掉,反而改變邊界。
118
+ * With includePrerelease the pre-release-friendly pattern is used; deleting
119
+ * the wrong pattern would swallow the `-0` suffix and change the boundary.
120
+ *
121
+ * @param comp - 比較器字串 / Comparator string
122
+ * @param options - 解析選項 / Parse options
123
+ * @returns 整理後的比較器字串 / Tidied comparator string
124
+ */
63
125
  function replaceGTE0(comp, options) {
64
126
  return comp.trim()
65
127
  .replace(re_1.re[(options === null || options === void 0 ? void 0 : options.includePrerelease) ? re_1.t.GTE0PRE : re_1.t.GTE0], '');
66
128
  }
67
129
  /**
130
+ * 展開單一比較器為純比較器字串
131
+ * Expand a single comparator into plain comparators
132
+ *
68
133
  * comprised of xranges, tildes, stars, and gtlt's at this point.
69
134
  * already replaced the hyphen ranges
70
135
  * turn into a set of JUST comparators.
136
+ *
137
+ * 順序刻意為 caret → tilde → xrange → star:前者的輸出可能仍含後者
138
+ * 語法,逐一往下傳遞可避免重複處理或漏處理。
139
+ * The order is deliberately caret → tilde → xrange → star: an earlier step may
140
+ * emit syntax handled by a later one, so chaining downward avoids both
141
+ * double-processing and missed cases.
142
+ *
143
+ * @param comp - 比較器字串 / Comparator string
144
+ * @param options - 解析選項 / Parse options
145
+ * @returns 純比較器字串 / Plain comparator string
71
146
  */
72
147
  function parseComparator(comp, options) {
73
148
  comp = replaceCarets(comp, options);
@@ -77,16 +152,41 @@ function parseComparator(comp, options) {
77
152
  return comp;
78
153
  }
79
154
  /**
155
+ * 展開 tilde(`~` / `~>`)語法
156
+ * Expand tilde (`~` / `~>`) syntax
157
+ *
80
158
  * ~, ~> --> * (any, kinda silly)
81
159
  * ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0
82
160
  * ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0
83
161
  * ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0
162
+ *
163
+ * 以空白切割後逐段轉換再接回,可同時處理 `>=1.0.0 ~2.0.0` 這類混合字串。
164
+ * Splitting on whitespace, converting each piece, then rejoining lets mixed
165
+ * strings such as `>=1.0.0 ~2.0.0` be handled in one pass.
166
+ *
167
+ * @param comp - 比較器字串 / Comparator string
168
+ * @param options - 解析選項 / Parse options
169
+ * @returns 展開後的比較器字串 / Expanded comparator string
84
170
  */
85
171
  function replaceTildes(comp, options) {
86
172
  return comp.trim().split(/\s+/).map((comp) => {
87
173
  return replaceTilde(comp, options);
88
174
  }).join(' ');
89
175
  }
176
+ /**
177
+ * 展開單一 tilde 比較器
178
+ * Expand a single tilde comparator
179
+ *
180
+ * 分支由粗到細(major → minor → patch → 有無 prerelease),
181
+ * 一旦判定為萬用段落就不再往下檢查,確保每種寫法只會命中一個分支。
182
+ * Branches run coarse → fine (major → minor → patch → presence of a
183
+ * pre-release); once a wildcard segment matches, later checks are skipped so
184
+ * each spelling hits exactly one branch.
185
+ *
186
+ * @param comp - 比較器字串 / Comparator string
187
+ * @param options - 解析選項(loose 決定用哪組正則)/ Parse options (loose picks the regex flavour)
188
+ * @returns 展開後的比較器字串 / Expanded comparator string
189
+ */
90
190
  function replaceTilde(comp, options) {
91
191
  const r = options.loose ? re_1.re[re_1.t.TILDELOOSE] : re_1.re[re_1.t.TILDE];
92
192
  return comp.replace(r, (_, M, m, p, pr) => {
@@ -112,23 +212,55 @@ function replaceTilde(comp, options) {
112
212
  });
113
213
  }
114
214
  /**
215
+ * 展開 caret(`^`)語法
216
+ * Expand caret (`^`) syntax
217
+ *
115
218
  * ^ --> * (any, kinda silly)
116
219
  * ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0
117
220
  * ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0
118
221
  * ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0
119
222
  * ^1.2.3 --> >=1.2.3 <2.0.0-0
120
223
  * ^1.2.0 --> >=1.2.0 <2.0.0-0
224
+ *
225
+ * 與 replaceTildes 同樣以空白切割逐段轉換,保留混合字串的可讀性。
226
+ * Like replaceTildes, this splits on whitespace and converts piecewise so
227
+ * mixed strings stay supported.
228
+ *
229
+ * @param comp - 比較器字串 / Comparator string
230
+ * @param options - 解析選項 / Parse options
231
+ * @returns 展開後的比較器字串 / Expanded comparator string
121
232
  */
122
233
  function replaceCarets(comp, options) {
123
234
  return comp.trim().split(/\s+/).map((comp) => {
124
235
  return replaceCaret(comp, options);
125
236
  }).join(' ');
126
237
  }
238
+ /**
239
+ * 展開單一 caret 比較器
240
+ * Expand a single caret comparator
241
+ *
242
+ * caret 的上界取決於 major 是否為 0:`0.x` 代表尚未穩定,
243
+ * 只能保證 patch/minor 以下的相容性;`>=1` 則可放寬到下一個 major。
244
+ * The upper bound of a caret depends on whether major is 0: `0.x` means the
245
+ * API is not yet stable, so only patch/minor compatibility is promised, while
246
+ * `>=1` may relax up to the next major.
247
+ *
248
+ * @param comp - 比較器字串 / Comparator string
249
+ * @param options - 解析選項(loose 決定用哪組正則)/ Parse options (loose picks the regex flavour)
250
+ * @returns 展開後的比較器字串 / Expanded comparator string
251
+ */
127
252
  function replaceCaret(comp, options) {
128
253
  const r = options.loose ? re_1.re[re_1.t.CARETLOOSE] : re_1.re[re_1.t.CARET];
129
254
  const z = options.includePrerelease ? '-0' : '';
130
255
  return comp.replace(r, (_, M, m, p, pr) => {
131
256
  let ret;
257
+ /**
258
+ * 萬用段落由粗到細判定;includePrerelease 時下界補 `-0`,
259
+ * 讓 `1.0.0-0` 這類最低預發布版本也被納入。
260
+ * Wildcards are checked coarse → fine; with includePrerelease the lower
261
+ * bound gains `-0` so the lowest pre-release (e.g. `1.0.0-0`) is
262
+ * included.
263
+ */
132
264
  if (isX(M)) {
133
265
  ret = '';
134
266
  }
@@ -136,6 +268,13 @@ function replaceCaret(comp, options) {
136
268
  ret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`;
137
269
  }
138
270
  else if (isX(p)) {
271
+ /**
272
+ * major 為 0 時上界只能進位到 minor(避免跨過不相容的 patch),
273
+ * 否則可一路放行到下一個 major。
274
+ * When major is 0 the upper bound may only roll over the minor
275
+ * (to avoid crossing an incompatible patch); otherwise the next
276
+ * major is allowed.
277
+ */
139
278
  if (M === '0') {
140
279
  ret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`;
141
280
  }
@@ -144,6 +283,13 @@ function replaceCaret(comp, options) {
144
283
  }
145
284
  }
146
285
  else if (pr) {
286
+ /**
287
+ * 有預發布標籤時沿用原 patch 作為下界,並依 major/minor 是否為 0
288
+ * 決定上界進位的位置(0.0.x → patch、0.x → minor、其餘 → major)。
289
+ * With a pre-release tag the original patch stays as the lower
290
+ * bound, while the upper bound rolls over patch/minor/major
291
+ * depending on whether major/minor is 0.
292
+ */
147
293
  if (M === '0') {
148
294
  if (m === '0') {
149
295
  ret = `>=${M}.${m}.${p}-${pr} <${M}.${m}.${+p + 1}-0`;
@@ -157,6 +303,12 @@ function replaceCaret(comp, options) {
157
303
  }
158
304
  }
159
305
  else {
306
+ /**
307
+ * 無預發布標籤時的分支結構與上一段相同,
308
+ * 差別在於下界不帶 `-pr`,且 z 只在 includePrerelease 時加入。
309
+ * Same shape as the previous block, except the lower bound carries
310
+ * no `-pr` and `z` only appears under includePrerelease.
311
+ */
160
312
  if (M === '0') {
161
313
  if (m === '0') {
162
314
  ret = `>=${M}.${m}.${p}${z} <${M}.${m}.${+p + 1}-0`;
@@ -172,11 +324,39 @@ function replaceCaret(comp, options) {
172
324
  return ret;
173
325
  });
174
326
  }
327
+ /**
328
+ * 展開 xrange(如 `>=1.2.x`、`1.x`)語法
329
+ * Expand xrange syntax (e.g. `>=1.2.x`, `1.x`)
330
+ *
331
+ * 以空白切割逐段轉換再接回,與 replaceTildes / replaceCarets 一致。
332
+ * Splitting on whitespace, converting piecewise, then rejoining — same
333
+ * strategy as replaceTildes / replaceCarets.
334
+ *
335
+ * @param comp - 比較器字串 / Comparator string
336
+ * @param options - 解析選項 / Parse options
337
+ * @returns 展開後的比較器字串 / Expanded comparator string
338
+ */
175
339
  function replaceXRanges(comp, options) {
176
340
  return comp.split(/\s+/).map((comp) => {
177
341
  return replaceXRange(comp, options);
178
342
  }).join(' ');
179
343
  }
344
+ /**
345
+ * 展開單一 xrange 比較器
346
+ * Expand a single xrange comparator
347
+ *
348
+ * 萬用段落會連鎖展開(xM ⇒ xm ⇒ xp),讓「哪一段是萬用」只需要判斷一次;
349
+ * 運算子 `>` / `<=` 遇到萬用段落時必須改寫成等價的 `>=` / `<`,
350
+ * 因為萬用本身沒有明確邊界,直接輸出會得到不可比較的結果。
351
+ * Wildcards cascade (xM ⇒ xm ⇒ xp) so "which segment is a wildcard" is decided
352
+ * once; operators `>` / `<=` must be rewritten into the equivalent `>=` / `<`
353
+ * because a wildcard has no exact boundary and would otherwise produce a
354
+ * non-comparable result.
355
+ *
356
+ * @param comp - 比較器字串 / Comparator string
357
+ * @param options - 解析選項 / Parse options
358
+ * @returns 展開後的比較器字串 / Expanded comparator string
359
+ */
180
360
  function replaceXRange(comp, options) {
181
361
  comp = comp.trim();
182
362
  const r = options.loose ? re_1.re[re_1.t.XRANGELOOSE] : re_1.re[re_1.t.XRANGE];
@@ -185,12 +365,23 @@ function replaceXRange(comp, options) {
185
365
  const xm = xM || isX(m);
186
366
  const xp = xm || isX(p);
187
367
  const anyX = xp;
368
+ /**
369
+ * `=1.x` 等同於 `1.x`,先去掉運算子避免後續產生 `>=1.x` 這種殘缺輸出
370
+ * `=1.x` means the same as `1.x`; drop the operator so the output never
371
+ * degenerates into a broken `>=1.x`
372
+ */
188
373
  if (gtlt === '=' && anyX) {
189
374
  gtlt = '';
190
375
  }
191
376
  // if we're including prereleases in the match, then we need
192
377
  // to fix this to -0, the lowest possible prerelease value
193
378
  pr = options.includePrerelease ? '-0' : '';
379
+ /**
380
+ * major 本身就是萬用:`>x` / `<x` 沒有任何可比較的版本
381
+ * (回傳 <0.0.0-0),其餘情況代表「任意版本」(回傳 *)。
382
+ * major itself is a wildcard: `>x` / `<x` can never match
383
+ * (<0.0.0-0), anything else means "any version" (`*`).
384
+ */
194
385
  if (xM) {
195
386
  if (gtlt === '>' || gtlt === '<') {
196
387
  // nothing is allowed
@@ -208,6 +399,14 @@ function replaceXRange(comp, options) {
208
399
  m = 0;
209
400
  }
210
401
  p = 0;
402
+ /**
403
+ * `>` 遇到萬用段落要進位成 `>=` 下一個值:
404
+ * `>1` → `>=2.0.0`、`>1.2` → `>=1.3.0`,
405
+ * 否則會把被萬用涵蓋的版本誤判為符合。
406
+ * `>` over a wildcard must round up to `>=` of the next value
407
+ * (`>1` → `>=2.0.0`, `>1.2` → `>=1.3.0`), otherwise versions the
408
+ * wildcard covers would be wrongly accepted.
409
+ */
211
410
  if (gtlt === '>') {
212
411
  // >1 => >=2.0.0
213
412
  // >1.2 => >=1.3.0
@@ -233,6 +432,13 @@ function replaceXRange(comp, options) {
233
432
  m = +m + 1;
234
433
  }
235
434
  }
435
+ /**
436
+ * 上界一律補 `-0`:沒有預發布的上界會把 `x.0.0-0` 之外的
437
+ * 預發布版本也包含進來,與 semver 的預設行為不符。
438
+ * Upper bounds always gain `-0`; without it, pre-releases below
439
+ * the boundary would be included, which contradicts semver's
440
+ * default behavior.
441
+ */
236
442
  if (gtlt === '<') {
237
443
  pr = '-0';
238
444
  }
@@ -248,7 +454,14 @@ function replaceXRange(comp, options) {
248
454
  });
249
455
  }
250
456
  /**
457
+ * 移除星號萬用字元
458
+ * Strip star wildcards
459
+ *
251
460
  * and '' means "any version", just remove the *s entirely.
461
+ *
462
+ * @param comp - 比較器字串 / Comparator string
463
+ * @param options - 解析選項(此處刻意忽略)/ Parse options (deliberately ignored here)
464
+ * @returns 移除萬用字元後的字串 / String without wildcards
252
465
  */
253
466
  function replaceStars(comp, options) {
254
467
  // Looseness is ignored here. star is always as loose as it gets!
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";;AAWA,sCAuDC;AAED,kBAGC;AAED,kCAIC;AAOD,0CAOC;AAQD,sCAMC;AAED,oCAoCC;AAUD,sCAMC;AAED,oCA4EC;AAED,wCAOC;AAED,sCA+FC;AAKD,oCAIC;AAhWD,2CAA2C;AAI3C;;;;;;GAMG;AACH,SAAgB,aAAa,CAAC,KAA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AI,CAAC,KAAK,EACtB,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAA;QACvB,CAAC;QAED,OAAO,GAAG,CAAA;IACX,CAAC,CAAC,CAAA;AACH,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY,CAAC,IAAY,EAAE,OAAiB;IAE3D,kEAAkE;IAClE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["import { re, t } from 'semver/internal/re';\nimport { IOptions } from '../types';\nimport { EnumSemverVersion } from '../const';\n\n/**\n * This function is passed to string.replace(re[t.HYPHENRANGE])\n * M, m, patch, prerelease, build\n * 1.2 - 3.4.5 => >=1.2.0 <=3.4.5\n * 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do\n * 1.2 - 3.4 => >=1.2.0 <3.5.0-0\n */\nexport function hyphenReplace(incPr: boolean)\n{\n\treturn ($0: string,\n\t\tfrom: string, fM: string, fm: string, fp: string, fpr: string, fb: string,\n\t\tto: string, tM: string, tm: string, tp: string, tpr: string, tb: string,\n\t) =>\n\t{\n\t\tif (isX(fM))\n\t\t{\n\t\t\tfrom = ''\n\t\t}\n\t\telse if (isX(fm))\n\t\t{\n\t\t\tfrom = `>=${fM}.0.0${incPr ? '-0' : ''}`\n\t\t}\n\t\telse if (isX(fp))\n\t\t{\n\t\t\tfrom = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`\n\t\t}\n\t\telse if (fpr)\n\t\t{\n\t\t\tfrom = `>=${from}`\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfrom = `>=${from}${incPr ? '-0' : ''}`\n\t\t}\n\n\t\tif (isX(tM))\n\t\t{\n\t\t\tto = ''\n\t\t}\n\t\telse if (isX(tm))\n\t\t{\n\t\t\tto = `<${+tM + 1}.0.0-0`\n\t\t}\n\t\telse if (isX(tp))\n\t\t{\n\t\t\tto = `<${tM}.${+tm + 1}.0-0`\n\t\t}\n\t\telse if (tpr)\n\t\t{\n\t\t\tto = `<=${tM}.${tm}.${tp}-${tpr}`\n\t\t}\n\t\telse if (incPr)\n\t\t{\n\t\t\tto = `<${tM}.${tm}.${+tp + 1}-0`\n\t\t}\n\t\telse\n\t\t{\n\t\t\tto = `<=${to}`\n\t\t}\n\n\t\treturn (`${from} ${to}`).trim()\n\t};\n}\n\nexport function isX(id: string): id is '' | '0' | '*' | 'x'\n{\n\treturn !id || id.toLowerCase() === 'x' || id === '*';\n}\n\nexport function replaceGTE0(comp: string, options: IOptions)\n{\n\treturn comp.trim()\n\t\t.replace(re[options?.includePrerelease ? t.GTE0PRE : t.GTE0], '')\n}\n\n/**\n * comprised of xranges, tildes, stars, and gtlt's at this point.\n * already replaced the hyphen ranges\n * turn into a set of JUST comparators.\n */\nexport function parseComparator(comp: string, options: IOptions)\n{\n\tcomp = replaceCarets(comp, options)\n\tcomp = replaceTildes(comp, options)\n\tcomp = replaceXRanges(comp, options)\n\tcomp = replaceStars(comp, options)\n\treturn comp\n}\n\n/**\n * ~, ~> --> * (any, kinda silly)\n * ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0\n * ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0\n * ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0\n */\nexport function replaceTildes(comp: string, options: IOptions)\n{\n\treturn comp.trim().split(/\\s+/).map((comp) =>\n\t{\n\t\treturn replaceTilde(comp, options)\n\t}).join(' ');\n}\n\nexport function replaceTilde(comp: string, options: IOptions)\n{\n\tconst r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]\n\treturn comp.replace(r, (_, M, m, p, pr) =>\n\t{\n\n\t\tlet ret: string\n\n\t\tif (isX(M))\n\t\t{\n\t\t\tret = ''\n\t\t}\n\t\telse if (isX(m))\n\t\t{\n\t\t\tret = `>=${M}.0.0 <${+M + 1}.0.0-0`\n\t\t}\n\t\telse if (isX(p))\n\t\t{\n\t\t\t// ~1.2 == >=1.2.0 <1.3.0-0\n\t\t\tret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`\n\t\t}\n\t\telse if (pr)\n\t\t{\n\n\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// ~1.2.3 == >=1.2.3 <1.3.0-0\n\t\t\tret = `>=${M}.${m}.${p\n\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t}\n\n\t\treturn ret\n\t})\n}\n\n/**\n * ^ --> * (any, kinda silly)\n * ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0\n * ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0\n * ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0\n * ^1.2.3 --> >=1.2.3 <2.0.0-0\n * ^1.2.0 --> >=1.2.0 <2.0.0-0\n */\nexport function replaceCarets(comp: string, options: IOptions)\n{\n\treturn comp.trim().split(/\\s+/).map((comp) =>\n\t{\n\t\treturn replaceCaret(comp, options)\n\t}).join(' ');\n}\n\nexport function replaceCaret(comp: string, options: IOptions)\n{\n\n\tconst r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]\n\tconst z = options.includePrerelease ? '-0' : ''\n\treturn comp.replace(r, (_, M, m, p, pr) =>\n\t{\n\n\t\tlet ret: string\n\n\t\tif (isX(M))\n\t\t{\n\t\t\tret = ''\n\t\t}\n\t\telse if (isX(m))\n\t\t{\n\t\t\tret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`\n\t\t}\n\t\telse if (isX(p))\n\t\t{\n\t\t\tif (M === '0')\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`\n\t\t\t}\n\t\t}\n\t\telse if (pr)\n\t\t{\n\n\t\t\tif (M === '0')\n\t\t\t{\n\t\t\t\tif (m === '0')\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t\t\t} <${M}.${m}.${+p + 1}-0`\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t\t} <${+M + 1}.0.0-0`\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\tif (M === '0')\n\t\t\t{\n\t\t\t\tif (m === '0')\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p\n\t\t\t\t\t}${z} <${M}.${m}.${+p + 1}-0`\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p\n\t\t\t\t\t}${z} <${M}.${+m + 1}.0-0`\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.${p\n\t\t\t\t} <${+M + 1}.0.0-0`\n\t\t\t}\n\t\t}\n\n\t\treturn ret\n\t})\n}\n\nexport function replaceXRanges(comp: string, options: IOptions)\n{\n\n\treturn comp.split(/\\s+/).map((comp) =>\n\t{\n\t\treturn replaceXRange(comp, options)\n\t}).join(' ')\n}\n\nexport function replaceXRange(comp: string, options: IOptions)\n{\n\tcomp = comp.trim()\n\tconst r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]\n\treturn comp.replace(r, (ret, gtlt, M, m, p, pr) =>\n\t{\n\n\t\tconst xM = isX(M)\n\t\tconst xm = xM || isX(m)\n\t\tconst xp = xm || isX(p)\n\t\tconst anyX = xp\n\n\t\tif (gtlt === '=' && anyX)\n\t\t{\n\t\t\tgtlt = ''\n\t\t}\n\n\t\t// if we're including prereleases in the match, then we need\n\t\t// to fix this to -0, the lowest possible prerelease value\n\t\tpr = options.includePrerelease ? '-0' : ''\n\n\t\tif (xM)\n\t\t{\n\t\t\tif (gtlt === '>' || gtlt === '<')\n\t\t\t{\n\t\t\t\t// nothing is allowed\n\t\t\t\tret = EnumSemverVersion.NULL\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// nothing is forbidden\n\t\t\t\tret = EnumSemverVersion.STAR\n\t\t\t}\n\t\t}\n\t\telse if (gtlt && anyX)\n\t\t{\n\t\t\t// we know patch is an x, because we have any x at all.\n\t\t\t// replace X with 0\n\t\t\tif (xm)\n\t\t\t{\n\t\t\t\tm = 0\n\t\t\t}\n\t\t\tp = 0\n\n\t\t\tif (gtlt === '>')\n\t\t\t{\n\t\t\t\t// >1 => >=2.0.0\n\t\t\t\t// >1.2 => >=1.3.0\n\t\t\t\tgtlt = '>='\n\t\t\t\tif (xm)\n\t\t\t\t{\n\t\t\t\t\tM = +M + 1\n\t\t\t\t\tm = 0\n\t\t\t\t\tp = 0\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tm = +m + 1\n\t\t\t\t\tp = 0\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (gtlt === '<=')\n\t\t\t{\n\t\t\t\t// <=0.7.x is actually <0.8.0, since any 0.7.x should\n\t\t\t\t// pass. Similarly, <=7.x is actually <8.0.0, etc.\n\t\t\t\tgtlt = '<'\n\t\t\t\tif (xm)\n\t\t\t\t{\n\t\t\t\t\tM = +M + 1\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tm = +m + 1\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (gtlt === '<')\n\t\t\t{\n\t\t\t\tpr = '-0'\n\t\t\t}\n\n\t\t\tret = `${gtlt + M}.${m}.${p}${pr}`\n\t\t}\n\t\telse if (xm)\n\t\t{\n\t\t\tret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`\n\t\t}\n\t\telse if (xp)\n\t\t{\n\t\t\tret = `>=${M}.${m}.0${pr\n\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t}\n\n\t\treturn ret\n\t})\n}\n\n/**\n * and '' means \"any version\", just remove the *s entirely.\n */\nexport function replaceStars(comp: string, options: IOptions)\n{\n\t// Looseness is ignored here. star is always as loose as it gets!\n\treturn comp.trim().replace(re[t.STAR], '')\n}\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";;AAmCA,sCAoEC;AAcD,kBAGC;AAeD,kCAIC;AAoBD,0CAOC;AAmBD,sCAMC;AAgBD,oCAoCC;AAqBD,sCAMC;AAgBD,oCAuGC;AAcD,wCAOC;AAkBD,sCAyHC;AAYD,oCAIC;AArjBD;;;;;;;;;;;;;GAaG;AACH,2CAA2C;AAI3C;;;;;;;;;;;;;;;;GAgBG;AACH,SAAgB,aAAa,CAAC,KAAc;IAE3C,OAAO,CAAC,EAAU,EACjB,IAAY,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,GAAW,EAAE,EAAU,EACzE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,GAAW,EAAE,EAAU,EACtE,EAAE;QAEH;;;;;WAKG;QACH,IAAI,GAAG,CAAC,EAAE,CAAC,EACX,CAAC;YACA,IAAI,GAAG,EAAE,CAAA;QACV,CAAC;aACI,IAAI,GAAG,CAAC,EAAE,CAAC,EAChB,CAAC;YACA,IAAI,GAAG,KAAK,EAAE,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAA;QACzC,CAAC;aACI,IAAI,GAAG,CAAC,EAAE,CAAC,EAChB,CAAC;YACA,IAAI,GAAG,KAAK,EAAE,IAAI,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EA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,IAAI,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;AAC3C,CAAC","sourcesContent":["/**\n * 範圍解析內部工具(移植自 semver/internal)\n * Internal range parsing utilities (ported from semver/internal)\n *\n * 這裡是把 semver 的範圍語法(hyphen、tilde、caret、xrange、star)\n * 展開成純比較器字串的核心;保留英文原註解以利與上游對照,\n * 並以中文補充分支取捨的理由。\n * These functions expand semver range syntax (hyphen, tilde, caret, xrange,\n * star) into plain comparator strings. Upstream English comments are kept for\n * easier diffing against the original; Chinese notes explain the rationale of\n * each branch.\n *\n * @packageDocumentation\n */\nimport { re, t } from 'semver/internal/re';\nimport { IOptions } from '../types';\nimport { EnumSemverVersion } from '../const';\n\n/**\n * 這是傳給 string.replace(re[t.HYPHENRANGE]) 的回呼函式\n * This function is passed to string.replace(re[t.HYPHENRANGE])\n * M, m, patch, prerelease, build\n * 1.2 - 3.4.5 => >=1.2.0 <=3.4.5\n * 1.2.3 - 3.4 => >=1.2.0 <3.5.0-0 Any 3.4.x will do\n * 1.2 - 3.4 => >=1.2.0 <3.5.0-0\n *\n * 上界與下界分開推導:hyphen 範圍的兩端可各自是萬用字元,\n * 必須先各自補成完整邊界,才能轉成等價的比較器組合。\n * The lower and upper bounds are derived separately: either side of a hyphen\n * range may be a wildcard, so each side must first be completed into an exact\n * boundary before it can become an equivalent comparator pair.\n *\n * @param incPr - 是否將預發布版本納入比較 / Whether to include pre-release versions in the comparison\n * @returns replace 用的回呼 / A callback for use with `replace`\n */\nexport function hyphenReplace(incPr: boolean)\n{\n\treturn ($0: string,\n\t\tfrom: string, fM: string, fm: string, fp: string, fpr: string, fb: string,\n\t\tto: string, tM: string, tm: string, tp: string, tpr: string, tb: string,\n\t) =>\n\t{\n\t\t/**\n\t\t * 下界(from):由粗到細檢查萬用字元,\n\t\t * 越粗的段落(major → minor → patch)需要越寬的下界。\n\t\t * Lower bound (from): wildcards are checked coarse → fine; the coarser\n\t\t * the wildcard (major → minor → patch), the wider the lower bound must be.\n\t\t */\n\t\tif (isX(fM))\n\t\t{\n\t\t\tfrom = ''\n\t\t}\n\t\telse if (isX(fm))\n\t\t{\n\t\t\tfrom = `>=${fM}.0.0${incPr ? '-0' : ''}`\n\t\t}\n\t\telse if (isX(fp))\n\t\t{\n\t\t\tfrom = `>=${fM}.${fm}.0${incPr ? '-0' : ''}`\n\t\t}\n\t\telse if (fpr)\n\t\t{\n\t\t\tfrom = `>=${from}`\n\t\t}\n\t\telse\n\t\t{\n\t\t\tfrom = `>=${from}${incPr ? '-0' : ''}`\n\t\t}\n\n\t\t/**\n\t\t * 上界(to):與下界相反,這裡一律補成「下一個版本之前」,\n\t\t * 萬用段落要進位(如 3.4 → <3.5.0-0),已知段落則直接含入(<=)。\n\t\t * Upper bound (to): mirrored against the lower bound — wildcards are\n\t\t * rounded up (e.g. 3.4 → <3.5.0-0) while exact segments are included\n\t\t * (<=).\n\t\t */\n\t\tif (isX(tM))\n\t\t{\n\t\t\tto = ''\n\t\t}\n\t\telse if (isX(tm))\n\t\t{\n\t\t\tto = `<${+tM + 1}.0.0-0`\n\t\t}\n\t\telse if (isX(tp))\n\t\t{\n\t\t\tto = `<${tM}.${+tm + 1}.0-0`\n\t\t}\n\t\telse if (tpr)\n\t\t{\n\t\t\tto = `<=${tM}.${tm}.${tp}-${tpr}`\n\t\t}\n\t\telse if (incPr)\n\t\t{\n\t\t\tto = `<${tM}.${tm}.${+tp + 1}-0`\n\t\t}\n\t\telse\n\t\t{\n\t\t\tto = `<=${to}`\n\t\t}\n\n\t\treturn (`${from} ${to}`).trim()\n\t};\n}\n\n/**\n * 判斷版本段落是否為萬用字元\n * Check whether a version segment is a wildcard\n *\n * 空字串也算萬用,因為正則在缺少該段時捕獲的是 '',\n * 與 'x' / '*' 表達的是同一件事(任意值)。\n * An empty string also counts as a wildcard: the regex captures '' when the\n * segment is absent, and that means the same as 'x' / '*' (any value).\n *\n * @param id - 版本段落 / Version segment\n * @returns 是否為萬用字元 / Whether it is a wildcard\n */\nexport function isX(id: string): id is '' | '0' | '*' | 'x'\n{\n\treturn !id || id.toLowerCase() === 'x' || id === '*';\n}\n\n/**\n * 移除 >=0.0.0 這類無意義的下界\n * Strip meaningless lower bounds such as >=0.0.0\n *\n * includePrerelease 時會改用允許預發布的樣式,\n * 否則刪錯樣式會把 `-0` 一併吃掉,反而改變邊界。\n * With includePrerelease the pre-release-friendly pattern is used; deleting\n * the wrong pattern would swallow the `-0` suffix and change the boundary.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項 / Parse options\n * @returns 整理後的比較器字串 / Tidied comparator string\n */\nexport function replaceGTE0(comp: string, options: IOptions)\n{\n\treturn comp.trim()\n\t\t.replace(re[options?.includePrerelease ? t.GTE0PRE : t.GTE0], '')\n}\n\n/**\n * 展開單一比較器為純比較器字串\n * Expand a single comparator into plain comparators\n *\n * comprised of xranges, tildes, stars, and gtlt's at this point.\n * already replaced the hyphen ranges\n * turn into a set of JUST comparators.\n *\n * 順序刻意為 caret → tilde → xrange → star:前者的輸出可能仍含後者\n * 語法,逐一往下傳遞可避免重複處理或漏處理。\n * The order is deliberately caret → tilde → xrange → star: an earlier step may\n * emit syntax handled by a later one, so chaining downward avoids both\n * double-processing and missed cases.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項 / Parse options\n * @returns 純比較器字串 / Plain comparator string\n */\nexport function parseComparator(comp: string, options: IOptions)\n{\n\tcomp = replaceCarets(comp, options)\n\tcomp = replaceTildes(comp, options)\n\tcomp = replaceXRanges(comp, options)\n\tcomp = replaceStars(comp, options)\n\treturn comp\n}\n\n/**\n * 展開 tilde(`~` / `~>`)語法\n * Expand tilde (`~` / `~>`) syntax\n *\n * ~, ~> --> * (any, kinda silly)\n * ~2, ~2.x, ~2.x.x, ~>2, ~>2.x ~>2.x.x --> >=2.0.0 <3.0.0-0\n * ~2.0, ~2.0.x, ~>2.0, ~>2.0.x --> >=2.0.0 <2.1.0-0\n * ~1.2, ~1.2.x, ~>1.2, ~>1.2.x --> >=1.2.0 <1.3.0-0\n *\n * 以空白切割後逐段轉換再接回,可同時處理 `>=1.0.0 ~2.0.0` 這類混合字串。\n * Splitting on whitespace, converting each piece, then rejoining lets mixed\n * strings such as `>=1.0.0 ~2.0.0` be handled in one pass.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項 / Parse options\n * @returns 展開後的比較器字串 / Expanded comparator string\n */\nexport function replaceTildes(comp: string, options: IOptions)\n{\n\treturn comp.trim().split(/\\s+/).map((comp) =>\n\t{\n\t\treturn replaceTilde(comp, options)\n\t}).join(' ');\n}\n\n/**\n * 展開單一 tilde 比較器\n * Expand a single tilde comparator\n *\n * 分支由粗到細(major → minor → patch → 有無 prerelease),\n * 一旦判定為萬用段落就不再往下檢查,確保每種寫法只會命中一個分支。\n * Branches run coarse → fine (major → minor → patch → presence of a\n * pre-release); once a wildcard segment matches, later checks are skipped so\n * each spelling hits exactly one branch.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項(loose 決定用哪組正則)/ Parse options (loose picks the regex flavour)\n * @returns 展開後的比較器字串 / Expanded comparator string\n */\nexport function replaceTilde(comp: string, options: IOptions)\n{\n\tconst r = options.loose ? re[t.TILDELOOSE] : re[t.TILDE]\n\treturn comp.replace(r, (_, M, m, p, pr) =>\n\t{\n\n\t\tlet ret: string\n\n\t\tif (isX(M))\n\t\t{\n\t\t\tret = ''\n\t\t}\n\t\telse if (isX(m))\n\t\t{\n\t\t\tret = `>=${M}.0.0 <${+M + 1}.0.0-0`\n\t\t}\n\t\telse if (isX(p))\n\t\t{\n\t\t\t// ~1.2 == >=1.2.0 <1.3.0-0\n\t\t\tret = `>=${M}.${m}.0 <${M}.${+m + 1}.0-0`\n\t\t}\n\t\telse if (pr)\n\t\t{\n\n\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t}\n\t\telse\n\t\t{\n\t\t\t// ~1.2.3 == >=1.2.3 <1.3.0-0\n\t\t\tret = `>=${M}.${m}.${p\n\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t}\n\n\t\treturn ret\n\t})\n}\n\n/**\n * 展開 caret(`^`)語法\n * Expand caret (`^`) syntax\n *\n * ^ --> * (any, kinda silly)\n * ^2, ^2.x, ^2.x.x --> >=2.0.0 <3.0.0-0\n * ^2.0, ^2.0.x --> >=2.0.0 <3.0.0-0\n * ^1.2, ^1.2.x --> >=1.2.0 <2.0.0-0\n * ^1.2.3 --> >=1.2.3 <2.0.0-0\n * ^1.2.0 --> >=1.2.0 <2.0.0-0\n *\n * 與 replaceTildes 同樣以空白切割逐段轉換,保留混合字串的可讀性。\n * Like replaceTildes, this splits on whitespace and converts piecewise so\n * mixed strings stay supported.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項 / Parse options\n * @returns 展開後的比較器字串 / Expanded comparator string\n */\nexport function replaceCarets(comp: string, options: IOptions)\n{\n\treturn comp.trim().split(/\\s+/).map((comp) =>\n\t{\n\t\treturn replaceCaret(comp, options)\n\t}).join(' ');\n}\n\n/**\n * 展開單一 caret 比較器\n * Expand a single caret comparator\n *\n * caret 的上界取決於 major 是否為 0:`0.x` 代表尚未穩定,\n * 只能保證 patch/minor 以下的相容性;`>=1` 則可放寬到下一個 major。\n * The upper bound of a caret depends on whether major is 0: `0.x` means the\n * API is not yet stable, so only patch/minor compatibility is promised, while\n * `>=1` may relax up to the next major.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項(loose 決定用哪組正則)/ Parse options (loose picks the regex flavour)\n * @returns 展開後的比較器字串 / Expanded comparator string\n */\nexport function replaceCaret(comp: string, options: IOptions)\n{\n\n\tconst r = options.loose ? re[t.CARETLOOSE] : re[t.CARET]\n\tconst z = options.includePrerelease ? '-0' : ''\n\treturn comp.replace(r, (_, M, m, p, pr) =>\n\t{\n\n\t\tlet ret: string\n\n\t\t/**\n\t\t * 萬用段落由粗到細判定;includePrerelease 時下界補 `-0`,\n\t\t * 讓 `1.0.0-0` 這類最低預發布版本也被納入。\n\t\t * Wildcards are checked coarse → fine; with includePrerelease the lower\n\t\t * bound gains `-0` so the lowest pre-release (e.g. `1.0.0-0`) is\n\t\t * included.\n\t\t */\n\t\tif (isX(M))\n\t\t{\n\t\t\tret = ''\n\t\t}\n\t\telse if (isX(m))\n\t\t{\n\t\t\tret = `>=${M}.0.0${z} <${+M + 1}.0.0-0`\n\t\t}\n\t\telse if (isX(p))\n\t\t{\n\t\t\t/**\n\t\t\t * major 為 0 時上界只能進位到 minor(避免跨過不相容的 patch),\n\t\t\t * 否則可一路放行到下一個 major。\n\t\t\t * When major is 0 the upper bound may only roll over the minor\n\t\t\t * (to avoid crossing an incompatible patch); otherwise the next\n\t\t\t * major is allowed.\n\t\t\t */\n\t\t\tif (M === '0')\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.0${z} <${M}.${+m + 1}.0-0`\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.0${z} <${+M + 1}.0.0-0`\n\t\t\t}\n\t\t}\n\t\telse if (pr)\n\t\t{\n\n\t\t\t/**\n\t\t\t * 有預發布標籤時沿用原 patch 作為下界,並依 major/minor 是否為 0\n\t\t\t * 決定上界進位的位置(0.0.x → patch、0.x → minor、其餘 → major)。\n\t\t\t * With a pre-release tag the original patch stays as the lower\n\t\t\t * bound, while the upper bound rolls over patch/minor/major\n\t\t\t * depending on whether major/minor is 0.\n\t\t\t */\n\t\t\tif (M === '0')\n\t\t\t{\n\t\t\t\tif (m === '0')\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t\t\t} <${M}.${m}.${+p + 1}-0`\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.${p}-${pr\n\t\t\t\t} <${+M + 1}.0.0-0`\n\t\t\t}\n\t\t}\n\t\telse\n\t\t{\n\n\t\t\t/**\n\t\t\t * 無預發布標籤時的分支結構與上一段相同,\n\t\t\t * 差別在於下界不帶 `-pr`,且 z 只在 includePrerelease 時加入。\n\t\t\t * Same shape as the previous block, except the lower bound carries\n\t\t\t * no `-pr` and `z` only appears under includePrerelease.\n\t\t\t */\n\t\t\tif (M === '0')\n\t\t\t{\n\t\t\t\tif (m === '0')\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p\n\t\t\t\t\t}${z} <${M}.${m}.${+p + 1}-0`\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tret = `>=${M}.${m}.${p\n\t\t\t\t\t}${z} <${M}.${+m + 1}.0-0`\n\t\t\t\t}\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\tret = `>=${M}.${m}.${p\n\t\t\t\t} <${+M + 1}.0.0-0`\n\t\t\t}\n\t\t}\n\n\t\treturn ret\n\t})\n}\n\n/**\n * 展開 xrange(如 `>=1.2.x`、`1.x`)語法\n * Expand xrange syntax (e.g. `>=1.2.x`, `1.x`)\n *\n * 以空白切割逐段轉換再接回,與 replaceTildes / replaceCarets 一致。\n * Splitting on whitespace, converting piecewise, then rejoining — same\n * strategy as replaceTildes / replaceCarets.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項 / Parse options\n * @returns 展開後的比較器字串 / Expanded comparator string\n */\nexport function replaceXRanges(comp: string, options: IOptions)\n{\n\n\treturn comp.split(/\\s+/).map((comp) =>\n\t{\n\t\treturn replaceXRange(comp, options)\n\t}).join(' ')\n}\n\n/**\n * 展開單一 xrange 比較器\n * Expand a single xrange comparator\n *\n * 萬用段落會連鎖展開(xM ⇒ xm ⇒ xp),讓「哪一段是萬用」只需要判斷一次;\n * 運算子 `>` / `<=` 遇到萬用段落時必須改寫成等價的 `>=` / `<`,\n * 因為萬用本身沒有明確邊界,直接輸出會得到不可比較的結果。\n * Wildcards cascade (xM ⇒ xm ⇒ xp) so \"which segment is a wildcard\" is decided\n * once; operators `>` / `<=` must be rewritten into the equivalent `>=` / `<`\n * because a wildcard has no exact boundary and would otherwise produce a\n * non-comparable result.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項 / Parse options\n * @returns 展開後的比較器字串 / Expanded comparator string\n */\nexport function replaceXRange(comp: string, options: IOptions)\n{\n\tcomp = comp.trim()\n\tconst r = options.loose ? re[t.XRANGELOOSE] : re[t.XRANGE]\n\treturn comp.replace(r, (ret, gtlt, M, m, p, pr) =>\n\t{\n\n\t\tconst xM = isX(M)\n\t\tconst xm = xM || isX(m)\n\t\tconst xp = xm || isX(p)\n\t\tconst anyX = xp\n\n\t\t/**\n\t\t * `=1.x` 等同於 `1.x`,先去掉運算子避免後續產生 `>=1.x` 這種殘缺輸出\n\t\t * `=1.x` means the same as `1.x`; drop the operator so the output never\n\t\t * degenerates into a broken `>=1.x`\n\t\t */\n\t\tif (gtlt === '=' && anyX)\n\t\t{\n\t\t\tgtlt = ''\n\t\t}\n\n\t\t// if we're including prereleases in the match, then we need\n\t\t// to fix this to -0, the lowest possible prerelease value\n\t\tpr = options.includePrerelease ? '-0' : ''\n\n\t\t/**\n\t\t * major 本身就是萬用:`>x` / `<x` 沒有任何可比較的版本\n\t\t * (回傳 <0.0.0-0),其餘情況代表「任意版本」(回傳 *)。\n\t\t * major itself is a wildcard: `>x` / `<x` can never match\n\t\t * (<0.0.0-0), anything else means \"any version\" (`*`).\n\t\t */\n\t\tif (xM)\n\t\t{\n\t\t\tif (gtlt === '>' || gtlt === '<')\n\t\t\t{\n\t\t\t\t// nothing is allowed\n\t\t\t\tret = EnumSemverVersion.NULL\n\t\t\t}\n\t\t\telse\n\t\t\t{\n\t\t\t\t// nothing is forbidden\n\t\t\t\tret = EnumSemverVersion.STAR\n\t\t\t}\n\t\t}\n\t\telse if (gtlt && anyX)\n\t\t{\n\t\t\t// we know patch is an x, because we have any x at all.\n\t\t\t// replace X with 0\n\t\t\tif (xm)\n\t\t\t{\n\t\t\t\tm = 0\n\t\t\t}\n\t\t\tp = 0\n\n\t\t\t/**\n\t\t\t * `>` 遇到萬用段落要進位成 `>=` 下一個值:\n\t\t\t * `>1` → `>=2.0.0`、`>1.2` → `>=1.3.0`,\n\t\t\t * 否則會把被萬用涵蓋的版本誤判為符合。\n\t\t\t * `>` over a wildcard must round up to `>=` of the next value\n\t\t\t * (`>1` → `>=2.0.0`, `>1.2` → `>=1.3.0`), otherwise versions the\n\t\t\t * wildcard covers would be wrongly accepted.\n\t\t\t */\n\t\t\tif (gtlt === '>')\n\t\t\t{\n\t\t\t\t// >1 => >=2.0.0\n\t\t\t\t// >1.2 => >=1.3.0\n\t\t\t\tgtlt = '>='\n\t\t\t\tif (xm)\n\t\t\t\t{\n\t\t\t\t\tM = +M + 1\n\t\t\t\t\tm = 0\n\t\t\t\t\tp = 0\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tm = +m + 1\n\t\t\t\t\tp = 0\n\t\t\t\t}\n\t\t\t}\n\t\t\telse if (gtlt === '<=')\n\t\t\t{\n\t\t\t\t// <=0.7.x is actually <0.8.0, since any 0.7.x should\n\t\t\t\t// pass. Similarly, <=7.x is actually <8.0.0, etc.\n\t\t\t\tgtlt = '<'\n\t\t\t\tif (xm)\n\t\t\t\t{\n\t\t\t\t\tM = +M + 1\n\t\t\t\t}\n\t\t\t\telse\n\t\t\t\t{\n\t\t\t\t\tm = +m + 1\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t/**\n\t\t\t * 上界一律補 `-0`:沒有預發布的上界會把 `x.0.0-0` 之外的\n\t\t\t * 預發布版本也包含進來,與 semver 的預設行為不符。\n\t\t\t * Upper bounds always gain `-0`; without it, pre-releases below\n\t\t\t * the boundary would be included, which contradicts semver's\n\t\t\t * default behavior.\n\t\t\t */\n\t\t\tif (gtlt === '<')\n\t\t\t{\n\t\t\t\tpr = '-0'\n\t\t\t}\n\n\t\t\tret = `${gtlt + M}.${m}.${p}${pr}`\n\t\t}\n\t\telse if (xm)\n\t\t{\n\t\t\tret = `>=${M}.0.0${pr} <${+M + 1}.0.0-0`\n\t\t}\n\t\telse if (xp)\n\t\t{\n\t\t\tret = `>=${M}.${m}.0${pr\n\t\t\t} <${M}.${+m + 1}.0-0`\n\t\t}\n\n\t\treturn ret\n\t})\n}\n\n/**\n * 移除星號萬用字元\n * Strip star wildcards\n *\n * and '' means \"any version\", just remove the *s entirely.\n *\n * @param comp - 比較器字串 / Comparator string\n * @param options - 解析選項(此處刻意忽略)/ Parse options (deliberately ignored here)\n * @returns 移除萬用字元後的字串 / String without wildcards\n */\nexport function replaceStars(comp: string, options: IOptions)\n{\n\t// Looseness is ignored here. star is always as loose as it gets!\n\treturn comp.trim().replace(re[t.STAR], '')\n}\n"]}
@@ -1,4 +1,21 @@
1
1
  import SemVer from 'semver/classes/semver';
2
2
  import { Options } from 'semver';
3
+ /**
4
+ * 檢查版本是否符合範圍
5
+ * Check whether a version satisfies a range
6
+ *
7
+ * 先把 `&` 轉成空白(「且」語意)再交給原生 semver,因此 `>=1.0.0 & <2.0.0`
8
+ * 與 `>=1.0.0 <2.0.0` 等價;此處未轉傳選項給 handleAmpersandAndSpaces,
9
+ * 所以 `noAmpersand` 不生效,只有 loose / includePrerelease 會送到 semver。
10
+ * `&` is converted to a space ("AND") before delegating to native semver, so
11
+ * `>=1.0.0 & <2.0.0` equals `>=1.0.0 <2.0.0`; options are not forwarded to
12
+ * handleAmpersandAndSpaces, so `noAmpersand` is ignored here while loose /
13
+ * includePrerelease still reach semver.
14
+ *
15
+ * @param version - 要檢查的版本 / Version to check
16
+ * @param range - 範圍字串(支援 `&`)/ Range string (`&` supported)
17
+ * @param optionsOrLoose - 選項或寬鬆旗標 / Options or loose flag
18
+ * @returns 是否符合 / Whether it satisfies the range
19
+ */
3
20
  export declare function satisfies(version: string | SemVer, range: string | Range, optionsOrLoose?: boolean | Options): boolean;
4
21
  export default satisfies;