MCPcopy Create free account
hub / github.com/Effect-TS/effect / expand

Function expand

packages/effect/src/SemVerRange.ts:522–540  ·  view source on GitHub ↗
(self: Comparator, includePrerelease: boolean)

Source from the content-addressed store, hash-verified

520}
521
522const expand = (self: Comparator, includePrerelease: boolean): ReadonlyArray<Bound> => {
523 const z = includePrerelease ? [0] : []
524 if (self._tag === "Hyphen") {
525 const { from, to } = self
526 // Unlike `>=`, a full hyphen lower bound without a pre-release also takes `z`.
527 const lower = from.components.length === 0
528 ? []
529 : [bound(">=", from.components, from.prerelease.length > 0 ? from.prerelease : z)]
530 return [...lower, ...expandXRange("<=", to, z)]
531 }
532 switch (self.operator) {
533 case "^":
534 return expandCaret(self.version, z)
535 case "~":
536 return expandTilde(self.version, z)
537 default:
538 return expandXRange(self.operator, self.version, z)
539 }
540}
541
542const testBound = (self: Bound, version: SemVer): boolean => {
543 const result = compareCore(version, self)

Callers 1

compileFunction · 0.70

Calls 4

expandXRangeFunction · 0.85
expandCaretFunction · 0.85
expandTildeFunction · 0.85
boundFunction · 0.70

Tested by

no test coverage detected