Package dev.floofy.utils.kotlin

Functions

Link copied to clipboard
fun String.ellipsis(textLen: Int = 1995): String

Concat a string if it's over textLen.

Link copied to clipboard
fun Long.humanize(long: Boolean = false, includeMs: Boolean = false): String

Returns the humanized time for a java.lang.Long instance

Link copied to clipboard
fun <T, U> T?.ifNotNull(body: (T) -> U): U?

Calls the body function if T was not null.

Link copied to clipboard
fun <T, U> T?.ifNull(body: T?.() -> U): U?

Calls the body function if T was null.

Link copied to clipboard
fun Long.sizeToStr(): String

Format this Long into a readable byte format.

Link copied to clipboard
fun String.titleCase(): String

Upper cases the first letter of this String

Link copied to clipboard
fun <T, U, E : Throwable> T.tryCatch(catchOn: KClass<E>, body: (T) -> U): U?

Tries a function method on T, returns null if the exception was the instance of E.

Properties

Link copied to clipboard
val Long.gigabytes: Long

Converts this Long from bytes -> gigabytes.

Link copied to clipboard
val Long.kilobytes: Long

Converts this Long from bytes -> kilobytes.

Link copied to clipboard
val Long.megabytes: Long

Converts this Long from bytes -> megabytes.

Link copied to clipboard
val Long.terabytes: Long

Converts this Long from bytes -> terabytes.