Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions packages/webamp/js/reducers/tracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,27 @@
[id: string]: PlaylistTrack;
}

let finalKhz: String = 'NaN';

Check failure on line 9 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Replace `'NaN'` with `"NaN"`
let finalKbps: String = 'NaN';

Check failure on line 10 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Replace `'NaN'` with `"NaN"`
function massageKhz(khz: number) {
let stringKhz = String(Math.round(khz / 1000));

Check failure on line 12 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

'stringKhz' is never reassigned. Use 'const' instead
if (khz/1000 != null) finalKhz = stringKhz;

Check failure on line 13 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Replace `/` with `·/·`

Check failure on line 13 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected constant binary expression. Compares constantly with the right-hand side of the `!=`
if (khz/1000 <= 100) finalKhz = stringKhz;

Check failure on line 14 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Replace `/` with `·/·`
if (khz/1000 <= 10) finalKhz = ' '+stringKhz.substring(0,1);

Check warning on line 15 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected string concatenation

Check failure on line 15 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Replace `/1000·<=·10)·finalKhz·=·'·'+stringKhz.substring(0,` with `·/·1000·<=·10)·finalKhz·=·"·"·+·stringKhz.substring(0,·`
if (khz/1000 >= 100) finalKhz = stringKhz.substring(1,3);

Check failure on line 16 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Replace `/1000·>=·100)·finalKhz·=·stringKhz.substring(1,` with `·/·1000·>=·100)·finalKhz·=·stringKhz.substring(1,·`
return finalKhz;
}

function massageKbps(kbps: number) {
let stringBitrate = String(Math.round(kbps / 1000));

Check failure on line 21 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

'stringBitrate' is never reassigned. Use 'const' instead
if (kbps/1000 != null) finalKbps = stringBitrate;

Check failure on line 22 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected constant binary expression. Compares constantly with the right-hand side of the `!=`
if (kbps/1000 <= 100) finalKbps = ' '+stringBitrate;

Check warning on line 23 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected string concatenation
if (kbps/1000 <= 10) finalKbps = ' '+stringBitrate;

Check warning on line 24 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected string concatenation
if (kbps/1000 >= 1000) finalKbps = stringBitrate.substring(0,2)+'H'; // if you asked me what this meant

Check warning on line 25 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected string concatenation
if (kbps/1000 >= 10000) finalKbps = ' '+stringBitrate.substring(0,1)+'C'; // i wouldnt know what to tell you

Check warning on line 26 in packages/webamp/js/reducers/tracks.ts

View workflow job for this annotation

GitHub Actions / ci

Unexpected string concatenation
return finalKbps;
}

const defaultPlaylistState: TracksState = {};

const tracks = (
Expand Down Expand Up @@ -80,8 +101,8 @@
artist,
album,
albumArtUrl,
kbps: bitrate != null ? String(Math.round(bitrate / 1000)) : kbps,
khz: sampleRate != null ? String(Math.round(sampleRate / 1000)) : khz,
kbps: bitrate != null ? massageKbps(bitrate) : kbps,
khz: sampleRate != null ? massageKhz(sampleRate) : khz,
channels: numberOfChannels != null ? numberOfChannels : channels,
},
};
Expand Down
Loading