Gathering detailed insights and metrics for enhanced-ms
Gathering detailed insights and metrics for enhanced-ms
Gathering detailed insights and metrics for enhanced-ms
Gathering detailed insights and metrics for enhanced-ms
Convert human readable time-frame strings to milliseconds and vice versa, with support for i10n and operators!
npm install enhanced-ms
Typescript
Module System
Node Version
NPM Version
TypeScript (99.82%)
Shell (0.18%)
Total Downloads
274,441
Last Day
906
Last Week
5,985
Last Month
23,484
Last Year
222,218
MIT License
16 Stars
88 Commits
6 Forks
1 Watchers
1 Branches
5 Contributors
Updated on Apr 09, 2025
Minified
Minified + Gzipped
Latest Version
4.1.0
Package Id
enhanced-ms@4.1.0
Unpacked Size
93.83 kB
Size
18.33 kB
File Count
6
NPM Version
10.8.2
Node Version
20.19.0
Published on
Mar 20, 2025
Cumulative downloads
Total Downloads
Last Day
12.4%
906
Compared to previous day
Last Week
8.2%
5,985
Compared to previous week
Last Month
-1.7%
23,484
Compared to previous month
Last Year
508.2%
222,218
Compared to previous year
npm install enhanced-ms
enhanced-ms
is a flexible library for formatting milliseconds into human-readable durations and vice versa. It is an enhanced version of the popular ms
with support for multiple inputs, localization, and more options.
Install using your preferred package manager:
1npm install enhanced-ms 2pnpm add enhanced-ms 3yarn add enhanced-ms
As mentioned above, enhanced-ms
is an enhanced version of the popular ms
, so how does it compare?
Feature | enhanced-ms | ms | pretty-ms | itty-time |
---|---|---|---|---|
Convert Milliseconds to Duration | ✅ | ✅ | ✅ | ✅ |
Convert Milliseconds to Multiple Duration Units | ✅ | ❌ | ❌ | ❌ |
Convert Duration to Milliseconds | ✅ | ✅ | ❌ | ✅ |
Convert Multiple Duration Units to Milliseconds | ✅ | ❌ | ❌ | ❌ |
Localization Support | ✅ | ❌ | ❌ | ❌ |
The currently supported languages include:
Language | Key |
---|---|
English (default) | en |
German | de |
Russian | ru |
Māori | mi |
Spanish | es |
Dutch | nl |
Italian | it |
French | fr |
You can help by adding support for more languages.
Make a pull request here.
The createMs
function allows you to create a new instance of ms
with a custom language and custom default options. This is useful if you want to use a different language or prefer different default options for parsing and formatting.
1function createMs(options?: CreateMsOptions): typeof ms;
Option | Type | Description | Default |
---|---|---|---|
language | Locale | LanguageDefinition | The language to use for parsing and formatting, if your preferred isn't supported, you can directly pass a language definition. | en |
formatOptions | FormatOptions | FormatOptionsPreset | The options to use for formatting. | see below |
The ms
function allows you to format a number of milliseconds to a duration string. Passing a number of milliseconds will return a duration string, if the number is invalid, it will return null
. The milliseconds overloads also allows you to pass a FormatOptions
object or a FormatOptionsPreset
to customise the formatting.
1function ms(milliseconds: number): string | null; 2function ms(milliseconds: number, options: FormatOptions): string | null; 3function ms(milliseconds: number, preset: FormatOptionsPreset): string | null;
Option | Type | Description | Default |
---|---|---|---|
extends | FormatOptionsPreset | Extends the preset with the given options. | none |
hideUnitNames | boolean | Hide unit names from the output. | false |
useAbbreviations | boolean | Use abbreviations for unit names. | false |
includeZero | boolean | Include units with the value 0 in the output. | false |
includeMs | boolean | Include milliseconds in the output. | false |
includeSubMs | boolean | Include sub-millisecond units in the output. | false |
includedUnits | ParseUnit[] | Which units should be included in the output. | ['year', 'day', 'hour', 'minute', 'second'] |
unitLimit | number | The maximum number of units to include in the output. | -1 |
unitSeparator | string | The separator to use between units. | |
minimumDigits | number | The minimum number of digits for a unit, aka will pad with zeroes. | 0 |
Preset | Example |
---|---|
short | 1m 30s |
fullPrecision | 10 seconds 100 milliseconds 100 microseconds 100 nanoseconds |
colonNotation | 00:01:30 |
The ms
function also allows you to parse a duration string (1 day
, 3 weeks 4 days
, etc). Passing a duration string will return a number of milliseconds, if no valid duration units are found, it will return 0
.
1function ms(duration: string): number;
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
18 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10
Reason
Found 3/13 approved changesets -- score normalized to 2
Reason
8 existing vulnerabilities detected
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-05-05
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