def filter_for(mapper, filter_fn):
    """Filter records out during the mapping phase.

    Examples:
        >>> @dataclass
        ... class Foo:
        ...     id: int
        >>> items = [Foo(id=1), Foo(id=2), Foo(id=3)]

        Normally the mapper would be the thing that turns raw json into the above `items`
        >>> noop = lambda x: x

        >>> mapper = filter_for(noop, lambda r: r.id <= 2)
        >>> mapper(items)
        [Foo(id=1), Foo(id=2)]
    """

    def decorator(response):
        return list(filter(filter_fn, mapper(response)))

    return decorator