index.js 351 B

12345678910111213141516
  1. 'use strict';
  2. function parseNodeVersion(version) {
  3. var match = version.match(/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})$/);
  4. if (!match) {
  5. throw new Error('Unable to parse: ' + version);
  6. }
  7. return {
  8. major: parseInt(match[1], 10),
  9. minor: parseInt(match[2], 10),
  10. patch: parseInt(match[3], 10),
  11. };
  12. }
  13. module.exports = parseNodeVersion;