Gathering detailed insights and metrics for @anonymort/ms-long
Gathering detailed insights and metrics for @anonymort/ms-long
Gathering detailed insights and metrics for @anonymort/ms-long
Gathering detailed insights and metrics for @anonymort/ms-long
npm install @anonymort/ms-long
Typescript
Module System
Min. Node Version
Node Version
NPM Version
70.6
Supply Chain
98.8
Quality
76.9
Maintenance
100
Vulnerability
100
License
Total Downloads
240
Last Day
1
Last Week
6
Last Month
16
Last Year
240
Minified
Minified + Gzipped
Latest Version
2.0.0
Package Id
@anonymort/ms-long@2.0.0
Unpacked Size
12.87 kB
Size
4.04 kB
File Count
8
NPM Version
9.6.5
Node Version
20.14.0
Published on
Jul 05, 2024
Cumulative downloads
Total Downloads
Last Day
0%
1
Compared to previous day
Last Week
100%
6
Compared to previous week
Last Month
6.7%
16
Compared to previous month
Last Year
0%
240
Compared to previous year
4
An extended time conversion utility that builds upon the popular ms
library, supporting extremely large time values and multiple units, including those needed for scientific projects.
parse
and format
functions for flexible usage1npm install @anonymort/ms-long
1import msLong, { parse, format } from '@anonymort/ms-long'; 2 3// Parse time strings 4console.log(msLong('2 hours 30 minutes')); // 9000000n 5 6// Format milliseconds 7console.log(msLong(9000000n)); // '2h 30m' 8console.log(msLong(9000000n, { long: true })); // '2 hours 30 minutes' 9 10// Parse complex time strings with large units 11console.log(parse('2 epochs 1 era')); // 1002000000000000000000n 12 13// Format large values 14console.log(format(1002000000000000000000n, { long: true })); 15// '1 era 2 epochs' 16 17// Use scientific notation 18console.log(parse('1.5e9 years')); // 47304000000000000000000n 19 20// Custom time scales 21const customUnits = { 22 galacticYear: 230000000000n * 365n * 24n * 60n * 60n * 1000n, // ~230 million years 23}; 24 25console.log(parse('2 galacticYears', customUnits)); // 14515200000000000000000n 26 27console.log(format(14515200000000000000000n, { long: true, customUnits })); 28// '2 galacticYears'
The main function that can both parse and format time values.
long
option determines whether to use long format (e.g., "2 hours" vs "2h").customUnits
option allows for defining custom time units.Parses a time string to milliseconds (as BigInt). Supports multiple units and extremely large time values.
Formats milliseconds (as BigInt or number) to a time string. Can handle extremely large values and provides precise output for large durations.
Custom units can be defined as needed.
ms
libraryparse
and format
functions exposedContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
No vulnerabilities found.
No security vulnerabilities found.