Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ jobs:
- name: Check format
run: npm run format-check

- name: Check types
run: npm run types-check

- name: Coveralls
uses: coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8
with:
Expand Down
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/**
* Takes a node version string and returns an object with the `major`/`minor`/`patch` and `pre`/`build` keys. If the version doesn't contain any pre-release or build information, the properties will be returned as empty string.
*
* @param {string} version node version string.
* @returns {object |string} object or empty string otherwise.
*/
export default function parseNodeVersion(version: string): object | string;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* Takes a node version string and returns an object with the `major`/`minor`/`patch` and `pre`/`build` keys. If the version doesn't contain any pre-release or build information, the properties will be returned as empty string.
*
* @param {string} version node version string.
* @returns {object | string} node version object or empty string otherwise.
*/
export default function parseNodeVersion(version) {
const match = version.match(
/^v(\d{1,2})\.(\d{1,2})\.(\d{1,2})(?:-([0-9A-Za-z-.]+))?(?:\+([0-9A-Za-z-.]+))?$/,
Expand Down
17 changes: 16 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,27 @@
},
"type": "module",
"main": "./index.js",
"types": "./index.d.ts",
"exports": "./index.js",
"files": [
"LICENSE",
"index.d.ts",
"index.d.ts.map",
"index.js"
],
"scripts": {
"format-check": "prettier . --check",
"format-write": "prettier . --write",
"lint": "eslint .",
"test": "node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=test/lcov.info \"test/*.js\""
"test": "node --test --experimental-test-coverage --test-reporter=spec --test-reporter-destination=stdout --test-reporter=lcov --test-reporter-destination=test/lcov.info \"test/*.js\"",
"types-check": "tsc index.js --checkJs --noEmit",
"types-write": "tsc index.js --checkJs --declaration --declarationMap --emitDeclarationOnly"
},
"devDependencies": {
"eslint": "10.11.0",
"eslint-config-gulp": "7.0.0",
"prettier": "3.9.6"
"prettier": "3.9.6",
"typescript": "6.0.3"
},
"keywords": [
"process.version",
Expand Down
Loading