File: _all.py

package info (click to toggle)
python-rx 4.0.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,056 kB
  • sloc: python: 39,070; javascript: 77; makefile: 24
file content (24 lines) | stat: -rw-r--r-- 497 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from typing import Callable, TypeVar

from reactivex import Observable, compose
from reactivex import operators as ops
from reactivex.typing import Predicate

_T = TypeVar("_T")


def all_(predicate: Predicate[_T]) -> Callable[[Observable[_T]], Observable[bool]]:
    def filter(v: _T):
        return not predicate(v)

    def mapping(b: bool) -> bool:
        return not b

    return compose(
        ops.filter(filter),
        ops.some(),
        ops.map(mapping),
    )


__all__ = ["all_"]