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

Function parseOrThrow

packages/effect/src/SemVer.ts:319–342  ·  view source on GitHub ↗
(input: string)

Source from the content-addressed store, hash-verified

317 )
318
319const parseOrThrow = (input: string): SemVer => {
320 let rest = input
321 let build: ReadonlyArray<string> = []
322 const plus = rest.indexOf("+")
323 if (plus !== -1) {
324 build = rest.slice(plus + 1).split(".").map(buildIdentifier)
325 rest = rest.slice(0, plus)
326 }
327 let prerelease: ReadonlyArray<string | number> = []
328 const dash = rest.indexOf("-")
329 if (dash !== -1) {
330 prerelease = rest.slice(dash + 1).split(".").map(prereleaseIdentifier)
331 rest = rest.slice(0, dash)
332 }
333 const core = rest.split(".")
334 if (core.length !== 3) return invalid("expected MAJOR.MINOR.PATCH")
335 return unchecked(
336 parseComponent(core[0], "major"),
337 parseComponent(core[1], "minor"),
338 parseComponent(core[2], "patch"),
339 prerelease,
340 build
341 )
342}
343
344/**
345 * Parses a strict Semantic Versioning 2.0.0 string.

Callers

nothing calls this directly

Calls 6

uncheckedFunction · 0.85
parseComponentFunction · 0.85
sliceMethod · 0.80
invalidFunction · 0.70
mapMethod · 0.45
splitMethod · 0.45

Tested by

no test coverage detected