All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.functions.parse.js Maven / Gradle / Ivy

There is a newer version: 7.6.3
Show newest version
const { MAX_LENGTH } = require('../internal/constants')
const SemVer = require('../classes/semver')
const parse = (version, options) => {
  if (version instanceof SemVer) {
    return version
  }

  if (typeof version !== 'string') {
    return null
  }

  if (version.length > MAX_LENGTH) {
    return null
  }

  try {
    return new SemVer(version, options)
  } catch (er) {
    return null
  }
}

module.exports = parse




© 2015 - 2024 Weber Informatics LLC | Privacy Policy