Added format milliseconds method
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/utils",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.26.17",
|
"version": "0.26.18",
|
||||||
"description": "Utility library",
|
"description": "Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -45,11 +45,10 @@ export function formatBytes(bytes: number, decimals = 2) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert milliseconds to human-readable duration
|
* Convert milliseconds to human-readable duration
|
||||||
* @param {string} number milliseconds
|
* @param {string} ms milliseconds
|
||||||
* @return {string} formated duration
|
* @return {string} formated duration
|
||||||
*/
|
*/
|
||||||
export function formatMs(number: string): string {
|
export function formatMs(ms: number): string {
|
||||||
const ms = parseInt(number, 10);
|
|
||||||
if (isNaN(ms) || ms < 0) return "Invalid input";
|
if (isNaN(ms) || ms < 0) return "Invalid input";
|
||||||
const seconds = ms / 1000;
|
const seconds = ms / 1000;
|
||||||
const minutes = seconds / 60;
|
const minutes = seconds / 60;
|
||||||
|
Reference in New Issue
Block a user