🪖 Moves humanFileSize to string utilities
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { socket, isConnected, systemInfo } from "../../lib/socket";
|
import { socket, isConnected, systemInfo } from "../../lib/socket";
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import { humanFileSize } from "../../lib/utils";
|
import { humanFileSize } from "$lib/utilities";
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if ($isConnected) {
|
if ($isConnected) {
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './result'
|
||||||
|
export * from './string-utilities'
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export const humanFileSize = (size:number):string => {
|
||||||
|
const units = ['B', 'kB', 'MB', 'GB', 'TB']
|
||||||
|
var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
||||||
|
return Number((size / Math.pow(1024, i)).toFixed(2)) * 1 + units[i];
|
||||||
|
}
|
||||||
@@ -1,10 +1,5 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
|
|
||||||
export const humanFileSize = (size:number):string => {
|
|
||||||
var i = size == 0 ? 0 : Math.floor(Math.log(size) / Math.log(1024));
|
|
||||||
return Number((size / Math.pow(1024, i)).toFixed(2)) * 1 + ['B', 'kB', 'MB', 'GB', 'TB'][i];
|
|
||||||
}
|
|
||||||
|
|
||||||
export const lerp = (start: number, end: number, amt: number) => {
|
export const lerp = (start: number, end: number, amt: number) => {
|
||||||
return (1 - amt) * start + amt * end;
|
return (1 - amt) * start + amt * end;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user