MCPcopy Create free account
hub / github.com/denoland/std / parseOperatorRange

Function parseOperatorRange

semver/parse_range.ts:334–356  ·  view source on GitHub ↗
(string: string)

Source from the content-addressed store, hash-verified

332}
333
334function parseOperatorRange(string: string): Comparator | Comparator[] | null {
335 const groups = string.match(OPERATOR_XRANGE_REGEXP)
336 ?.groups as RangeRegExpGroups;
337 if (!groups) return parseComparator(string);
338
339 switch (groups.operator) {
340 case "^":
341 return handleCaretOperator(groups);
342 case "~":
343 case "~>":
344 return handleTildeOperator(groups);
345 case "<":
346 return handleLessThanOperator(groups);
347 case "<=":
348 return handleLessThanOrEqualOperator(groups);
349 case ">":
350 return handleGreaterThanOperator(groups);
351 case ">=":
352 return handleGreaterOrEqualOperator(groups);
353 default:
354 return handleEqualOperator(groups);
355 }
356}
357function parseOperatorRanges(string: string): (Comparator | null)[] {
358 return string.split(/\s+/).flatMap(parseOperatorRange);
359}

Callers

nothing calls this directly

Calls 9

parseComparatorFunction · 0.85
handleCaretOperatorFunction · 0.85
handleTildeOperatorFunction · 0.85
handleLessThanOperatorFunction · 0.85
handleEqualOperatorFunction · 0.85
matchMethod · 0.80

Tested by

no test coverage detected