diff options
Diffstat (limited to 'deps/npm/node_modules/semver/functions/parse.js')
-rw-r--r-- | deps/npm/node_modules/semver/functions/parse.js | 27 |
1 files changed, 5 insertions, 22 deletions
diff --git a/deps/npm/node_modules/semver/functions/parse.js b/deps/npm/node_modules/semver/functions/parse.js index a66663aa59..459b3b1737 100644 --- a/deps/npm/node_modules/semver/functions/parse.js +++ b/deps/npm/node_modules/semver/functions/parse.js @@ -1,32 +1,15 @@ -const { MAX_LENGTH } = require('../internal/constants') -const { re, t } = require('../internal/re') const SemVer = require('../classes/semver') - -const parseOptions = require('../internal/parse-options') -const parse = (version, options) => { - options = parseOptions(options) - +const parse = (version, options, throwErrors = false) => { if (version instanceof SemVer) { return version } - - if (typeof version !== 'string') { - return null - } - - if (version.length > MAX_LENGTH) { - return null - } - - const r = options.loose ? re[t.LOOSE] : re[t.FULL] - if (!r.test(version)) { - return null - } - try { return new SemVer(version, options) } catch (er) { - return null + if (!throwErrors) { + return null + } + throw er } } |