Skip to content

Commit 77f22a5

Browse files
committed
Require Node.js 18
1 parent 453c6c2 commit 77f22a5

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

.github/funding.yml

-4
This file was deleted.

.github/workflows/main.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 16
14-
- 14
15-
- 12
13+
- 20
14+
- 18
1615
steps:
17-
- uses: actions/checkout@v2
18-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-node@v4
1918
with:
2019
node-version: ${{ matrix.node-version }}
2120
- run: npm install

index.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export interface Options {
1+
export type Options = {
22
/**
33
Also match non-semver versions like `1.88`. They're coerced into semver compliant versions.
44
55
@default false
66
*/
77
readonly loose?: boolean;
8-
}
8+
};
99

1010
/**
1111
Find semver versions in a string: `unicorn v1.2.3` → `1.2.3`.

index.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import semverRegex from 'semver-regex';
2+
import {matches} from 'super-regex';
23

34
export default function findVersions(stringWithVersions, {loose = false} = {}) {
45
if (typeof stringWithVersions !== 'string') {
56
throw new TypeError(`Expected a string, got ${typeof stringWithVersions}`);
67
}
78

89
const regex = loose ? new RegExp(`(?:${semverRegex().source})|(?:v?(?:\\d+\\.\\d+)(?:\\.\\d+)?)`, 'g') : semverRegex();
9-
const matches = stringWithVersions.match(regex) || [];
10+
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.
1011

11-
return [...new Set(matches.map(match => match.trim().replace(/^v/, '').replace(/^\d+\.\d+$/, '$&.0')))];
12+
return [...new Set(versions)];
1213
}

package.json

+11-6
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,13 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"type": "module",
14-
"exports": "./index.js",
14+
"exports": {
15+
"types": "./index.d.ts",
16+
"default": "./index.js"
17+
},
18+
"sideEffects": false,
1519
"engines": {
16-
"node": ">=12"
20+
"node": ">=18"
1721
},
1822
"scripts": {
1923
"test": "xo && ava && tsd"
@@ -36,11 +40,12 @@
3640
"get"
3741
],
3842
"dependencies": {
39-
"semver-regex": "^4.0.5"
43+
"semver-regex": "^4.0.5",
44+
"super-regex": "^1.0.0"
4045
},
4146
"devDependencies": {
42-
"ava": "^4.3.0",
43-
"tsd": "^0.20.0",
44-
"xo": "^0.49.0"
47+
"ava": "^6.1.2",
48+
"tsd": "^0.31.0",
49+
"xo": "^0.58.0"
4550
}
4651
}

0 commit comments

Comments
 (0)