Gathering detailed insights and metrics for @lukeed/ms
Gathering detailed insights and metrics for @lukeed/ms
A tiny (414B) and fast utility to convert milliseconds to and from strings.
npm install @lukeed/ms
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
72,819,305
Last Day
211,464
Last Week
1,176,833
Last Month
5,062,026
Last Year
47,795,376
MIT License
229 Stars
29 Commits
5 Forks
3 Watchers
1 Branches
3 Contributors
Updated on Mar 13, 2025
Minified
Minified + Gzipped
Latest Version
2.0.2
Package Id
@lukeed/ms@2.0.2
Unpacked Size
9.17 kB
Size
3.62 kB
File Count
7
NPM Version
10.1.0
Node Version
20.8.1
Published on
Nov 28, 2023
Cumulative downloads
Total Downloads
Last Day
-0.5%
211,464
Compared to previous day
Last Week
4%
1,176,833
Compared to previous week
Last Month
9.7%
5,062,026
Compared to previous month
Last Year
107.7%
47,795,376
Compared to previous year
A tiny (414B) and fast utility to convert milliseconds to and from strings.
NOTICE: This is a fork of vercel/ms!
In June 2019, I opened a PR with signficiant performance and code size improvements. After nearly 2 years of silence, it was eventually closed. :cry: A year into my wait, I started anew (this repo), hoping to improve upon my own improvements.
This module is delivered as:
dist/index.js
dist/index.mjs
dist/index.min.js
$ npm install --save @lukeed/ms
1import { parse, format } from '@lukeed/ms'; 2 3// string => number 4parse('2 days'); //=> 172800000 5parse('1d'); //=> 86400000 6parse('10h'); //=> 36000000 7parse('2.5 hrs'); //=> 9000000 8parse('2h'); //=> 7200000 9parse('1m'); //=> 60000 10parse('5s'); //=> 5000 11parse('1y'); //=> 31557600000 12parse('100'); //=> 100 13parse('-3 days'); //=> -259200000 14parse('-1h'); //=> -3600000 15parse('-200'); //=> -200 16 17// number => string 18format(60000); //=> '1m' 19format(2 * 60000); //=> '2m' 20format(-3 * 60000); //=> '-3m' 21format(parse('10 hours')); //=> '10h' 22 23// number => string (long) 24format(60000, true); //=> '1 minute' 25format(2 * 60000, true); //=> '2 minutes' 26format(-3 * 60000, true); //=> '-3 minutes' 27format(parse('10 hours'), true); //=> '10 hours'
Returns: Number
Parses the input string, returning the number of milliseconds.
Type: String
The human-readable time string; eg: 10min
, 10m
, 10 minutes
.
Returns: Number
Formats the millisecond count to a human-readable time string.
Important: The output will be rounded to the nearest whole integer.
Type: Number
The number of milliseconds.
Type: Boolean
Default: false
Whether or not the output should use the interval's long/full form; eg hour
or hours
instead of h
.
Note: When
long
, the count and interval will be separated by a single space.
Also, whenlong
, the interval may be pluralized; eg1 second
vs2 seconds
.
Running on Node.js v12.18.4
Validation :: parse
✔ lukeed/ms
✔ zeit/ms
Benchmark :: "parse"
lukeed/ms x 351,319 ops/sec ±0.31% (96 runs sampled)
zeit/ms x 245,576 ops/sec ±1.66% (94 runs sampled)
Benchmark :: "parse" (long)
lukeed/ms x 335,538 ops/sec ±0.50% (94 runs sampled)
zeit/ms x 265,410 ops/sec ±1.72% (95 runs sampled)
Validation :: format
✔ lukeed/ms
✔ zeit/ms
Benchmark :: "format"
lukeed/ms x 4,109,440 ops/sec ±0.35% (94 runs sampled)
zeit/ms x 3,420,198 ops/sec ±1.61% (94 runs sampled)
Benchmark :: "format" (long)
lukeed/ms x 3,402,872 ops/sec ±0.14% (97 runs sampled)
zeit/ms x 1,344,908 ops/sec ±3.68% (96 runs sampled)
This is obviously a fork of zeit/ms.
I opened a PR in June 2019 that introduced significant performance gains and code reduction — it was ignored for nearly two years. This repository is a from-scratch re-implementation that takes the goals of that PR a bit further.
MIT © Luke Edwards
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 3/29 approved changesets -- score normalized to 1
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
security policy file not detected
Details
Reason
project is not fuzzed
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-03-10
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