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

Function select

packages/effect/src/SemVerRange.ts:632–647  ·  view source on GitHub ↗
(
  self: SemVerRange,
  versions: Iterable<VersionInput>,
  options: MatchOptions | undefined,
  better: -1 | 1
)

Source from the content-addressed store, hash-verified

630)
631
632const select = (
633 self: SemVerRange,
634 versions: Iterable<VersionInput>,
635 options: MatchOptions | undefined,
636 better: -1 | 1
637): Option.Option<SemVer> => {
638 const test = matcher(self, options)
639 let selected: SemVer | undefined
640 for (const input of versions) {
641 const version = versionFromInputUnsafe(input)
642 if (test(version) && (selected === undefined || compareCore(version, selected) === better)) {
643 selected = version
644 }
645 }
646 return Option.fromUndefinedOr(selected)
647}
648
649/**
650 * Returns the version with the highest precedence that a range matches.

Callers 1

SemVerRange.tsFile · 0.70

Calls 3

compareCoreFunction · 0.90
matcherFunction · 0.70
testFunction · 0.50

Tested by

no test coverage detected