find-versions
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
export interface Options { | ||
export type Options = { | ||
/** | ||
@@ -8,3 +8,3 @@ Also match non-semver versions like `1.88`. They're coerced into semver compliant versions. | ||
readonly loose?: boolean; | ||
} | ||
}; | ||
@@ -11,0 +11,0 @@ /** |
import semverRegex from 'semver-regex'; | ||
import {matches} from 'super-regex'; | ||
@@ -9,5 +10,5 @@ export default function findVersions(stringWithVersions, {loose = false} = {}) { | ||
const regex = loose ? new RegExp(`(?:${semverRegex().source})|(?:v?(?:\\d+\\.\\d+)(?:\\.\\d+)?)`, 'g') : semverRegex(); | ||
const matches = stringWithVersions.match(regex) || []; | ||
const versions = [...matches(regex, stringWithVersions)].map(({match}) => match.trim().replace(/^v/, '').replace(/^\d+\.\d+$/, '$&.0')); // TODO: Remove the `...` when https://github.com/tc39/proposal-iterator-helpers is available. | ||
return [...new Set(matches.map(match => match.trim().replace(/^v/, '').replace(/^\d+\.\d+$/, '$&.0')))]; | ||
return [...new Set(versions)]; | ||
} |
{ | ||
"name": "find-versions", | ||
"version": "5.1.0", | ||
"version": "6.0.0", | ||
"description": "Find semver versions in a string: `unicorn v1.2.3` → `1.2.3`", | ||
@@ -14,5 +14,9 @@ "license": "MIT", | ||
"type": "module", | ||
"exports": "./index.js", | ||
"exports": { | ||
"types": "./index.d.ts", | ||
"default": "./index.js" | ||
}, | ||
"sideEffects": false, | ||
"engines": { | ||
"node": ">=12" | ||
"node": ">=18" | ||
}, | ||
@@ -40,9 +44,10 @@ "scripts": { | ||
"dependencies": { | ||
"semver-regex": "^4.0.5" | ||
"semver-regex": "^4.0.5", | ||
"super-regex": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^4.3.0", | ||
"tsd": "^0.20.0", | ||
"xo": "^0.49.0" | ||
"ava": "^6.1.2", | ||
"tsd": "^0.31.0", | ||
"xo": "^0.58.0" | ||
} | ||
} |
4008
6.17%32
3.23%2
100%+ Added
+ Added
+ Added
+ Added
+ Added