MCPcopy
hub / github.com/originjs/vite-plugin-federation / parseHyphen

Function parseHyphen

packages/lib/src/utils/semver/parser.ts:29–71  ·  view source on GitHub ↗
(range: string)

Source from the content-addressed store, hash-verified

27} from './constants'
28
29export function parseHyphen(range: string): string {
30 return range.replace(
31 parseRegex(hyphenRange),
32 (
33 _range,
34 from,
35 fromMajor,
36 fromMinor,
37 fromPatch,
38 _fromPreRelease,
39 _fromBuild,
40 to,
41 toMajor,
42 toMinor,
43 toPatch,
44 toPreRelease
45 ) => {
46 if (isXVersion(fromMajor)) {
47 from = ''
48 } else if (isXVersion(fromMinor)) {
49 from = `>=${fromMajor}.0.0`
50 } else if (isXVersion(fromPatch)) {
51 from = `>=${fromMajor}.${fromMinor}.0`
52 } else {
53 from = `>=${from}`
54 }
55
56 if (isXVersion(toMajor)) {
57 to = ''
58 } else if (isXVersion(toMinor)) {
59 to = `<${+toMajor + 1}.0.0-0`
60 } else if (isXVersion(toPatch)) {
61 to = `<${toMajor}.${+toMinor + 1}.0-0`
62 } else if (toPreRelease) {
63 to = `<=${toMajor}.${toMinor}.${toPatch}-${toPreRelease}`
64 } else {
65 to = `<=${to}`
66 }
67
68 return `${from} ${to}`.trim()
69 }
70 )
71}
72
73export function parseComparatorTrim(range: string): string {
74 return range.replace(parseRegex(comparatorTrim), '$1$2$3')

Callers

nothing calls this directly

Calls 2

parseRegexFunction · 0.90
isXVersionFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…