source: trip-planner-front/node_modules/semver/functions/diff.js@ ceaed42

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

initial commit

  • Property mode set to 100644
File size: 634 bytes
Line 
1const parse = require('./parse')
2const eq = require('./eq')
3
4const diff = (version1, version2) => {
5 if (eq(version1, version2)) {
6 return null
7 } else {
8 const v1 = parse(version1)
9 const v2 = parse(version2)
10 const hasPre = v1.prerelease.length || v2.prerelease.length
11 const prefix = hasPre ? 'pre' : ''
12 const defaultResult = hasPre ? 'prerelease' : ''
13 for (const key in v1) {
14 if (key === 'major' || key === 'minor' || key === 'patch') {
15 if (v1[key] !== v2[key]) {
16 return prefix + key
17 }
18 }
19 }
20 return defaultResult // may be undefined
21 }
22}
23module.exports = diff
Note: See TracBrowser for help on using the repository browser.