Update index.js
Browse files
index.js
CHANGED
|
@@ -222,7 +222,29 @@ async function convertMp4ToAudio(inputBuffer) {
|
|
| 222 |
.pipe(outputStream);
|
| 223 |
});
|
| 224 |
}
|
|
|
|
|
|
|
| 225 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 226 |
async function streamToBuffer(stream) {
|
| 227 |
const chunks = [];
|
| 228 |
const captureChunks = new Writable({
|
|
|
|
| 222 |
.pipe(outputStream);
|
| 223 |
});
|
| 224 |
}
|
| 225 |
+
function formatSize(bytes, si = false, dp = 2) {
|
| 226 |
+
const thresh = si ? 1000 : 1024;
|
| 227 |
|
| 228 |
+
if (Math.abs(bytes) < thresh) {
|
| 229 |
+
return `${bytes} B`;
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
const units = si
|
| 233 |
+
? ["kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]
|
| 234 |
+
: ["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
| 235 |
+
let u = -1;
|
| 236 |
+
const r = 10 ** dp;
|
| 237 |
+
|
| 238 |
+
do {
|
| 239 |
+
bytes /= thresh;
|
| 240 |
+
++u;
|
| 241 |
+
} while (
|
| 242 |
+
Math.round(Math.abs(bytes) * r) / r >= thresh &&
|
| 243 |
+
u < units.length - 1
|
| 244 |
+
);
|
| 245 |
+
|
| 246 |
+
return `${bytes.toFixed(dp)} ${units[u]}`;
|
| 247 |
+
}
|
| 248 |
async function streamToBuffer(stream) {
|
| 249 |
const chunks = [];
|
| 250 |
const captureChunks = new Writable({
|