mirror of
https://github.com/InsanusMokrassar/TelegramBotAPI.git
synced 2024-12-22 16:47:13 +00:00
simpleFilter to list wrapper
This commit is contained in:
parent
553da0a3ee
commit
f6e819be62
@ -9,6 +9,10 @@
|
||||
* `Ktor`: `1.6.7` -> `1.6.8`
|
||||
* `BehaviourBuilder`:
|
||||
* Fixes in `onMediaGroup` and dependent functions
|
||||
* Add several new extensions for `SimpleFilter`:
|
||||
* `SimpleFilter#listAll`
|
||||
* `SimpleFilter#listAny`
|
||||
* `SimpleFilter#listNone`
|
||||
|
||||
## 0.38.7
|
||||
|
||||
|
@ -4,6 +4,27 @@ typealias SimpleFilter<T> = suspend (T) -> Boolean
|
||||
|
||||
inline fun <T> SimpleFilter(noinline block: SimpleFilter<T>) = block
|
||||
|
||||
/**
|
||||
* @return [SimpleFilter] which will return true in case when all the items in incoming data passed [this] filter
|
||||
*/
|
||||
fun <T> SimpleFilter<T>.listAll() = SimpleFilter<Iterable<T>> {
|
||||
it.all { this@listAll(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* @return [SimpleFilter] which will return true in case when there is any item in incoming data passed [this] filter
|
||||
*/
|
||||
fun <T> SimpleFilter<T>.listAny() = SimpleFilter<Iterable<T>> {
|
||||
it.any { this@listAny(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* @return [SimpleFilter] which will return true in case when there is no any item in incoming data passed [this] filter
|
||||
*/
|
||||
fun <T> SimpleFilter<T>.listNone() = SimpleFilter<Iterable<T>> {
|
||||
it.none { this@listNone(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an AND (&&) operation between [this] and [other]
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user