MCPcopy Create free account
hub / github.com/Automattic/mongoose / parseVersion

Function parseVersion

scripts/website.js:163–180  ·  view source on GitHub ↗

* Parse a given semver version string to a number array * @param {string} str The string to parse * @returns number array or undefined

(str)

Source from the content-addressed store, hash-verified

161 * @returns number array or undefined
162 */
163function parseVersion(str) {
164 const versionReg = /^v?(\d+)\.(\d+)\.(\d+)$/i;
165
166 const match = versionReg.exec(str);
167
168 if (!!match) {
169 const parsed = [parseInt(match[1]), parseInt(match[2]), parseInt(match[3])]
170
171 // fallback just in case some number did not parse
172 if (Number.isNaN(parsed[0]) || Number.isNaN(parsed[1]) || Number.isNaN(parsed[2])) {
173 console.log(`some version was matched but did not parse to int! "${str}"`);
174 return undefined;
175 }
176 return parsed;
177 }
178
179 return undefined;
180}
181
182function getVersions() {
183 // get all tags from git

Callers 1

getCurrentVersionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected