From 146f171cbc6a72abf8ec241998b2aaad5177533d Mon Sep 17 00:00:00 2001 From: Azalea <22280294+hykilpikonna@users.noreply.github.com> Date: Mon, 13 Jan 2025 21:16:30 -0500 Subject: [PATCH] [+] Str.some --- src/main/java/ext/Ext.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/ext/Ext.kt b/src/main/java/ext/Ext.kt index f9240cfd..db2d6073 100644 --- a/src/main/java/ext/Ext.kt +++ b/src/main/java/ext/Ext.kt @@ -220,6 +220,7 @@ fun Str.splitLines() = replace("\r\n", "\n").split('\n') fun Str.md5() = MD5.digest(toByteArray(Charsets.UTF_8)).toHexString() fun Str.fromChusanUsername() = String(this.toByteArray(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8) fun Str.truncate(len: Int) = if (this.length > len) this.take(len) + "..." else this +val Str.some get() = ifBlank { null } // Coroutine suspend fun async(block: suspend kotlinx.coroutines.CoroutineScope.() -> T): T = withContext(Dispatchers.IO) { block() }