Skip to content

Commit f9afe11

Browse files
committed
replace ms with ms-tiny
ms-tiny is API-compatible and ships ESM + CJS with TypeScript types. 833 bytes gzipped, zero dependencies. Wrapped ms() call in try-catch in timespan.js since ms-tiny throws on invalid input instead of returning undefined. Made-with: Cursor
1 parent ed59e76 commit f9afe11

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

lib/timespan.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
var ms = require('ms');
1+
var ms = require('ms-tiny');
22

33
module.exports = function (time, iat) {
44
var timestamp = iat || Math.floor(Date.now() / 1000);
55

66
if (typeof time === 'string') {
7-
var milliseconds = ms(time);
8-
if (typeof milliseconds === 'undefined') {
7+
var milliseconds;
8+
try {
9+
milliseconds = ms(time);
10+
} catch (e) {
911
return;
1012
}
1113
return Math.floor(timestamp + milliseconds / 1000);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"lodash.isplainobject": "^4.0.6",
4545
"lodash.isstring": "^4.0.1",
4646
"lodash.once": "^4.0.0",
47-
"ms": "^2.1.1",
47+
"ms-tiny": "^1.1.0",
4848
"semver": "^7.5.4"
4949
},
5050
"devDependencies": {

test/jwt.asymmetric_signing.tests.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const path = require('path');
55

66
const expect = require('chai').expect;
77
const assert = require('chai').assert;
8-
const ms = require('ms');
8+
const ms = require('ms-tiny');
99

1010
function loadKey(filename) {
1111
return fs.readFileSync(path.join(__dirname, filename));

0 commit comments

Comments
 (0)