Skip to content

Commit 3cf528d

Browse files
committed
chore: improve comments in utils
1 parent 6d03667 commit 3cf528d

File tree

4 files changed

+28
-4
lines changed

4 files changed

+28
-4
lines changed

src/utils/parseBitrate.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// Converts input bitrate to kbits/s
1+
/**
2+
* Converts the given bitrate value to kilobits per second (kbps) based on the provided unit.
3+
*
4+
* @param bitrate The bitrate value to be converted.
5+
* @param unit The unit of the given bitrate value. Supported units are "b/s", "bit/s", "bits/s", "kb/s", "kbit/s", "kbits/s", "mb/s", "mbit/s", and "mbits/s".
6+
* @returns The bitrate value converted to kbps.
7+
* @throws Error if the provided unit is not recognized.
8+
*/
29
export function parseBitrate(bitrate: number, unit: string): number {
310
switch (unit.toLowerCase()) {
411
case "b/s":

src/utils/parseSize.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
// Converts input size to bytes
1+
/**
2+
* Parses a size value with a unit and returns the size in bytes.
3+
*
4+
* @param size - The size value to parse.
5+
* @param unit - The unit of the size value, e.g. "B", "KB", "MB".
6+
* @returns The size in bytes.
7+
* @throws {Error} If the unit is unknown.
8+
*/
29
export function parseSize(size: number, unit: string): number {
310
switch (unit.toLowerCase()) {
411
case "b":

src/utils/secsToTimer.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// Convert seconds to HH:MM:SS.MS
1+
/**
2+
* Converts a number of seconds to a formatted timer string in the format "HH:MM:SS.MS".
3+
*
4+
* @param seconds - The number of seconds to convert.
5+
* @returns A formatted timer string.
6+
*/
27
export function secsToTimer(seconds: number): string {
38
const h = Math.floor(seconds / 3600);
49
const m = Math.floor(seconds / 60) % 60;

src/utils/timerToSecs.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
// Convert HH:MM:SS.MS to seconds
1+
/**
2+
* Converts a time string in the format "HH:MM:SS.MS" to a number of seconds.
3+
*
4+
* @param input - A time string in the format "HH:MM:SS.MS".
5+
* @returns The number of seconds represented by the input time string, rounded to two decimal places.
6+
*/
27
export function timerToSecs(input: string): number {
38
const timer = input.split(":");
49
const hours = +timer[0];

0 commit comments

Comments
 (0)