feat: add modelTypes
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
export function colorIsDark(color) {
|
||||
export function colorIsDark(color: string | undefined) {
|
||||
if (typeof color === 'undefined') {
|
||||
return true // Defaults to dark
|
||||
}
|
||||
|
18
src/helpers/getHumanSize.ts
Normal file
18
src/helpers/getHumanSize.ts
Normal file
@ -0,0 +1,18 @@
|
||||
const SIZES = [
|
||||
'B',
|
||||
'KB',
|
||||
'MB',
|
||||
'GB',
|
||||
'TB',
|
||||
] as const
|
||||
|
||||
export function getHumanSize(inputSize: number) {
|
||||
let iterator = 0
|
||||
let size = inputSize
|
||||
while (size > 1024) {
|
||||
size /= 1024
|
||||
iterator++
|
||||
}
|
||||
|
||||
return Number(Math.round(Number(size + 'e2')) + 'e-2') + ' ' + SIZES[iterator]
|
||||
}
|
Reference in New Issue
Block a user