Skip to content

Commit

Permalink
chore: convert parseDuration to TS
Browse files Browse the repository at this point in the history
Changes after code review
  • Loading branch information
stephane-m-dev committed Sep 23, 2024
1 parent a297160 commit 3f08791
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 17 deletions.
16 changes: 0 additions & 16 deletions @vates/parse-duration/index.js

This file was deleted.

5 changes: 4 additions & 1 deletion @vates/parse-duration/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
"ms": "^2.1.2"
},
"scripts": {
"build": "tsc",
"dev": "tsc --watch",
"postversion": "npm publish --access public",
"test": "node --test"
}
},
"main": "dist/index.js"
}
14 changes: 14 additions & 0 deletions @vates/parse-duration/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

const ms = require('ms')

exports.parseDuration = (value: number | string): number => {
if (typeof value === 'number') {
return value
}
const duration: number = ms(value)
if (duration === undefined) {
throw new TypeError(`not a valid duration: ${value}`)
}
return duration
}
18 changes: 18 additions & 0 deletions @vates/parse-duration/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"compilerOptions": {
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"newLine": "lf",
"noImplicitAny": true,
"strict": false,
"skipLibCheck": true,
"baseUrl": ".",
"sourceMap": false,
"strictNullChecks": true,
"target": "ES2015",
"outDir": "./dist",
"rootDir": "./src"
},
"exclude": ["node_modules", "dist"]
}
1 change: 1 addition & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<!--packages-start-->

- @vates/parse-duration minor
- @xen-orchestra/lite minor
- @xen-orchestra/web minor
- @xen-orchestra/web-core minor
Expand Down

0 comments on commit 3f08791

Please sign in to comment.