Filter chunks of data from an iterable or a chain

    :param function: callable selecting valid elements
    :type function: callable
    :param iterable: object providing chunks via iteration
    :type iterable: iterable or None

    For any chunk in ``iterable`` or the chain, it is passed on only if
    ``function(chunk)`` returns true.

    .. code::

        chain = iterlet(range(10)) >> filterlet(lambda chunk: chunk % 2 == 0)
        for value in chain:
            print(value)  # prints 0, 2, 4, 6, 8

def filterlet(function=bool, iterable=None):
    """
    Filter chunks of data from an iterable or a chain

    :param function: callable selecting valid elements
    :type function: callable
    :param iterable: object providing chunks via iteration
    :type iterable: iterable or None

    For any chunk in ``iterable`` or the chain, it is passed on only if
    ``function(chunk)`` returns true.

    .. code::

        chain = iterlet(range(10)) >> filterlet(lambda chunk: chunk % 2 == 0)
        for value in chain:
            print(value)  # prints 0, 2, 4, 6, 8
    """
    if iterable is None:
        return _filterlet(function=function)
    else:
        return iterlet(elem for elem in iterable if function(elem))