feat: history/favorites panel, image preview, context strip
Co-Authored-By: Ovis Fast (Claude) <[email protected]>
This commit is contained in:
1 parent
6360c75ff8
commit
7116af9434
9 files changed
+930
-79
No files matched your search
@@ -177,3 +177,18 @@ function standalone(before, after, afterNext) {
|
||||
if (after === "." && PATH_CHAR.test(afterNext)) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A size for a tile: `512 B`, `1,5 KB`, `5 MB`.
|
||||
*
|
||||
* @param {number|undefined|null} bytes
|
||||
* @returns {string} nothing when the size is not known
|
||||
*/
|
||||
export function formatBytes(bytes) {
|
||||
if (!Number.isFinite(bytes) || bytes < 0) return "";
|
||||
const unit = (value, name) => `${String(Math.round(value * 10) / 10).replace(".", ",")} ${name}`;
|
||||
if (bytes < 1024) return `${bytes} B`;
|
||||
if (bytes < 1024 * 1024) return unit(bytes / 1024, "KB");
|
||||
if (bytes < 1024 * 1024 * 1024) return unit(bytes / 1024 / 1024, "MB");
|
||||
return unit(bytes / 1024 / 1024 / 1024, "GB");
|
||||
}
|
||||
Reference in new issue
Block a user