UNPKG

vike

Version:

The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.

25 lines (24 loc) 630 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.humanizeTime = humanizeTime; function humanizeTime(milliseconds) { const seconds = milliseconds / 1000; if (seconds < 120) { const n = round(seconds); return `${n} second${plural(n)}`; } { const minutes = seconds / 60; const n = round(minutes); return `${n} minute${plural(n)}`; } } function round(n) { let rounded = n.toFixed(1); if (rounded.endsWith('.0')) rounded = rounded.slice(0, -2); return rounded; } function plural(n) { return n === '1' ? '' : 's'; }