UNPKG

@mdf.js/utils

Version:

MMS - API Core - Common utils tools

24 lines 984 B
"use strict"; /** * Copyright 2024 Mytra Control S.L. All rights reserved. * * Use of this source code is governed by an MIT-style license that can be found in the LICENSE file * or at https://opensource.org/licenses/MIT. */ Object.defineProperty(exports, "__esModule", { value: true }); exports.prettyMS = prettyMS; const parseMS_1 = require("./parseMS"); /** * Convert milliseconds to a human readable string: `1337000000` → `15d 11h 23m 20s`. * @param ms - Milliseconds to humanize. */ function prettyMS(ms) { const time = (0, parseMS_1.parseMS)(ms); const days = time.days ? `${time.days}d ` : ''; const hours = time.hours ? `${time.hours}h ` : ''; const minutes = time.minutes ? `${time.minutes}m ` : ''; const seconds = time.seconds ? `${time.seconds}s ` : ''; const milliseconds = time.milliseconds ? `${time.milliseconds}ms ` : ''; return `${days}${hours}${minutes}${seconds}${milliseconds}`.trim(); } //# sourceMappingURL=prettyMS.js.map