kmp-base

Basic Kotlin Multiplatform functions and classes missing in the Kotlin StdLib.
Setup
Gradle
implementation("net.codinux.kotlin:kmp-base:1.5.2")
implementation("net.codinux.kotlin:kmp-base-text:1.5.2")
Maven
<dependency>
<groupId>net.codinux.kotlin</groupId>
<artifactId>kmp-base-jvm</artifactId>
<version>1.5.2</version>
</dependency>
Usage
Getting the platform type
println("Running on platform ${Platform.type}")
Platform.isAndroidOrIOS
Platform.isNative
Platform.isJavaScript
Get system information
println("Platform line separator: ${Platform.lineSeparator}")
println("Platform file separator: ${Platform.fileSeparator}")
println("OS name: ${Platform.osName}")
println("OS version: ${Platform.osVersion}")
println("CPU architecture: ${Platform.cpuArchitecture}")
Get information about environment
val environment = Environment()
println("Environment variables:")
environment.variables.forEach { (name, value) ->
println("$name: $value")
}
println("Is running in debug mode: ${environment.isRunningInDebugMode}")
println("Is running tests: ${environment.isRunningTests}")
String extensions
null.isNotNullOrBlank()
"test-string".indexOfOrNull("fun")
"another-test-string".indicesOf()
.count()
.ofMaxLength()
.substringBeforeOrNull()
.substringAfterLastOrNull()
kmp-base-text
Charsets
Charsets.UTF8
Charset.availableCharsets
Charset.forName("UTF-8")
License
Copyright 2023 dankito
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.