export function msToTime(ms: number) { let seconds = (ms / 1000); let minutes = (ms / (1000 * 60)); let hours = (ms / (1000 * 60 * 60)); let days = (ms / (1000 * 60 * 60 * 24)); if (seconds < 60) return `${seconds.toFixed(1)} secs`; else if (minutes < 60) return `${minutes.toFixed(1)} mins`; else if (hours < 24) return `${hours.toFixed(1)} hrs`; else return `${days.toFixed(1)} days`; } export function parseContentType(ctypRaw: string | null | undefined) { ctypRaw = (ctypRaw) ? ctypRaw : "text/plain"; let ctyps = ctypRaw.split(";"); let ctyp = ctyps[0]; return ctyp; } export function processType(): string { switch (true) { case ((typeof process !== 'undefined') && (process.release.name === 'node')): return "nodejs"; case (typeof window !== 'undefined'): return "browser"; case (typeof (self as any).clients !== 'undefined'): return "serviceworker"; default: return "unknown" } }