parse.js 317 B

12345678910111213141516
  1. const SemVer = require('../classes/semver')
  2. const parse = (version, options, throwErrors = false) => {
  3. if (version instanceof SemVer) {
  4. return version
  5. }
  6. try {
  7. return new SemVer(version, options)
  8. } catch (er) {
  9. if (!throwErrors) {
  10. return null
  11. }
  12. throw er
  13. }
  14. }
  15. module.exports = parse