source: trip-planner-front/node_modules/semver/functions/parse.js@ 76712b2

Last change on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 660 bytes
RevLine 
[6a3a178]1const {MAX_LENGTH} = require('../internal/constants')
2const { re, t } = require('../internal/re')
3const SemVer = require('../classes/semver')
4
5const parseOptions = require('../internal/parse-options')
6const parse = (version, options) => {
7 options = parseOptions(options)
8
9 if (version instanceof SemVer) {
10 return version
11 }
12
13 if (typeof version !== 'string') {
14 return null
15 }
16
17 if (version.length > MAX_LENGTH) {
18 return null
19 }
20
21 const r = options.loose ? re[t.LOOSE] : re[t.FULL]
22 if (!r.test(version)) {
23 return null
24 }
25
26 try {
27 return new SemVer(version, options)
28 } catch (er) {
29 return null
30 }
31}
32
33module.exports = parse
Note: See TracBrowser for help on using the repository browser.