mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
Bytes
This commit is contained in:
parent
bc9c8f7ee2
commit
1ca985aa4a
7 changed files with 35 additions and 19 deletions
11
src/utils.ts
11
src/utils.ts
|
@ -363,6 +363,17 @@ export const nFormatter = (num: number, digits: number): string => {
|
|||
);
|
||||
};
|
||||
|
||||
export const formatSpeed = (speed: number): string => {
|
||||
// source: en.wikipedia.org/wiki/Data-rate_units#Conversion_table
|
||||
const suffix = ["B/s", "kB/s", "MB/s", "GB/s"];
|
||||
let index = 0;
|
||||
while (speed > 1000) {
|
||||
index++;
|
||||
speed = speed / 1000;
|
||||
}
|
||||
return `${speed.toFixed(index > 1 ? 1 : 0)} ${suffix[index]}`;
|
||||
};
|
||||
|
||||
export const getVersion = () => {
|
||||
return (
|
||||
document.querySelector<HTMLMetaElement>('meta[name="version"]')?.content ||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue