17 lines
317 B
JavaScript
Raw Normal View History

2023-07-24 11:13:08 +08:00
const SemVer = require('../classes/semver')
2023-09-06 09:51:55 +08:00
const parse = (version, options, throwErrors = false) => {
2023-07-24 11:13:08 +08:00
if (version instanceof SemVer) {
return version
}
try {
return new SemVer(version, options)
} catch (er) {
2023-09-06 09:51:55 +08:00
if (!throwErrors) {
return null
}
throw er
2023-07-24 11:13:08 +08:00
}
}
module.exports = parse