Gathering detailed insights and metrics for ms
Gathering detailed insights and metrics for ms
Gathering detailed insights and metrics for ms
Gathering detailed insights and metrics for ms
npm install ms
Typescript
Module System
Node Version
NPM Version
99.7
Supply Chain
84.7
Quality
82.6
Maintenance
100
Vulnerability
100
License
TypeScript (91.41%)
JavaScript (8.4%)
Shell (0.19%)
Total Downloads
46,295,635,002
Last Day
17,122,760
Last Week
262,805,787
Last Month
1,126,189,986
Last Year
12,374,937,419
MIT License
5,298 Stars
163 Commits
276 Forks
90 Watchers
7 Branches
112 Contributors
Updated on Jul 02, 2025
Minified
Minified + Gzipped
Latest Version
2.1.3
Package Id
ms@2.1.3
Size
2.90 kB
NPM Version
6.14.6
Node Version
12.18.3
Published on
Dec 08, 2020
Cumulative downloads
Total Downloads
Last Day
-2%
17,122,760
Compared to previous day
Last Week
-6%
262,805,787
Compared to previous week
Last Month
1.8%
1,126,189,986
Compared to previous month
Last Year
13.9%
12,374,937,419
Compared to previous year
Use this package to easily convert various time formats to milliseconds.
1ms('2 days') // 172800000 2ms('1d') // 86400000 3ms('10h') // 36000000 4ms('2.5 hrs') // 9000000 5ms('2h') // 7200000 6ms('1m') // 60000 7ms('5s') // 5000 8ms('1y') // 31557600000 9ms('100') // 100 10ms('-3 days') // -259200000 11ms('-1h') // -3600000 12ms('-200') // -200
1ms(60000) // "1m" 2ms(2 * 60000) // "2m" 3ms(-3 * 60000) // "-3m" 4ms(ms('10 hours')) // "10h"
1ms(60000, { long: true }) // "1 minute" 2ms(2 * 60000, { long: true }) // "2 minutes" 3ms(-3 * 60000, { long: true }) // "-3 minutes" 4ms(ms('10 hours'), { long: true }) // "10 hours"
ms
, a string with a unit is returned100
for '100'
)As of v3.0, this package includes TypeScript definitions.
For added safety, we're using Template Literal Types (added in TypeScript 4.1). This ensures that you don't accidentally pass ms
values that it can't process.
This won't require you to do anything special in most situations, but you can also import the StringValue
type from ms
if you need to use it.
1import ms, { StringValue } from 'ms'; 2 3// Using the exported type. 4function example(value: StringValue) { 5 ms(value); 6} 7 8// This function will only accept a string compatible with `ms`. 9example('1 h');
In this example, we use a Type Assertion to coerce a string
.
1import ms, { StringValue } from 'ms'; 2 3// Type assertion with the exported type. 4function example(value: string) { 5 try { 6 // A string could be "wider" than the values accepted by `ms`, so we assert 7 // that our `value` is a `StringValue`. 8 // 9 // It's important to note that this can be dangerous (see below). 10 ms(value as StringValue); 11 } catch (error: Error) { 12 // Handle any errors from invalid vaues. 13 console.error(error); 14 } 15} 16 17// This function will accept any string, which may result in a bug. 18example('any value');
You may also create a custom Template Literal Type.
1import ms from 'ms'; 2 3type OnlyDaysAndWeeks = `${number} ${'days' | 'weeks'}`; 4 5// Using a custom Template Literal Type. 6function example(value: OnlyDaysAndWeeks) { 7 // The type of `value` is narrower than the values `ms` accepts, which is 8 // safe to use without coercion. 9 ms(value); 10} 11 12// This function will accept "# days" or "# weeks" only. 13example('5.2 days');
ms
as a macro at build-time.npm link
npm link ms
. Instead of the default one from npm, Node.js will now use your clone of ms!As always, you can run the tests using: npm test
7.5/10
Summary
Regular Expression Denial of Service in ms
Affected Versions
< 0.7.1
Patched Versions
0.7.1
5.3/10
Summary
Vercel ms Inefficient Regular Expression Complexity vulnerability
Affected Versions
< 2.0.0
Patched Versions
2.0.0
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
Found 19/29 approved changesets -- score normalized to 6
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
11 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More