diff --git a/README.md b/README.md index a3bd25c..81d09fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![Download](https://img.shields.io/badge/Download-1.0.0-%23007ec6)](https://search.maven.org/artifact/ch.tutteli.kbox/kbox/1.0.0/jar) +[![Download](https://img.shields.io/badge/Download-0.16.0-%23007ec6)](https://search.maven.org/artifact/ch.tutteli.kbox/kbox/0.16.0/jar) [![Apache license](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](http://opensource.org/licenses/Apache2.0) @@ -17,47 +17,50 @@ KBox is a very small but useful utility library for Kotlin (JVM, Android and JS). Current extension functions: -- [`Array/List/Iterable/Sequence.appendtoStringBuilder`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/appendToString.kt#L37) +- [`Array/List/Iterable/Sequence.appendtoStringBuilder`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/appendToString.kt#L37) with the ability to define a different separator for the last separation => handy if you want to form sentences like `a, b and c` -- [`CharSequence.blankToNull`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/blanktoNull.kt#L7) +- [`CharSequence.blankToNull`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/blanktoNull.kt#L7) returns the same `CharSequence` if not blank, `null` otherwise -- [`forEachIn(Array/Iterable/Sequence, Array/Iterable/Sequence, ..., action: (E) -> Unit)`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/forEachIn.kt#L6) +- [`forEachIn(Array/Iterable/Sequence, Array/Iterable/Sequence, ..., action: (E) -> Unit)`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/forEachIn.kt#L6) applies the given action to each entry in the given `Iterable`s. -- [` forElementAndEachIn(E, Array/Iterable/Sequence, action: (E) -> Unit)`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/forThisAndForEach.kt#L6) +- [` forElementAndEachIn(E, Array/Iterable/Sequence, action: (E) -> Unit)`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/forThisAndForEach.kt#L6) applies the given action to `this` and each entry in Iterable -- [`Iterable.forEachRemaining()`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/forEachRemaining.kt#L9) +- [`Iterable.forEachRemaining()`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/forEachRemaining.kt#L9) shortcut for `while(hasNext()) yourLambda(next())` -- [`Array/List.ifWithinBound`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/ifWithinBound.kt#L13) +- [`Array/List.ifWithinBound`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/ifWithinBound.kt#L13) shortcut for `if(index < size){ thenBlock() } else { elseBlock() }` -- [`CharSequence?.isNotNullAndNotEmpty/isNotNullAndNotBlank`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/isNotNullAndNot.kt#L6) +- [`CharSequence?.isNotNullAndNotEmpty/isNotNullAndNotBlank`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/isNotNullAndNot.kt#L6) -- [`Array/List/Iterable/Sequence.joinToString`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/joinToString.kt#L31) +- [`Array/List/Iterable/Sequence.joinToString`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/joinToString.kt#L31) with the ability to define a different separator for the last separation => handy if you want to form sentences like `a, b and c` -- [`Map.mapParents`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/mapParents.kt#L13) +- [`Map.mapParents`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/mapParents.kt#L13) maps child-parent relations. -- [`Iterator.mapRemaining/mapRemainingWithCounter`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/mapRemaining.kt#L9) - maps remaining entries with the help of a transform function (where `mapRemainingWithCounter` passes a counter variable to the transform function). +- [`Iterator.mapRemaining/mapRemainingWithCounter`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/mapRemaining.kt#L9) + maps remaining entries with the help of a transform function (where `mapRemainingWithCounter` passes a counter variable to the transform function). -- [`Array/Iterable/Sequence.mapWithIndex`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/mapWithIndex.kt#L11) +- [`Array/Iterable/Sequence.mapWithIndex`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/mapWithIndex.kt#L11) -- [`Iterator.toPeekingIterator()`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/PeekingIteratorUnsynchronized.kt) +- [`Sequence.dynamicTraversal`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/dynamicTraversal.kt#L34) + allows to iterator over a tree/graph like structure lazily + +- [`Iterator.toPeekingIterator()`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/PeekingIteratorUnsynchronized.kt) which allows to have a look what the next element is without consuming it. -- [`varargsToList/glue`](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/varargToList.kt#L11) +- [`varargsToList/glue`](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/varargToList.kt#L11) creates a `List` out of a single `E` and an `Array`. Moreover, the following function might come in handy for you as well: -- [identity](https://github.com/robstoll/kbox/tree/v1.0.0/src/commonMain/kotlin/ch/tutteli/kbox/identity.kt) +- [identity](https://github.com/robstoll/kbox/tree/main/src/commonMain/kotlin/ch/tutteli/kbox/identity.kt) # Installation @@ -66,7 +69,7 @@ KBox is published to maven central. ``` repositories { mavenCentral() } dependencies { - implementation("ch.tutteli.kbox:kbox-jvm:1.0.0") + implementation("ch.tutteli.kbox:kbox-jvm:0.16.0") } ``` diff --git a/build.gradle.kts b/build.gradle.kts index 95bbce2..dae0c7f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -7,7 +7,7 @@ import java.nio.file.StandardCopyOption buildscript { // needs to be defined in here because otherwise tutteli-publish plugin does not have this information when applied // and we want that it to apply the ch.tutteli conventions - rootProject.version = "1.0.0" + rootProject.version = "1.0.0-SNAPSHOT" rootProject.group = "ch.tutteli.kbox" rootProject.description = "A utility library for Kotlin " } diff --git a/docs/index.md b/docs/index.md index 4905e71..1e0c473 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1,4 +1,4 @@ -[![Download](https://img.shields.io/badge/Download-1.0.0-%23007ec6)](https://search.maven.org/artifact/ch.tutteli.kbox/kbox/1.0.0/jar) +[![Download](https://img.shields.io/badge/Download-0.16.0-%23007ec6)](https://search.maven.org/artifact/ch.tutteli.kbox/kbox/0.16.0/jar) [![Apache license](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg)](http://opensource.org/licenses/Apache2.0) # KBox @@ -11,7 +11,7 @@ KBox is published to maven central. ``` repositories { mavenCentral() } dependencies { - implementation("ch.tutteli.kbox:kbox:1.0.0") + implementation("ch.tutteli.kbox:kbox:0.16.0") } ``` diff --git a/src/commonMain/kotlin/ch/tutteli/kbox/blankToNull.kt b/src/commonMain/kotlin/ch/tutteli/kbox/blankToNull.kt index fbaf25c..f5ce803 100644 --- a/src/commonMain/kotlin/ch/tutteli/kbox/blankToNull.kt +++ b/src/commonMain/kotlin/ch/tutteli/kbox/blankToNull.kt @@ -4,4 +4,4 @@ package ch.tutteli.kbox * Returns this [CharSequence] if it is not blank, null otherwise. */ @Suppress("NOTHING_TO_INLINE") -inline fun T.blankToNull(): T? = if(this.isNotBlank()) this else null +inline fun T.blankToNull(): T? = this.ifBlank { null } diff --git a/src/commonMain/kotlin/ch/tutteli/kbox/dynamicTraversal.kt b/src/commonMain/kotlin/ch/tutteli/kbox/dynamicTraversal.kt index 8275698..bf54c8c 100644 --- a/src/commonMain/kotlin/ch/tutteli/kbox/dynamicTraversal.kt +++ b/src/commonMain/kotlin/ch/tutteli/kbox/dynamicTraversal.kt @@ -27,7 +27,7 @@ import kotlin.jvm.JvmName * @param loadElements the function returning the children of a given element in case of a tree / the connected nodes * in case of a graph. * - * @since 1.1.0 + * @since 1.0.0 */ @OptIn(ExperimentalTypeInference::class) @OverloadResolutionByLambdaReturnType @@ -76,7 +76,7 @@ fun Sequence.dynamicTraversal( * @param loadElements the function returning the children of a given element in case of a tree / the connected nodes * in case of a graph. * - * @since 1.1.0 + * @since 1.0.0 */ @OptIn(ExperimentalTypeInference::class) @OverloadResolutionByLambdaReturnType @@ -107,14 +107,14 @@ fun Sequence.dynamicTraversal( /** * Represents the option to which traversal algorithm shall be applied. * - * @since 1.1.0 + * @since 1.0.0 */ enum class TraversalAlgorithmOption { /** Taking the tree as example, the resulting sequence contains the result in a breath first manner, * i.e. if `dropRoots = false` then the elements of the original sequence are returned first (if `dropRoots] = true` * then they are skipped/dropped), then the children of those elements, then the children of the children and so on. * - * @since 1.1.0 + * @since 1.0.0 */ BreadthFirst, @@ -126,7 +126,7 @@ enum class TraversalAlgorithmOption { * Once there is no first child (i.e. we reached a leaf of the tree) the sibling of this child is visited, and again * the first child of this sibling etc. * - * @since 1.1.0 + * @since 1.0.0 */ DepthFirst } diff --git a/src/commonTest/kotlin/ch/tutteli/kbox/BlankToNullSpec.kt b/src/commonTest/kotlin/ch/tutteli/kbox/BlankToNullSpec.kt index 67ceb31..d92ea17 100644 --- a/src/commonTest/kotlin/ch/tutteli/kbox/BlankToNullSpec.kt +++ b/src/commonTest/kotlin/ch/tutteli/kbox/BlankToNullSpec.kt @@ -5,9 +5,6 @@ import ch.tutteli.kbox.atrium.expect import org.spekframework.spek2.Spek import org.spekframework.spek2.style.specification.describe -/** - * asdf - */ object BlankToNullSpec : Spek({ describe("fun ${String::blankToNull.name}") {