@lazy-node/semver-ampersand 3.0.11 → 3.0.12

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 +35 -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
@@ -6,6 +6,20 @@ const re_1 = require("semver/internal/re");
6
6
  const util_1 = require("./util");
7
7
  const debug_1 = tslib_1.__importDefault(require("semver/internal/debug"));
8
8
  const const_1 = require("../const");
9
+ /**
10
+ * 把範圍字串正規化成後續可直接切割的形態
11
+ * Normalize a range string into a directly splittable form
12
+ *
13
+ * 這一層只處理「寫法」差異(hyphen、多餘空白、運算子後的空格),
14
+ * 不改變語意;先完成這些正規化,後續 parseComparator 才能假設輸入一致。
15
+ * This pass only fixes *spelling* differences (hyphen ranges, stray spaces,
16
+ * spaces after operators) without changing semantics; once it is done,
17
+ * parseComparator may assume a consistent input shape.
18
+ *
19
+ * @param range - 原始範圍字串 / Raw range string
20
+ * @param options - 解析選項(loose 決定正則、includePrerelease 影響 hyphen 上界)/ Parse options (loose picks the regex; includePrerelease affects the hyphen upper bound)
21
+ * @returns 正規化後的範圍字串 / Normalized range string
22
+ */
9
23
  function normalizeRangeInput(range, options) {
10
24
  // `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`
11
25
  const hr = options.loose ? re_1.re[re_1.t.HYPHENRANGELOOSE] : re_1.re[re_1.t.HYPHENRANGE];
@@ -19,6 +33,8 @@ function normalizeRangeInput(range, options) {
19
33
  // `^ 1.2.3` => `^1.2.3`
20
34
  range = range.replace(re_1.re[re_1.t.CARETTRIM], re_1.caretTrimReplace);
21
35
  // normalize spaces
36
+ // 最後統一收斂所有空白型別,讓 splitSpace 的切割結果可預期
37
+ // Collapse every whitespace flavour last so splitSpace cuts predictably
22
38
  range = range.replace(const_1.reSpaces, ' ');
23
39
  return range;
24
40
  }
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeRangeInput.js","sourceRoot":"","sources":["normalizeRangeInput.ts"],"names":[],"mappings":";;AAMA,kDAoBC;;AAzBD,2CAAsG;AACtG,iCAAuC;AACvC,0EAA0C;AAC1C,oCAAoC;AAEpC,SAAgB,mBAAmB,CAAC,KAAa,EAAE,OAAiB;IAEnE,uCAAuC;IACvC,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAE,CAAC,MAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,OAAE,CAAC,MAAC,CAAC,WAAW,CAAC,CAAA;IACrE,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,IAAA,oBAAa,EAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACnE,IAAA,eAAK,EAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC9B,uCAAuC;IACvC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,cAAc,CAAC,EAAE,0BAAqB,CAAC,CAAA;IAClE,IAAA,eAAK,EAAC,iBAAiB,EAAE,KAAK,EAAE,OAAE,CAAC,MAAC,CAAC,cAAc,CAAC,CAAC,CAAA;IAErD,wBAAwB;IACxB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,SAAS,CAAC,EAAE,qBAAgB,CAAC,CAAA;IAExD,wBAAwB;IACxB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,SAAS,CAAC,EAAE,qBAAgB,CAAC,CAAA;IAExD,mBAAmB;IACnB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAQ,EAAE,GAAG,CAAC,CAAA;IAEpC,OAAO,KAAK,CAAA;AACb,CAAC","sourcesContent":["import { IOptions } from '../types';\nimport { caretTrimReplace, comparatorTrimReplace, re, t, tildeTrimReplace } from 'semver/internal/re';\nimport { hyphenReplace } from './util';\nimport debug from 'semver/internal/debug';\nimport { reSpaces } from '../const';\n\nexport function normalizeRangeInput(range: string, options: IOptions)\n{\n\t// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`\n\tconst hr = options.loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]\n\trange = range.replace(hr, hyphenReplace(options.includePrerelease))\n\tdebug('hyphen replace', range)\n\t// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`\n\trange = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)\n\tdebug('comparator trim', range, re[t.COMPARATORTRIM])\n\n\t// `~ 1.2.3` => `~1.2.3`\n\trange = range.replace(re[t.TILDETRIM], tildeTrimReplace)\n\n\t// `^ 1.2.3` => `^1.2.3`\n\trange = range.replace(re[t.CARETTRIM], caretTrimReplace)\n\n\t// normalize spaces\n\trange = range.replace(reSpaces, ' ')\n\n\treturn range\n}\n"]}
1
+ {"version":3,"file":"normalizeRangeInput.js","sourceRoot":"","sources":["normalizeRangeInput.ts"],"names":[],"mappings":";;AAoBA,kDAsBC;;AAzCD,2CAAsG;AACtG,iCAAuC;AACvC,0EAA0C;AAC1C,oCAAoC;AAEpC;;;;;;;;;;;;;GAaG;AACH,SAAgB,mBAAmB,CAAC,KAAa,EAAE,OAAiB;IAEnE,uCAAuC;IACvC,MAAM,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAE,CAAC,MAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,OAAE,CAAC,MAAC,CAAC,WAAW,CAAC,CAAA;IACrE,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,IAAA,oBAAa,EAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAA;IACnE,IAAA,eAAK,EAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAC9B,uCAAuC;IACvC,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,cAAc,CAAC,EAAE,0BAAqB,CAAC,CAAA;IAClE,IAAA,eAAK,EAAC,iBAAiB,EAAE,KAAK,EAAE,OAAE,CAAC,MAAC,CAAC,cAAc,CAAC,CAAC,CAAA;IAErD,wBAAwB;IACxB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,SAAS,CAAC,EAAE,qBAAgB,CAAC,CAAA;IAExD,wBAAwB;IACxB,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,OAAE,CAAC,MAAC,CAAC,SAAS,CAAC,EAAE,qBAAgB,CAAC,CAAA;IAExD,mBAAmB;IACnB,qCAAqC;IACrC,wEAAwE;IACxE,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,gBAAQ,EAAE,GAAG,CAAC,CAAA;IAEpC,OAAO,KAAK,CAAA;AACb,CAAC","sourcesContent":["import { IOptions } from '../types';\nimport { caretTrimReplace, comparatorTrimReplace, re, t, tildeTrimReplace } from 'semver/internal/re';\nimport { hyphenReplace } from './util';\nimport debug from 'semver/internal/debug';\nimport { reSpaces } from '../const';\n\n/**\n * 把範圍字串正規化成後續可直接切割的形態\n * Normalize a range string into a directly splittable form\n *\n * 這一層只處理「寫法」差異(hyphen、多餘空白、運算子後的空格),\n * 不改變語意;先完成這些正規化,後續 parseComparator 才能假設輸入一致。\n * This pass only fixes *spelling* differences (hyphen ranges, stray spaces,\n * spaces after operators) without changing semantics; once it is done,\n * parseComparator may assume a consistent input shape.\n *\n * @param range - 原始範圍字串 / Raw range string\n * @param options - 解析選項(loose 決定正則、includePrerelease 影響 hyphen 上界)/ Parse options (loose picks the regex; includePrerelease affects the hyphen upper bound)\n * @returns 正規化後的範圍字串 / Normalized range string\n */\nexport function normalizeRangeInput(range: string, options: IOptions)\n{\n\t// `1.2.3 - 1.2.4` => `>=1.2.3 <=1.2.4`\n\tconst hr = options.loose ? re[t.HYPHENRANGELOOSE] : re[t.HYPHENRANGE]\n\trange = range.replace(hr, hyphenReplace(options.includePrerelease))\n\tdebug('hyphen replace', range)\n\t// `> 1.2.3 < 1.2.5` => `>1.2.3 <1.2.5`\n\trange = range.replace(re[t.COMPARATORTRIM], comparatorTrimReplace)\n\tdebug('comparator trim', range, re[t.COMPARATORTRIM])\n\n\t// `~ 1.2.3` => `~1.2.3`\n\trange = range.replace(re[t.TILDETRIM], tildeTrimReplace)\n\n\t// `^ 1.2.3` => `^1.2.3`\n\trange = range.replace(re[t.CARETTRIM], caretTrimReplace)\n\n\t// normalize spaces\n\t// 最後統一收斂所有空白型別,讓 splitSpace 的切割結果可預期\n\t// Collapse every whitespace flavour last so splitSpace cuts predictably\n\trange = range.replace(reSpaces, ' ')\n\n\treturn range\n}\n"]}
@@ -1,4 +1,42 @@
1
1
  import { IOptions } from '../types';
2
+ /**
3
+ * 比較兩組選項是否等價
4
+ * Check whether two option sets are equivalent
5
+ *
6
+ * 只比較 loose 與 includePrerelease 兩個「會影響解析結果」的欄位;
7
+ * 其餘欄位(如 noAmpersand)不參與,因為它們只影響前置字串處理。
8
+ * Only compares `loose` and `includePrerelease`, the fields that actually
9
+ * change parsing output; other fields (e.g. noAmpersand) are excluded because
10
+ * they only affect the earlier string-level handling.
11
+ *
12
+ * @param oldOptions - 原選項 / Original options
13
+ * @param newOptions - 新選項 / New options
14
+ * @returns 是否等價 / Whether they are equivalent
15
+ */
2
16
  export declare function _isSameOptions(oldOptions: IOptions, newOptions: IOptions): boolean;
17
+ /**
18
+ * 把選項複製到目標物件
19
+ * Copy options into the target object
20
+ *
21
+ * 以 `!!` 強制布林,確保複製後的欄位一定是真正的 boolean。
22
+ * Coerced with `!!` so the copied fields are always real booleans.
23
+ *
24
+ * @param oldOptions - 目標選項(被就地修改)/ Target options (mutated in place)
25
+ * @param newOptions - 來源選項 / Source options
26
+ * @returns 同一個目標選項 / The same target options
27
+ */
3
28
  export declare function _copyOptions(oldOptions: IOptions, newOptions: IOptions): IOptions;
29
+ /**
30
+ * 正規化選項中的布林欄位
31
+ * Normalize the boolean fields of the options
32
+ *
33
+ * 第三個參數傳 true(mode),連同未定義的欄位也一併補成 false,
34
+ * 讓 Range 實例上的 loose / includePrerelease 一定是布林值。
35
+ * The third argument (`mode`) is true so even undefined fields are materialized
36
+ * as false, guaranteeing `loose` / `includePrerelease` on a Range instance are
37
+ * always boolean.
38
+ *
39
+ * @param options - 選項物件(會被原地修改)/ Options object (mutated in place)
40
+ * @returns 正規化後的選項 / Normalized options
41
+ */
4
42
  export declare function _normalizeOptions(options: IOptions): IOptions;
@@ -4,15 +4,53 @@ exports._isSameOptions = _isSameOptions;
4
4
  exports._copyOptions = _copyOptions;
5
5
  exports._normalizeOptions = _normalizeOptions;
6
6
  const fixBooleanProperty_1 = require("../util/fixBooleanProperty");
7
+ /**
8
+ * 比較兩組選項是否等價
9
+ * Check whether two option sets are equivalent
10
+ *
11
+ * 只比較 loose 與 includePrerelease 兩個「會影響解析結果」的欄位;
12
+ * 其餘欄位(如 noAmpersand)不參與,因為它們只影響前置字串處理。
13
+ * Only compares `loose` and `includePrerelease`, the fields that actually
14
+ * change parsing output; other fields (e.g. noAmpersand) are excluded because
15
+ * they only affect the earlier string-level handling.
16
+ *
17
+ * @param oldOptions - 原選項 / Original options
18
+ * @param newOptions - 新選項 / New options
19
+ * @returns 是否等價 / Whether they are equivalent
20
+ */
7
21
  function _isSameOptions(oldOptions, newOptions) {
8
22
  return oldOptions.loose === newOptions.loose &&
9
23
  oldOptions.includePrerelease === newOptions.includePrerelease;
10
24
  }
25
+ /**
26
+ * 把選項複製到目標物件
27
+ * Copy options into the target object
28
+ *
29
+ * 以 `!!` 強制布林,確保複製後的欄位一定是真正的 boolean。
30
+ * Coerced with `!!` so the copied fields are always real booleans.
31
+ *
32
+ * @param oldOptions - 目標選項(被就地修改)/ Target options (mutated in place)
33
+ * @param newOptions - 來源選項 / Source options
34
+ * @returns 同一個目標選項 / The same target options
35
+ */
11
36
  function _copyOptions(oldOptions, newOptions) {
12
37
  oldOptions.loose = !!newOptions.loose;
13
38
  oldOptions.includePrerelease = !!newOptions.includePrerelease;
14
39
  return oldOptions;
15
40
  }
41
+ /**
42
+ * 正規化選項中的布林欄位
43
+ * Normalize the boolean fields of the options
44
+ *
45
+ * 第三個參數傳 true(mode),連同未定義的欄位也一併補成 false,
46
+ * 讓 Range 實例上的 loose / includePrerelease 一定是布林值。
47
+ * The third argument (`mode`) is true so even undefined fields are materialized
48
+ * as false, guaranteeing `loose` / `includePrerelease` on a Range instance are
49
+ * always boolean.
50
+ *
51
+ * @param options - 選項物件(會被原地修改)/ Options object (mutated in place)
52
+ * @returns 正規化後的選項 / Normalized options
53
+ */
16
54
  function _normalizeOptions(options) {
17
55
  options = (0, fixBooleanProperty_1.fixBooleanProperty)(options, [
18
56
  'loose',
@@ -1 +1 @@
1
- {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;AAIA,wCAIC;AAED,oCAMC;AAED,8CAQC;AAxBD,mEAAsE;AAEtE,SAAgB,cAAc,CAAC,UAAoB,EAAE,UAAoB;IAExE,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU,CAAC,KAAK;QAC3C,UAAU,CAAC,iBAAiB,KAAK,UAAU,CAAC,iBAAiB,CAAA;AAC/D,CAAC;AAED,SAAgB,YAAY,CAAC,UAAoB,EAAE,UAAoB;IAEtE,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAAA;IACrC,UAAU,CAAC,iBAAiB,GAAG,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAA;IAE7D,OAAO,UAAU,CAAA;AAClB,CAAC;AAED,SAAgB,iBAAiB,CAAC,OAAiB;IAElD,OAAO,GAAG,IAAA,uCAAkB,EAAC,OAAO,EAAE;QACrC,OAAO;QACP,mBAAmB;KACnB,EAAE,IAAI,CAAC,CAAA;IAER,OAAO,OAAO,CAAA;AACf,CAAC","sourcesContent":["import semverRange from 'semver/classes/range';\nimport { IOptions } from '../types';\nimport { fixBooleanProperty, opts } from '../util/fixBooleanProperty';\n\nexport function _isSameOptions(oldOptions: IOptions, newOptions: IOptions)\n{\n\treturn oldOptions.loose === newOptions.loose &&\n\t\toldOptions.includePrerelease === newOptions.includePrerelease\n}\n\nexport function _copyOptions(oldOptions: IOptions, newOptions: IOptions)\n{\n\toldOptions.loose = !!newOptions.loose\n\toldOptions.includePrerelease = !!newOptions.includePrerelease\n\n\treturn oldOptions\n}\n\nexport function _normalizeOptions(options: IOptions)\n{\n\toptions = fixBooleanProperty(options, [\n\t\t'loose',\n\t\t'includePrerelease',\n\t], true)\n\n\treturn options\n}\n"]}
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["options.ts"],"names":[],"mappings":";;AAkBA,wCAIC;AAaD,oCAMC;AAeD,8CAQC;AA9DD,mEAAsE;AAEtE;;;;;;;;;;;;;GAaG;AACH,SAAgB,cAAc,CAAC,UAAoB,EAAE,UAAoB;IAExE,OAAO,UAAU,CAAC,KAAK,KAAK,UAAU,CAAC,KAAK;QAC3C,UAAU,CAAC,iBAAiB,KAAK,UAAU,CAAC,iBAAiB,CAAA;AAC/D,CAAC;AAED;;;;;;;;;;GAUG;AACH,SAAgB,YAAY,CAAC,UAAoB,EAAE,UAAoB;IAEtE,UAAU,CAAC,KAAK,GAAG,CAAC,CAAC,UAAU,CAAC,KAAK,CAAA;IACrC,UAAU,CAAC,iBAAiB,GAAG,CAAC,CAAC,UAAU,CAAC,iBAAiB,CAAA;IAE7D,OAAO,UAAU,CAAA;AAClB,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,SAAgB,iBAAiB,CAAC,OAAiB;IAElD,OAAO,GAAG,IAAA,uCAAkB,EAAC,OAAO,EAAE;QACrC,OAAO;QACP,mBAAmB;KACnB,EAAE,IAAI,CAAC,CAAA;IAER,OAAO,OAAO,CAAA;AACf,CAAC","sourcesContent":["import semverRange from 'semver/classes/range';\nimport { IOptions } from '../types';\nimport { fixBooleanProperty, opts } from '../util/fixBooleanProperty';\n\n/**\n * 比較兩組選項是否等價\n * Check whether two option sets are equivalent\n *\n * 只比較 loose 與 includePrerelease 兩個「會影響解析結果」的欄位;\n * 其餘欄位(如 noAmpersand)不參與,因為它們只影響前置字串處理。\n * Only compares `loose` and `includePrerelease`, the fields that actually\n * change parsing output; other fields (e.g. noAmpersand) are excluded because\n * they only affect the earlier string-level handling.\n *\n * @param oldOptions - 原選項 / Original options\n * @param newOptions - 新選項 / New options\n * @returns 是否等價 / Whether they are equivalent\n */\nexport function _isSameOptions(oldOptions: IOptions, newOptions: IOptions)\n{\n\treturn oldOptions.loose === newOptions.loose &&\n\t\toldOptions.includePrerelease === newOptions.includePrerelease\n}\n\n/**\n * 把選項複製到目標物件\n * Copy options into the target object\n *\n * 以 `!!` 強制布林,確保複製後的欄位一定是真正的 boolean。\n * Coerced with `!!` so the copied fields are always real booleans.\n *\n * @param oldOptions - 目標選項(被就地修改)/ Target options (mutated in place)\n * @param newOptions - 來源選項 / Source options\n * @returns 同一個目標選項 / The same target options\n */\nexport function _copyOptions(oldOptions: IOptions, newOptions: IOptions)\n{\n\toldOptions.loose = !!newOptions.loose\n\toldOptions.includePrerelease = !!newOptions.includePrerelease\n\n\treturn oldOptions\n}\n\n/**\n * 正規化選項中的布林欄位\n * Normalize the boolean fields of the options\n *\n * 第三個參數傳 true(mode),連同未定義的欄位也一併補成 false,\n * 讓 Range 實例上的 loose / includePrerelease 一定是布林值。\n * The third argument (`mode`) is true so even undefined fields are materialized\n * as false, guaranteeing `loose` / `includePrerelease` on a Range instance are\n * always boolean.\n *\n * @param options - 選項物件(會被原地修改)/ Options object (mutated in place)\n * @returns 正規化後的選項 / Normalized options\n */\nexport function _normalizeOptions(options: IOptions)\n{\n\toptions = fixBooleanProperty(options, [\n\t\t'loose',\n\t\t'includePrerelease',\n\t], true)\n\n\treturn options\n}\n"]}
@@ -1,20 +1,87 @@
1
1
  import { Comparator } from 'semver';
2
2
  import { IOptions } from '../types';
3
3
  /**
4
+ * 產生快取鍵所需的選項摘要
5
+ * Build the option summary used as part of the cache key
6
+ *
4
7
  * memoize range parsing for performance.
5
8
  * this is a very hot path, and fully deterministic.
9
+ *
10
+ * 只串接「有值」的選項(filter 已過濾掉 falsy),
11
+ * 讓不同選項組合產生不同鍵、相同組合則共用快取。
12
+ * Only truthy options are joined (the filter drops falsy ones), so distinct
13
+ * option combinations get distinct keys while identical ones share the cache.
14
+ *
15
+ * @param options - 解析選項 / Parse options
16
+ * @returns 快取鍵用的選項摘要 / Option summary for the cache key
6
17
  */
7
18
  export declare function getMemoOpts(options: IOptions): string;
19
+ /**
20
+ * 把範圍展開成可逐段解析的比較器前驅字串
21
+ * Expand a range into comparator-ready strings before parsing
22
+ *
23
+ * 兩段式展開是必要的:第一段把 caret/tilde/xrange 等語法攤平,
24
+ * 攤平後可能產生重複或 `>=0.0.0` 這類等價寫法,第二段才負責去重與化簡。
25
+ * The two-pass expansion is required: the first pass flattens caret/tilde/
26
+ * xrange syntax, which may yield duplicates or equivalent spellings such as
27
+ * `>=0.0.0`; the second pass then deduplicates and simplifies.
28
+ *
29
+ * @param range - 已正規化的範圍字串 / Normalized range string
30
+ * @param options - 解析選項 / Parse options
31
+ * @returns 化簡後的比較器字串陣列 / Deduplicated comparator strings
32
+ */
8
33
  export declare function normalizeRangeInputForComparator(range: string, options: IOptions): string[];
34
+ /**
35
+ * 解析範圍的核心流程(不含快取)
36
+ * Core range-parsing flow (without caching)
37
+ *
38
+ * @param range - 範圍字串 / Range string
39
+ * @param options - 解析選項 / Parse options
40
+ * @returns 不可變的比較器陣列 / Read-only array of comparators
41
+ */
9
42
  export declare function parseRangeCore(range: string, options: IOptions): ReadonlyArray<Comparator>;
10
43
  /**
44
+ * 過濾掉不符合比較器格式的項目
45
+ * Drop entries that do not match comparator syntax
46
+ *
11
47
  * in loose mode, throw out any that are not valid comparators
48
+ *
49
+ * @param rangeList - 比較器字串陣列 / Comparator strings
50
+ * @param options - 解析選項 / Parse options
51
+ * @returns 合法的比較器字串陣列 / Valid comparator strings
12
52
  */
13
53
  export declare function filterRangeListForComparator(rangeList: string[], options: IOptions): string[];
14
54
  /**
55
+ * 合併並化簡比較器清單
56
+ * Merge and simplify a comparator list
57
+ *
15
58
  * if any comparators are the null set, then replace with JUST null set
16
59
  * if more than one comparator, remove any * comparators
17
60
  * also, don't include the same comparator more than once
61
+ *
62
+ * 任意版本比較器 `*`(值為空字串)與其他比較器並存時會被移除,
63
+ * 因為 `* & >=1.0.0` 中的 `*` 不提供任何額外限制。
64
+ * When the "any" comparator `*` (empty-string value) coexists with others it
65
+ * is removed, since `*` in `* & >=1.0.0` adds no restriction.
66
+ *
67
+ * @param compList - 比較器陣列 / Comparator array
68
+ * @returns 化簡後的比較器陣列 / Simplified comparator array
18
69
  */
19
70
  export declare function reduceComparatorList(compList: Comparator[]): Comparator[];
71
+ /**
72
+ * 解析範圍字串(含快取)
73
+ * Parse a range string (with caching)
74
+ *
75
+ * memoize range parsing for performance.
76
+ * this is a very hot path, and fully deterministic.
77
+ *
78
+ * 快取鍵包含選項摘要,因為同一段範圍在 loose / includePrerelease
79
+ * 不同設定下會解析出不同的比較器。
80
+ * The cache key includes the option summary: the same range parses into
81
+ * different comparators under loose / includePrerelease settings.
82
+ *
83
+ * @param range - 範圍字串 / Range string
84
+ * @param options - 解析選項 / Parse options
85
+ * @returns 不可變的比較器陣列 / Read-only array of comparators
86
+ */
20
87
  export declare function parseRange(range: string, options: IOptions): ReadonlyArray<Comparator>;
@@ -15,12 +15,37 @@ const split_1 = require("../util/split");
15
15
  const array_hyper_unique_1 = require("array-hyper-unique");
16
16
  const normalizeRangeInput_1 = require("./normalizeRangeInput");
17
17
  /**
18
+ * 產生快取鍵所需的選項摘要
19
+ * Build the option summary used as part of the cache key
20
+ *
18
21
  * memoize range parsing for performance.
19
22
  * this is a very hot path, and fully deterministic.
23
+ *
24
+ * 只串接「有值」的選項(filter 已過濾掉 falsy),
25
+ * 讓不同選項組合產生不同鍵、相同組合則共用快取。
26
+ * Only truthy options are joined (the filter drops falsy ones), so distinct
27
+ * option combinations get distinct keys while identical ones share the cache.
28
+ *
29
+ * @param options - 解析選項 / Parse options
30
+ * @returns 快取鍵用的選項摘要 / Option summary for the cache key
20
31
  */
21
32
  function getMemoOpts(options) {
22
33
  return Object.keys(options).filter(k => options[k]).join(',');
23
34
  }
35
+ /**
36
+ * 把範圍展開成可逐段解析的比較器前驅字串
37
+ * Expand a range into comparator-ready strings before parsing
38
+ *
39
+ * 兩段式展開是必要的:第一段把 caret/tilde/xrange 等語法攤平,
40
+ * 攤平後可能產生重複或 `>=0.0.0` 這類等價寫法,第二段才負責去重與化簡。
41
+ * The two-pass expansion is required: the first pass flattens caret/tilde/
42
+ * xrange syntax, which may yield duplicates or equivalent spellings such as
43
+ * `>=0.0.0`; the second pass then deduplicates and simplifies.
44
+ *
45
+ * @param range - 已正規化的範圍字串 / Normalized range string
46
+ * @param options - 解析選項 / Parse options
47
+ * @returns 化簡後的比較器字串陣列 / Deduplicated comparator strings
48
+ */
24
49
  function normalizeRangeInputForComparator(range, options) {
25
50
  let rangeList = (0, split_1.splitSpace)(range)
26
51
  .map(comp => (0, util_1.parseComparator)(comp, options));
@@ -29,11 +54,25 @@ function normalizeRangeInputForComparator(range, options) {
29
54
  .map(comp => (0, util_1.replaceGTE0)(comp, options));
30
55
  return (0, array_hyper_unique_1.array_unique_overwrite)(rangeList);
31
56
  }
57
+ /**
58
+ * 解析範圍的核心流程(不含快取)
59
+ * Core range-parsing flow (without caching)
60
+ *
61
+ * @param range - 範圍字串 / Range string
62
+ * @param options - 解析選項 / Parse options
63
+ * @returns 不可變的比較器陣列 / Read-only array of comparators
64
+ */
32
65
  function parseRangeCore(range, options) {
33
66
  range = (0, normalizeRangeInput_1.normalizeRangeInput)(range, options);
34
67
  // At this point, the range is completely trimmed and
35
68
  // ready to be split into comparators.
36
69
  let rangeList = normalizeRangeInputForComparator(range, options);
70
+ /**
71
+ * loose 模式才過濾:嚴格模式下無效比較器要讓建構失敗,
72
+ * 寬鬆模式則允許個別條件被忽略(與 semver 行為一致)。
73
+ * Filter only in loose mode: strict mode must fail on invalid comparators,
74
+ * while loose mode tolerates dropping them (same as semver).
75
+ */
37
76
  if (options.loose) {
38
77
  rangeList = filterRangeListForComparator(rangeList, options);
39
78
  }
@@ -43,32 +82,77 @@ function parseRangeCore(range, options) {
43
82
  return result;
44
83
  }
45
84
  /**
85
+ * 過濾掉不符合比較器格式的項目
86
+ * Drop entries that do not match comparator syntax
87
+ *
46
88
  * in loose mode, throw out any that are not valid comparators
89
+ *
90
+ * @param rangeList - 比較器字串陣列 / Comparator strings
91
+ * @param options - 解析選項 / Parse options
92
+ * @returns 合法的比較器字串陣列 / Valid comparator strings
47
93
  */
48
94
  function filterRangeListForComparator(rangeList, options) {
49
95
  const compRe = options.loose ? re_1.re[re_1.t.COMPARATORLOOSE] : re_1.re[re_1.t.COMPARATOR];
50
96
  return rangeList.filter(comp => !!comp.match(compRe));
51
97
  }
52
98
  /**
99
+ * 合併並化簡比較器清單
100
+ * Merge and simplify a comparator list
101
+ *
53
102
  * if any comparators are the null set, then replace with JUST null set
54
103
  * if more than one comparator, remove any * comparators
55
104
  * also, don't include the same comparator more than once
105
+ *
106
+ * 任意版本比較器 `*`(值為空字串)與其他比較器並存時會被移除,
107
+ * 因為 `* & >=1.0.0` 中的 `*` 不提供任何額外限制。
108
+ * When the "any" comparator `*` (empty-string value) coexists with others it
109
+ * is removed, since `*` in `* & >=1.0.0` adds no restriction.
110
+ *
111
+ * @param compList - 比較器陣列 / Comparator array
112
+ * @returns 化簡後的比較器陣列 / Simplified comparator array
56
113
  */
57
114
  function reduceComparatorList(compList) {
58
115
  const l = compList.length;
59
116
  const rangeMap = new Map();
60
117
  for (const comp of compList) {
118
+ /**
119
+ * Null Set(<0.0.0-0)代表「沒有任何版本符合」,
120
+ * 其餘條件再寬也無意義,直接短路回傳。
121
+ * A null set (<0.0.0-0) means "nothing matches"; no other condition
122
+ * can widen it, so short-circuit immediately.
123
+ */
61
124
  if ((0, detect_1.isNullSet)(comp)) {
62
125
  return [comp];
63
126
  }
64
127
  rangeMap.set(comp.value, comp);
65
128
  }
129
+ /**
130
+ * 只有一個以上比較器時才移除 `*`,避免把單純的 `*` 範圍清空。
131
+ * Drop `*` only when more than one comparator remains, so a plain `*`
132
+ * range is not emptied by accident.
133
+ */
66
134
  if (rangeMap.size > 1 && rangeMap.has('')) {
67
135
  rangeMap.delete('');
68
136
  }
69
137
  const result = [...rangeMap.values()];
70
138
  return result;
71
139
  }
140
+ /**
141
+ * 解析範圍字串(含快取)
142
+ * Parse a range string (with caching)
143
+ *
144
+ * memoize range parsing for performance.
145
+ * this is a very hot path, and fully deterministic.
146
+ *
147
+ * 快取鍵包含選項摘要,因為同一段範圍在 loose / includePrerelease
148
+ * 不同設定下會解析出不同的比較器。
149
+ * The cache key includes the option summary: the same range parses into
150
+ * different comparators under loose / includePrerelease settings.
151
+ *
152
+ * @param range - 範圍字串 / Range string
153
+ * @param options - 解析選項 / Parse options
154
+ * @returns 不可變的比較器陣列 / Read-only array of comparators
155
+ */
72
156
  function parseRange(range, options) {
73
157
  range = range.trim();
74
158
  // memoize range parsing for performance.
@@ -1 +1 @@
1
- {"version":3,"file":"parseRange.js","sourceRoot":"","sources":["parseRange.ts"],"names":[],"mappings":"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","sourcesContent":["import { cache } from './cache';\nimport { Comparator } from 'semver';\nimport { isNullSet } from '../comparator/detect';\nimport { IOptions } from '../types';\nimport { re, t } from 'semver/internal/re'\nimport { parseComparator, replaceGTE0 } from './util';\nimport { splitSpace } from '../util/split';\nimport { array_unique_overwrite } from 'array-hyper-unique';\nimport { normalizeRangeInput } from './normalizeRangeInput';\n\n/**\n * memoize range parsing for performance.\n * this is a very hot path, and fully deterministic.\n */\nexport function getMemoOpts(options: IOptions)\n{\n\treturn Object.keys(options).filter(k => options[k]).join(',')\n}\n\nexport function normalizeRangeInputForComparator(range: string, options: IOptions)\n{\n\tlet rangeList = splitSpace(range)\n\t\t.map(comp => parseComparator(comp, options))\n\t;\n\n\trangeList = splitSpace(rangeList.join(' '))\n\t\t// >=0.0.0 is equivalent to *\n\t\t.map(comp => replaceGTE0(comp, options))\n\n\treturn array_unique_overwrite(rangeList)\n}\n\nexport function parseRangeCore(range: string, options: IOptions): ReadonlyArray<Comparator>\n{\n\trange = normalizeRangeInput(range, options);\n\n\t// At this point, the range is completely trimmed and\n\t// ready to be split into comparators.\n\n\tlet rangeList = normalizeRangeInputForComparator(range, options)\n\n\tif (options.loose)\n\t{\n\t\trangeList = filterRangeListForComparator(rangeList, options)\n\t}\n\n\tlet compList = rangeList\n\t\t.map(comp => new Comparator(comp, options))\n\n\tconst result = reduceComparatorList(compList)\n\n\treturn result\n}\n\n/**\n * in loose mode, throw out any that are not valid comparators\n */\nexport function filterRangeListForComparator(rangeList: string[], options: IOptions)\n{\n\tconst compRe = options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n\n\treturn rangeList.filter(comp => !!comp.match(compRe))\n}\n\n/**\n * if any comparators are the null set, then replace with JUST null set\n * if more than one comparator, remove any * comparators\n * also, don't include the same comparator more than once\n */\nexport function reduceComparatorList(compList: Comparator[])\n{\n\tconst l = compList.length\n\tconst rangeMap = new Map<string, Comparator>()\n\tfor (const comp of compList)\n\t{\n\t\tif (isNullSet(comp))\n\t\t{\n\t\t\treturn [comp]\n\t\t}\n\t\trangeMap.set(comp.value, comp)\n\t}\n\tif (rangeMap.size > 1 && rangeMap.has(''))\n\t{\n\t\trangeMap.delete('')\n\t}\n\n\tconst result = [...rangeMap.values()]\n\n\treturn result\n}\n\nexport function parseRange(range: string, options: IOptions): ReadonlyArray<Comparator>\n{\n\trange = range.trim()\n\n\t// memoize range parsing for performance.\n\t// this is a very hot path, and fully deterministic.\n\tconst memoOpts = getMemoOpts(options)\n\tconst memoKey = `parseRange:${memoOpts}:${range}`\n\tconst cached = cache.get(memoKey)\n\tif (cached)\n\t{\n\t\treturn cached\n\t}\n\n\tconst result = parseRangeCore(range, options)\n\n\tcache.set(memoKey, result)\n\treturn result\n}\n"]}
1
+ {"version":3,"file":"parseRange.js","sourceRoot":"","sources":["parseRange.ts"],"names":[],"mappings":"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","sourcesContent":["import { cache } from './cache';\nimport { Comparator } from 'semver';\nimport { isNullSet } from '../comparator/detect';\nimport { IOptions } from '../types';\nimport { re, t } from 'semver/internal/re'\nimport { parseComparator, replaceGTE0 } from './util';\nimport { splitSpace } from '../util/split';\nimport { array_unique_overwrite } from 'array-hyper-unique';\nimport { normalizeRangeInput } from './normalizeRangeInput';\n\n/**\n * 產生快取鍵所需的選項摘要\n * Build the option summary used as part of the cache key\n *\n * memoize range parsing for performance.\n * this is a very hot path, and fully deterministic.\n *\n * 只串接「有值」的選項(filter 已過濾掉 falsy),\n * 讓不同選項組合產生不同鍵、相同組合則共用快取。\n * Only truthy options are joined (the filter drops falsy ones), so distinct\n * option combinations get distinct keys while identical ones share the cache.\n *\n * @param options - 解析選項 / Parse options\n * @returns 快取鍵用的選項摘要 / Option summary for the cache key\n */\nexport function getMemoOpts(options: IOptions)\n{\n\treturn Object.keys(options).filter(k => options[k]).join(',')\n}\n\n/**\n * 把範圍展開成可逐段解析的比較器前驅字串\n * Expand a range into comparator-ready strings before parsing\n *\n * 兩段式展開是必要的:第一段把 caret/tilde/xrange 等語法攤平,\n * 攤平後可能產生重複或 `>=0.0.0` 這類等價寫法,第二段才負責去重與化簡。\n * The two-pass expansion is required: the first pass flattens caret/tilde/\n * xrange syntax, which may yield duplicates or equivalent spellings such as\n * `>=0.0.0`; the second pass then deduplicates and simplifies.\n *\n * @param range - 已正規化的範圍字串 / Normalized range string\n * @param options - 解析選項 / Parse options\n * @returns 化簡後的比較器字串陣列 / Deduplicated comparator strings\n */\nexport function normalizeRangeInputForComparator(range: string, options: IOptions)\n{\n\tlet rangeList = splitSpace(range)\n\t\t.map(comp => parseComparator(comp, options))\n\t;\n\n\trangeList = splitSpace(rangeList.join(' '))\n\t\t// >=0.0.0 is equivalent to *\n\t\t.map(comp => replaceGTE0(comp, options))\n\n\treturn array_unique_overwrite(rangeList)\n}\n\n/**\n * 解析範圍的核心流程(不含快取)\n * Core range-parsing flow (without caching)\n *\n * @param range - 範圍字串 / Range string\n * @param options - 解析選項 / Parse options\n * @returns 不可變的比較器陣列 / Read-only array of comparators\n */\nexport function parseRangeCore(range: string, options: IOptions): ReadonlyArray<Comparator>\n{\n\trange = normalizeRangeInput(range, options);\n\n\t// At this point, the range is completely trimmed and\n\t// ready to be split into comparators.\n\n\tlet rangeList = normalizeRangeInputForComparator(range, options)\n\n\t/**\n\t * loose 模式才過濾:嚴格模式下無效比較器要讓建構失敗,\n\t * 寬鬆模式則允許個別條件被忽略(與 semver 行為一致)。\n\t * Filter only in loose mode: strict mode must fail on invalid comparators,\n\t * while loose mode tolerates dropping them (same as semver).\n\t */\n\tif (options.loose)\n\t{\n\t\trangeList = filterRangeListForComparator(rangeList, options)\n\t}\n\n\tlet compList = rangeList\n\t\t.map(comp => new Comparator(comp, options))\n\n\tconst result = reduceComparatorList(compList)\n\n\treturn result\n}\n\n/**\n * 過濾掉不符合比較器格式的項目\n * Drop entries that do not match comparator syntax\n *\n * in loose mode, throw out any that are not valid comparators\n *\n * @param rangeList - 比較器字串陣列 / Comparator strings\n * @param options - 解析選項 / Parse options\n * @returns 合法的比較器字串陣列 / Valid comparator strings\n */\nexport function filterRangeListForComparator(rangeList: string[], options: IOptions)\n{\n\tconst compRe = options.loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR]\n\n\treturn rangeList.filter(comp => !!comp.match(compRe))\n}\n\n/**\n * 合併並化簡比較器清單\n * Merge and simplify a comparator list\n *\n * if any comparators are the null set, then replace with JUST null set\n * if more than one comparator, remove any * comparators\n * also, don't include the same comparator more than once\n *\n * 任意版本比較器 `*`(值為空字串)與其他比較器並存時會被移除,\n * 因為 `* & >=1.0.0` 中的 `*` 不提供任何額外限制。\n * When the \"any\" comparator `*` (empty-string value) coexists with others it\n * is removed, since `*` in `* & >=1.0.0` adds no restriction.\n *\n * @param compList - 比較器陣列 / Comparator array\n * @returns 化簡後的比較器陣列 / Simplified comparator array\n */\nexport function reduceComparatorList(compList: Comparator[])\n{\n\tconst l = compList.length\n\tconst rangeMap = new Map<string, Comparator>()\n\tfor (const comp of compList)\n\t{\n\t\t/**\n\t\t * Null Set(<0.0.0-0)代表「沒有任何版本符合」,\n\t\t * 其餘條件再寬也無意義,直接短路回傳。\n\t\t * A null set (<0.0.0-0) means \"nothing matches\"; no other condition\n\t\t * can widen it, so short-circuit immediately.\n\t\t */\n\t\tif (isNullSet(comp))\n\t\t{\n\t\t\treturn [comp]\n\t\t}\n\t\trangeMap.set(comp.value, comp)\n\t}\n\t/**\n\t * 只有一個以上比較器時才移除 `*`,避免把單純的 `*` 範圍清空。\n\t * Drop `*` only when more than one comparator remains, so a plain `*`\n\t * range is not emptied by accident.\n\t */\n\tif (rangeMap.size > 1 && rangeMap.has(''))\n\t{\n\t\trangeMap.delete('')\n\t}\n\n\tconst result = [...rangeMap.values()]\n\n\treturn result\n}\n\n/**\n * 解析範圍字串(含快取)\n * Parse a range string (with caching)\n *\n * memoize range parsing for performance.\n * this is a very hot path, and fully deterministic.\n *\n * 快取鍵包含選項摘要,因為同一段範圍在 loose / includePrerelease\n * 不同設定下會解析出不同的比較器。\n * The cache key includes the option summary: the same range parses into\n * different comparators under loose / includePrerelease settings.\n *\n * @param range - 範圍字串 / Range string\n * @param options - 解析選項 / Parse options\n * @returns 不可變的比較器陣列 / Read-only array of comparators\n */\nexport function parseRange(range: string, options: IOptions): ReadonlyArray<Comparator>\n{\n\trange = range.trim()\n\n\t// memoize range parsing for performance.\n\t// this is a very hot path, and fully deterministic.\n\tconst memoOpts = getMemoOpts(options)\n\tconst memoKey = `parseRange:${memoOpts}:${range}`\n\tconst cached = cache.get(memoKey)\n\tif (cached)\n\t{\n\t\treturn cached\n\t}\n\n\tconst result = parseRangeCore(range, options)\n\n\tcache.set(memoKey, result)\n\treturn result\n}\n"]}
@@ -1,2 +1,14 @@
1
1
  import { buildRangeSet } from './buildRangeSet';
2
+ /**
3
+ * 把二維條件集合組回範圍字串
4
+ * Join a two-dimensional condition set back into a range string
5
+ *
6
+ * 與 stringifyComparatorsSet 的差別在於輸入是「字串」的二維陣列
7
+ * (buildRangeSet 的輸出),而非 Comparator 物件。
8
+ * Unlike stringifyComparatorsSet, the input here is a two-dimensional array of
9
+ * *strings* (the output of buildRangeSet) rather than Comparator objects.
10
+ *
11
+ * @param rangeSet - 二維條件字串集合 / Two-dimensional condition sets
12
+ * @returns 範圍字串 / Range string
13
+ */
2
14
  export declare function stringifyRangeSet(rangeSet: ReturnType<typeof buildRangeSet>): string;
@@ -2,6 +2,18 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.stringifyRangeSet = stringifyRangeSet;
4
4
  const const_1 = require("../const");
5
+ /**
6
+ * 把二維條件集合組回範圍字串
7
+ * Join a two-dimensional condition set back into a range string
8
+ *
9
+ * 與 stringifyComparatorsSet 的差別在於輸入是「字串」的二維陣列
10
+ * (buildRangeSet 的輸出),而非 Comparator 物件。
11
+ * Unlike stringifyComparatorsSet, the input here is a two-dimensional array of
12
+ * *strings* (the output of buildRangeSet) rather than Comparator objects.
13
+ *
14
+ * @param rangeSet - 二維條件字串集合 / Two-dimensional condition sets
15
+ * @returns 範圍字串 / Range string
16
+ */
5
17
  function stringifyRangeSet(rangeSet) {
6
18
  return rangeSet
7
19
  .map(a => a.join(' '))
@@ -1 +1 @@
1
- {"version":3,"file":"stringifyRangeSet.js","sourceRoot":"","sources":["stringifyRangeSet.ts"],"names":[],"mappings":";;AAGA,8CAKC;AAPD,oCAAsD;AAEtD,SAAgB,iBAAiB,CAAC,QAA0C;IAE3E,OAAO,QAAQ;SACb,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACrB,IAAI,CAAC,kCAA0B,CAAC,CAAA;AACnC,CAAC","sourcesContent":["import { buildRangeSet } from './buildRangeSet';\nimport { separatorDoubleVerticalBar } from '../const';\n\nexport function stringifyRangeSet(rangeSet: ReturnType<typeof buildRangeSet>)\n{\n\treturn rangeSet\n\t\t.map(a => a.join(' '))\n\t\t.join(separatorDoubleVerticalBar)\n}\n"]}
1
+ {"version":3,"file":"stringifyRangeSet.js","sourceRoot":"","sources":["stringifyRangeSet.ts"],"names":[],"mappings":";;AAeA,8CAKC;AAnBD,oCAAsD;AAEtD;;;;;;;;;;;GAWG;AACH,SAAgB,iBAAiB,CAAC,QAA0C;IAE3E,OAAO,QAAQ;SACb,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SACrB,IAAI,CAAC,kCAA0B,CAAC,CAAA;AACnC,CAAC","sourcesContent":["import { buildRangeSet } from './buildRangeSet';\nimport { separatorDoubleVerticalBar } from '../const';\n\n/**\n * 把二維條件集合組回範圍字串\n * Join a two-dimensional condition set back into a range string\n *\n * 與 stringifyComparatorsSet 的差別在於輸入是「字串」的二維陣列\n * (buildRangeSet 的輸出),而非 Comparator 物件。\n * Unlike stringifyComparatorsSet, the input here is a two-dimensional array of\n * *strings* (the output of buildRangeSet) rather than Comparator objects.\n *\n * @param rangeSet - 二維條件字串集合 / Two-dimensional condition sets\n * @returns 範圍字串 / Range string\n */\nexport function stringifyRangeSet(rangeSet: ReturnType<typeof buildRangeSet>)\n{\n\treturn rangeSet\n\t\t.map(a => a.join(' '))\n\t\t.join(separatorDoubleVerticalBar)\n}\n"]}
@@ -1 +1,13 @@
1
+ /**
2
+ * 把範圍字串轉成永遠可用於真值判斷的形式
3
+ * Turn a range string into a form that is always truthy-testable
4
+ *
5
+ * 空字串代表「任意版本」,但空字串在 JavaScript 中是 falsy,
6
+ * 回傳 `*` 可讓 `if (range.toRangeString())` 的判斷保持直覺。
7
+ * An empty string means "any version" yet is falsy in JavaScript; returning
8
+ * `*` keeps `if (range.toRangeString())` intuitive.
9
+ *
10
+ * @param range - 範圍字串 / Range string
11
+ * @returns 原字串,空字串則回傳 `*` / The original string, or `*` when empty
12
+ */
1
13
  export declare function toRangeString(range: string): string | '*';
@@ -1,6 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toRangeString = toRangeString;
4
+ /**
5
+ * 把範圍字串轉成永遠可用於真值判斷的形式
6
+ * Turn a range string into a form that is always truthy-testable
7
+ *
8
+ * 空字串代表「任意版本」,但空字串在 JavaScript 中是 falsy,
9
+ * 回傳 `*` 可讓 `if (range.toRangeString())` 的判斷保持直覺。
10
+ * An empty string means "any version" yet is falsy in JavaScript; returning
11
+ * `*` keeps `if (range.toRangeString())` intuitive.
12
+ *
13
+ * @param range - 範圍字串 / Range string
14
+ * @returns 原字串,空字串則回傳 `*` / The original string, or `*` when empty
15
+ */
4
16
  function toRangeString(range) {
5
17
  return range || '*';
6
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"toRangeString.js","sourceRoot":"","sources":["toRangeString.ts"],"names":[],"mappings":";;AACA,sCAGC;AAHD,SAAgB,aAAa,CAAC,KAAa;IAE1C,OAAO,KAAK,IAAI,GAAG,CAAA;AACpB,CAAC","sourcesContent":["\nexport function toRangeString(range: string): string | '*'\n{\n\treturn range || '*'\n}\n"]}
1
+ {"version":3,"file":"toRangeString.js","sourceRoot":"","sources":["toRangeString.ts"],"names":[],"mappings":";;AAaA,sCAGC;AAfD;;;;;;;;;;;GAWG;AACH,SAAgB,aAAa,CAAC,KAAa;IAE1C,OAAO,KAAK,IAAI,GAAG,CAAA;AACpB,CAAC","sourcesContent":["\n/**\n * 把範圍字串轉成永遠可用於真值判斷的形式\n * Turn a range string into a form that is always truthy-testable\n *\n * 空字串代表「任意版本」,但空字串在 JavaScript 中是 falsy,\n * 回傳 `*` 可讓 `if (range.toRangeString())` 的判斷保持直覺。\n * An empty string means \"any version\" yet is falsy in JavaScript; returning\n * `*` keeps `if (range.toRangeString())` intuitive.\n *\n * @param range - 範圍字串 / Range string\n * @returns 原字串,空字串則回傳 `*` / The original string, or `*` when empty\n */\nexport function toRangeString(range: string): string | '*'\n{\n\treturn range || '*'\n}\n"]}