File tree Expand file tree Collapse file tree 5 files changed +44
-9
lines changed
common/src/commonMain/kotlin/dev/suresh
build-logic/common-plugins/src/main/kotlin/plugins Expand file tree Collapse file tree 5 files changed +44
-9
lines changed Original file line number Diff line number Diff line change 1
1
package dev.suresh
2
2
3
3
import dev.zacsweers.redacted.annotations.Redacted
4
+ import kotlinx.serialization.Serializable
4
5
5
- data class KData (val name : String , val age : Int , @Redacted val password : String )
6
+ @Serializable data class KData (val name : String , val age : Int , @Redacted val password : String )
Original file line number Diff line number Diff line change 1
1
package dev.suresh
2
2
3
3
import BuildConfig
4
+ import kotlinx.datetime.Clock
5
+ import kotlinx.datetime.TimeZone
6
+ import kotlinx.datetime.toLocalDateTime
7
+ import kotlinx.io.bytestring.*
8
+ import kotlinx.serialization.encodeToString
9
+ import kotlinx.serialization.json.Json
4
10
5
11
expect val platform: String
6
12
7
13
class Greeting {
8
- fun greeting () = " ${BuildConfig .time} - ${KData (" sdsds" ,123 ," dssdsd" )} : Kotlin $platform !"
14
+
15
+ val json = Json { prettyPrint = true }
16
+
17
+ fun greeting () =
18
+ """
19
+ | ${BuildConfig .time} - ${KData (" Foo" , 123 , " xxxx" )} : Kotlin $platform !
20
+ | ${kotlinxTests()}
21
+ """
22
+ .trimMargin()
23
+
24
+ private fun kotlinxTests (): String {
25
+ val ba = " Kotlinx" .encodeToByteArray()
26
+ val bs1 = ByteString (ba)
27
+ val bs2 = " IO" .encodeToByteString()
28
+
29
+ val bs = buildByteString {
30
+ append(bs1)
31
+ append(bs2)
32
+ }
33
+
34
+ return """
35
+ |${Clock .System .now().toLocalDateTime(TimeZone .currentSystemDefault())}
36
+ |${json.encodeToString(KData (" Bar" , 123 , " xxxx" ))}
37
+ |${bs.decodeToString()}
38
+ """
39
+ .trimMargin()
40
+ }
9
41
}
Original file line number Diff line number Diff line change @@ -105,6 +105,7 @@ kotlinMultiplatform.apply {
105
105
implementation(libs.kotlinx.coroutines.core)
106
106
implementation(libs.kotlinx.datetime)
107
107
implementation(libs.kotlinx.serialization.json)
108
+ implementation(libs.kotlinx.io.bytestring)
108
109
implementation(libs.kotlinx.io.core)
109
110
implementation(libs.ktor.client.core)
110
111
implementation(libs.ktor.client.logging)
Original file line number Diff line number Diff line change @@ -102,6 +102,7 @@ kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serial
102
102
kotlinx-datetime = { module = " org.jetbrains.kotlinx:kotlinx-datetime" , version.ref = " kotlinx-datetime" }
103
103
kotlinx-atomicfu = { module = " org.jetbrains.kotlinx:atomicfu" , version.ref = " kotlinx-atomicfu" }
104
104
kotlinx-io-core = { module = " org.jetbrains.kotlinx:kotlinx-io-core" , version.ref = " kotlinx-io" }
105
+ kotlinx-io-bytestring = { module = " org.jetbrains.kotlinx:kotlinx-io-bytestring" , version.ref = " kotlinx-io" }
105
106
106
107
kotlinRetry = { module = " com.michael-bull.kotlin-retry:kotlin-retry" , version.ref = " kotlinRetry" }
107
108
kotest-core = { module = " io.kotest:kotest-assertions-core" , version.ref = " kotest" }
Original file line number Diff line number Diff line change @@ -5,18 +5,18 @@ import kotlinx.browser.document
5
5
import kotlinx.coroutines.await
6
6
import kotlinx.coroutines.delay
7
7
import kotlinx.dom.appendText
8
- import kotlinx.io.bytestring.ByteString
9
- import kotlinx.io.bytestring.decodeToString
10
8
11
9
suspend fun main () {
12
10
val text = " ${BuildConfig .time} : Hello, ${Greeting ().greeting()} !"
13
- println (text)
14
11
val root = document.getElementById(" root" )
15
- root?.appendText(text)
12
+
13
+ text.lines().forEach {
14
+ println (it)
15
+ root?.appendText(it)
16
+ root?.appendChild(document.createElement(" br" ))
17
+ }
18
+
16
19
delay(1 .seconds)
17
20
val promise = Promise .resolve(" Promise" )
18
21
root?.appendText(promise.await())
19
-
20
- val ba = ByteString (" Kotlin-IO" .encodeToByteArray())
21
- println (ba.decodeToString())
22
22
}
You can’t perform that action at this time.
0 commit comments