Skip to content

Commit

Permalink
Use an actual Map
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 23, 2017
1 parent 1559c38 commit d41a71d
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
/* eslint-disable quote-props */
'use strict';
const os = require('os');
const execa = require('execa');

// Reference: https://www.gaijin.at/en/lstwinver.php
const nameMap = {
'10.0': '10',
'6.3': '8.1',
'6.2': '8',
'6.1': '7',
'6.0': 'Vista',
'5.2': 'Server 2003',
'5.1': 'XP',
'5.0': '2000',
'4.9': 'ME',
'4.1': '98',
'4.0': '95'
};
const names = new Map([
['10.0', '10'],
['6.3', '8.1'],
['6.2', '8'],
['6.1', '7'],
['6.0', 'Vista'],
['5.2', 'Server 2003'],
['5.1', 'XP'],
['5.0', '2000'],
['4.9', 'ME'],
['4.1', '98'],
['4.0', '95']
]);

module.exports = release => {
const version = /\d+\.\d+/.exec(release || os.release());
Expand All @@ -36,5 +35,5 @@ module.exports = release => {
}
}

return nameMap[ver];
return names.get(ver);
};

0 comments on commit d41a71d

Please sign in to comment.