You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 554B

12345678910111213
  1. 'use strict';
  2. const semverRegex = require('semver-regex');
  3. module.exports = (stringWithVersions, options = {}) => {
  4. if (typeof stringWithVersions !== 'string') {
  5. throw new TypeError(`Expected a string, got ${typeof stringWithVersions}`);
  6. }
  7. const reLoose = new RegExp(`(?:${semverRegex().source})|(?:v?(?:\\d+\\.\\d+)(?:\\.\\d+)?)`, 'g');
  8. const matches = stringWithVersions.match(options.loose === true ? reLoose : semverRegex()) || [];
  9. return [...new Set(matches.map(match => match.trim().replace(/^v/, '').replace(/^\d+\.\d+$/, '$&.0')))];
  10. };