aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/web/src/lib/util.js14
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