Skip to content

Commit

Permalink
simpleFilter to list wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
InsanusMokrassar committed Mar 19, 2022
1 parent 553da0a commit f6e819b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
*/
Expand Down

0 comments on commit f6e819b

Please sign in to comment.