mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 02:31:35 +00:00
General code cleanup from analysis
This commit is contained in:
parent
806494f5e0
commit
36f33b9f7e
3 changed files with 16 additions and 20 deletions
|
|
@ -8,7 +8,7 @@ function timeToPastText(timestamp) {
|
|||
["hour", 60 * 60 * 1000],
|
||||
["minute", 60 * 1000],
|
||||
["second", 1 * 1000]
|
||||
].reduce((acc, [unitName, unitValue]) => {
|
||||
].reduce((acc, /** @type {[string, number]} */ [unitName, unitValue]) => {
|
||||
if (acc) return acc
|
||||
if (difference > unitValue) {
|
||||
const number = Math.floor(difference / unitValue)
|
||||
|
|
@ -19,12 +19,9 @@ function timeToPastText(timestamp) {
|
|||
}
|
||||
|
||||
function lengthSecondsToLengthText(seconds) {
|
||||
return [Math.floor(seconds/3600), Math.floor(seconds/60)%60, seconds%60]
|
||||
.reduce((a, c, i, t) => (
|
||||
a ? a : c || i == 1 ? t.slice(i) : false
|
||||
), false)
|
||||
.map((x, i) => i === 0 ? x : (x+"").padStart(2, "0"))
|
||||
.join(":")
|
||||
let parts = [Math.floor(seconds/3600), Math.floor(seconds/60)%60, seconds%60]
|
||||
if (parts[0] === 0) parts = parts.slice(1)
|
||||
return parts.map((x, i) => i === 0 ? x : (x+"").padStart(2, "0")).join(":")
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class User {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param {any} responseHeaders supply this to create a token
|
||||
* @param {any} [responseHeaders] supply this to create a token
|
||||
*/
|
||||
function getUser(req, responseHeaders) {
|
||||
const token = getToken(req, responseHeaders)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue