
Extensive utility toolkit offering extensions, date/time helpers, numeric operations, degrees/radians types, async/reactive utilities, formatters, validators, locale and currency providers, and safe-null helpers.
KMPKit is a Kotlin Multiplatform utility library targeting Android, iOS, JS, WasmJS, and JVM. It offers an extensive toolkit of extensions, utilities, formatters, and validators to enhance productivity across Kotlin projects.
Be sure to show your support by starring ⭐️ this repository!
Everything lives in the com.tweener.kmpkit package and works on every target, unless stated otherwise.
currentPlatform: the platform the code runs on (ANDROID, IOS, JS, WASM_JS or JVM).currentPlatformVersion: a description of the platform version (e.g. "Android 14 (SDK 34)", "iOS 17.2", "JVM 21.0.2").currentDeviceInfo: the device model, name and manufacturer, when available.LocalDateTime.now(), LocalDate.now() and LocalTime.now(), with an optional time zone.isAfter, isBefore, isSameDate, isToday.toEpochMilliseconds(), Long.fromEpochMilliseconds(), LocalDate.toLocalDateTime().daysInMonth(), getDaysInYear(), isLeapYear(), withDayOfMonth(), monthsSince().LocalDateTime.plus(value, unit) and plus(duration), plus ignoreNanoSeconds().round(decimalPrecision) for Double and Float.applyPercent(percent) and safeDiv(divisor, resultIfZero) for Int, Float and Double.Random.nextFloat(min, max).Degrees and Radians value classes with arithmetic and comparison operators, created with .degrees and .radians on Float and Double, and converted with toRadians() and toDegrees().Flow.conditional(condition, ifTrue, ifFalse): switches to one of two flows depending on each emitted value.CoroutineScope.onInit { }: runs a block once and exposes it as a StateFlow.combine overloads for 6, 7 and 8 flows.suspendCatching { }: a runCatching for suspending code.CancellableContinuation.resumeIfActive() and resumeWithExceptionIfActive().formatAmount(value, currency, localeLanguage): formats an amount for a currency and a locale, with optional decimals and "k", "M" and "B" abbreviations.EmailAddressValidator().isValid(email).UrlCodec().decode(encodedUrl): decodes a URL-encoded string.createLocaleProvider(): the current language and country.createCurrencyProvider(localeProvider): the currency code for that locale.safeLet(p1, p2, ...): runs a block only when all 2 to 6 values are non-null.requireNotNullOrThrow(value) { throwable }: returns the value or throws your own exception.MutableCollection.replace(elements) and MutableMap.replace(elements): clear, then add all.Context.getAlarmManager(), Context.getNotificationManager() and Context.getRawUri(rawFilename).In your settings.gradle.kts file, add Maven Central to your repositories:
repositories {
mavenCentral()
}Then add KMPKit dependency to your module:
libs.versions.toml:[versions]
kmpkit = "1.*.*" // Check latest version
[libraries]
kmpkit = { group = "io.github.tweener", name = "kmpkit", version.ref = "kmpkit" }Then in your module build.gradle.kts add:
dependencies {
implementation(libs.kmpkit)
}build.gradle.kts add:dependencies {
val kmpkit_version = "1.*.*" // Check latest version
implementation("io.github.tweener:kmpkit:$kmpkit_version")
}KMPKit is licensed under the Apache-2.0.
KMPKit is a Kotlin Multiplatform utility library targeting Android, iOS, JS, WasmJS, and JVM. It offers an extensive toolkit of extensions, utilities, formatters, and validators to enhance productivity across Kotlin projects.
Be sure to show your support by starring ⭐️ this repository!
Everything lives in the com.tweener.kmpkit package and works on every target, unless stated otherwise.
currentPlatform: the platform the code runs on (ANDROID, IOS, JS, WASM_JS or JVM).currentPlatformVersion: a description of the platform version (e.g. "Android 14 (SDK 34)", "iOS 17.2", "JVM 21.0.2").currentDeviceInfo: the device model, name and manufacturer, when available.LocalDateTime.now(), LocalDate.now() and LocalTime.now(), with an optional time zone.isAfter, isBefore, isSameDate, isToday.toEpochMilliseconds(), Long.fromEpochMilliseconds(), LocalDate.toLocalDateTime().daysInMonth(), getDaysInYear(), isLeapYear(), withDayOfMonth(), monthsSince().LocalDateTime.plus(value, unit) and plus(duration), plus ignoreNanoSeconds().round(decimalPrecision) for Double and Float.applyPercent(percent) and safeDiv(divisor, resultIfZero) for Int, Float and Double.Random.nextFloat(min, max).Degrees and Radians value classes with arithmetic and comparison operators, created with .degrees and .radians on Float and Double, and converted with toRadians() and toDegrees().Flow.conditional(condition, ifTrue, ifFalse): switches to one of two flows depending on each emitted value.CoroutineScope.onInit { }: runs a block once and exposes it as a StateFlow.combine overloads for 6, 7 and 8 flows.suspendCatching { }: a runCatching for suspending code.CancellableContinuation.resumeIfActive() and resumeWithExceptionIfActive().formatAmount(value, currency, localeLanguage): formats an amount for a currency and a locale, with optional decimals and "k", "M" and "B" abbreviations.EmailAddressValidator().isValid(email).UrlCodec().decode(encodedUrl): decodes a URL-encoded string.createLocaleProvider(): the current language and country.createCurrencyProvider(localeProvider): the currency code for that locale.safeLet(p1, p2, ...): runs a block only when all 2 to 6 values are non-null.requireNotNullOrThrow(value) { throwable }: returns the value or throws your own exception.MutableCollection.replace(elements) and MutableMap.replace(elements): clear, then add all.Context.getAlarmManager(), Context.getNotificationManager() and Context.getRawUri(rawFilename).In your settings.gradle.kts file, add Maven Central to your repositories:
repositories {
mavenCentral()
}Then add KMPKit dependency to your module:
libs.versions.toml:[versions]
kmpkit = "1.*.*" // Check latest version
[libraries]
kmpkit = { group = "io.github.tweener", name = "kmpkit", version.ref = "kmpkit" }Then in your module build.gradle.kts add:
dependencies {
implementation(libs.kmpkit)
}build.gradle.kts add:dependencies {
val kmpkit_version = "1.*.*" // Check latest version
implementation("io.github.tweener:kmpkit:$kmpkit_version")
}KMPKit is licensed under the Apache-2.0.