All files / js/utils helpers.js

100% Statements 16/16
83.33% Branches 5/6
100% Functions 3/3
100% Lines 16/16

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 365x 6x   6x       6x         6x   6x   6x   1x 1x     6x       5x 4x     5x 4x 4x 4x    
export const parseTime = seconds => {
    let hours = Math.floor(seconds / 3600);
 
    let mins = Math.floor((seconds % 3600) / 60)
        .toFixed(0)
        .toString();
 
    let secs = Math.floor((seconds % 3600) % 60)
        .toFixed(0)
        .toString();
 
    // Left-pad seconds string if needed
    secs = secs >= 10 ? secs : `0${secs}`;
 
    let parsedTime = `${mins}:${secs}`;
 
    if (hours > 0) {
        // Left-pad minutes string if needed
        mins = mins >= 10 ? mins : `0${mins}`;
        parsedTime = `${hours}:${mins}:${secs}`;
    }
 
    return parsedTime;
};
 
// Get File Type
export const getFileType = string =>
    string.substr((~-string.lastIndexOf(".") >>> 0) + 2);
 
// Get File Name
export const getFileName = string => {
    let fullFileName = string.replace(/^.*[\\\/]/, "");
    let withNoExtension = fullFileName.split(".")[0];
    return withNoExtension;
};