[fleet] replace takeTillFirst with takeUntilInclusive

GitOrigin-RevId: 21b9bbbdfbfd10d3b2508f286282d77769442a7e
This commit is contained in:
Alexander Zolotov
2025-10-07 14:53:16 +02:00
committed by intellij-monorepo-bot
parent 635cb95299
commit 71ec005d4e

View File

@@ -1,9 +1,6 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package fleet.util
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.transformWhile
/**
* Same idea as [kotlin.collections.singleOrNull] but will throw if the collection contains more than one element.
* */
@@ -35,13 +32,6 @@ inline fun <T> Iterable<T>.singleOrNullOrThrowWithMessage(errorMessage: () -> St
return single
}
inline fun <T> Flow<T>.takeTillFirst(crossinline predicate: (T) -> Boolean): Flow<T> {
return this@takeTillFirst.transformWhile {
emit(it)
!predicate(it)
}
}
inline fun <T> Iterable<T>.takeTillFirst(crossinline predicate: (T) -> Boolean): Iterable<T> {
val list = ArrayList<T>()
for (item in this) {