diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2022-03-26 12:36:19 -0500 |
|---|---|---|
| committer | JP Dillingham <jpdillingham@gmail.com> | 2022-03-26 12:36:19 -0500 |
| commit | 920fc07cb9377539e9169b51b2e7f1d2d60976a1 (patch) | |
| tree | 1c5af9e28bf4efdd8d7d6ad0bf53a6f46967c40b /src | |
| parent | 511748128942afa64231fbaa1ca971a354bcc1d1 (diff) | |
| download | slskd-920fc07cb9377539e9169b51b2e7f1d2d60976a1.tar.gz | |
add formatAttributes
Diffstat (limited to 'src')
| -rw-r--r-- | src/web/src/lib/util.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/web/src/lib/util.js b/src/web/src/lib/util.js index 86bd6977..32c55090 100644 --- a/src/web/src/lib/util.js +++ b/src/web/src/lib/util.js @@ -34,6 +34,20 @@ export const getDirectoryName = (fullPath) => { return path; } +export const formatAttributes = ({ bitRate, isVariableBitRate, bitDepth, sampleRate }) => { + const isLossless = !!sampleRate && !!bitDepth; + + if (isLossless) { + return `${bitDepth}/${sampleRate/1000}kHz`; + } + + if (isVariableBitRate) { + return `${bitRate}kbps, VBR` + } + + return bitRate ? `${bitRate}kbps` : '' +} + /* https://www.npmjs.com/package/js-file-download * * Copyright 2017 Kenneth Jiang |
