MCPcopy Create free account
hub / github.com/ethereum/node-crawler / parseVersion

Function parseVersion

frontend/src/data/DataProcessor.ts:95–117  ·  view source on GitHub ↗
(version: string, parseOpt: ParseParam)

Source from the content-addressed store, hash-verified

93}
94
95function parseVersion(version: string, parseOpt: ParseParam): Version | undefined {
96 const matches = version.match(/v?(?<major>\d+)(?:.(?<minor>\d+).(?<patch>\d+)(?:-(?<tag>\w+)(?:-(?<build>[a-zA-Z0-9]+)(?:-(?<date>\d+))?)?)?)?/)
97
98 if (!matches?.groups) {
99 parseOpt.errorCallback('version', version, parseOpt.primaryKey);
100 return undefined
101 }
102
103 const minor = tryParseNumber(matches.groups.minor)
104 const patch = tryParseNumber(matches.groups.patch)
105 const tag = matches.groups.tag
106 const build = matches.groups.build
107 const date = matches.groups.date
108
109 return {
110 major: parseInt(matches.groups.major),
111 ...minor !== undefined && { minor },
112 ...patch !== undefined && { patch },
113 ...tag && { tag },
114 ...build && { build },
115 ...date && { date },
116 }
117}
118
119function parseOs(os: string, parseOpt: ParseParam): OperatingSytem | undefined {
120 const match = matchAll(os, /(linux|windows|darwin|x86_64|x64|amd64)/g)

Callers 2

parseRuntimeFunction · 0.70
parseRawFunction · 0.70

Calls 1

tryParseNumberFunction · 0.85

Tested by

no test coverage detected