Tuulbox

Toolbox of utilities/helpers for Kotlin development

License

License

Categories

Categories

Data
GroupId

GroupId

com.juul.tuulbox
ArtifactId

ArtifactId

test-metadata
Last Version

Last Version

4.1.0
Release Date

Release Date

Type

Type

pom.sha512
Description

Description

Tuulbox
Toolbox of utilities/helpers for Kotlin development
Project URL

Project URL

https://github.com/JuulLabs/tuulbox
Source Code Management

Source Code Management

https://github.com/JuulLabs/tuulbox

Download test-metadata

Dependencies

compile (4)

Group / Artifact Type Version
org.jetbrains.kotlin : kotlin-test-common jar 1.4.31
org.jetbrains.kotlinx : kotlinx-coroutines-core-metadata jar 1.4.0
org.jetbrains.kotlinx : kotlinx-datetime-metadata jar 0.1.1
org.jetbrains.kotlin : kotlin-stdlib-common jar 1.4.31

Project Modules

There are no modules declared in this project.

codecov Slack

Tuulbox

Toolbox of utilities/helpers for Kotlin development.

Coroutines

badge-android badge-js badge-jvm badge-mac

Utilities for Coroutines.

combine

combine for up to 10 Flows:

val combined = combine(
    flow1,
    flow2,
    // ...
    flow9,
    flow10,
) { value1, value2, /* ... */, value9, value10 ->
    // ...
}

Logging

badge-js badge-jvm badge-mac

Simple multiplatform logging API.

Initialization

Logging can be initialized via install:

Log.dispatcher.install(ConsoleLogger)

Custom loggers can be created by implementing the Logger interface.

Log

Log message can be logged via:

Log.verbose { "Example" }

The following log level functions are available:

Optional tag and throwable may be provided. tag defaults to an autogenerated value, but behavior can be customized via Log.tagGenerator property.

Functional

badge-js badge-jvm badge-mac

Utilities for manipulating functions. For a full functional ecosystem, complete with Monad and the like, prefer Arrow.

Temporal

badge-android badge-js badge-jvm

Toolbox of utilities for dates and times, building on KotlinX DateTime.

Various interval Flows are provided, such as: instantFlow, localDateTimeFlow, and localDateFlow. For example:

localDateTimeFlow().collect {
    println("The time is now: $it")
}

Note: Because this is built on top of KotlinX DateTime, core library desugaring must be enabled for Android targets.

Test

badge-js badge-jvm badge-mac

Utilities for test suites.

runTest

Multiplatform test analogy to runBlocking:

@Test
fun exampleUnitTest() = runTest {
    // ...
}

assertContains

assertContains(
    array = arrayOf(1, 2, 3),
    value = 2,
)
assertContains(
    range = 1..10,
    value = 5,
)

assertSimilar

assertSimilar(
    target = 5,
    epsilon = 1,
    value = 6,
)

Encoding

badge-js badge-jvm badge-mac

Utilities for working with binary data.

IntBitSet

val bitSet = 0.bits
bitSet[30] = true
bitSet.asPrimitive() // 1073741824
/* | Index | ... | 3 | 2 | 1 | 0 |
 * |-------|-----|---|---|---|---|
 * | Bit   | ... | 1 | 0 | 1 | 0 |
 */
val bitSet = 10.bits

bitSet[0] // false
bitSet[1] // true
bitSet[2] // false
bitSet[3] // true

LongBitSet

/* | Index | ... | 3 | 2 | 1 | 0 |
 * |-------|-----|---|---|---|---|
 * | Bit   | ... | 1 | 1 | 0 | 0 |
 */
val bitSet = 12L.bits

bitSet[0] // false
bitSet[1] // false
bitSet[2] // true
bitSet[3] // true
val bitSet = 0L.bits
bitSet[40] = true
bitSet.asPrimitive() // 1099511627776L

Setup

Gradle

Maven Central

Tuulbox can be configured via Gradle Kotlin DSL as follows:

Multiplatform

plugins {
    id("com.android.application") // or id("com.android.library")
    kotlin("multiplatform")
}

repositories {
    mavenCentral()
}

kotlin {
    jvm() // and/or android()
    js().browser() // and/or js().node()
    macosX64()

    sourceSets {
        val commonMain by getting {
            dependencies {
                implementation("com.juul.tuulbox:coroutines:$version")
                implementation("com.juul.tuulbox:logging:$version")
                implementation("com.juul.tuulbox:functional:$version")
                implementation("com.juul.tuulbox:temporal:$version")
                implementation("com.juul.tuulbox:encoding:$version")
            }
        }
        
        val commonTest by getting {
            dependencies {
                implementation("com.juul.tuulbox:test:$version")
            }
        }
    }
}

Platform-specific

repositories {
    mavenCentral()
}

dependencies {
    implementation("com.juul.tuulbox:coroutines:$version")
    implementation("com.juul.tuulbox:logging:$version")
    implementation("com.juul.tuulbox:functional:$version")
    implementation("com.juul.tuulbox:temporal:$version")
    implementation("com.juul.tuulbox:encoding:$version")
    testImplementation("com.juul.tuulbox:test:$version")
}

License

Copyright 2021 JUUL Labs, Inc.

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

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
com.juul.tuulbox

JUUL Labs

Versions

Version
4.1.0
4.0.1
4.0.0
3.2.0
3.1.1
3.1.0
3.0.0