How to use the aioitertools.builtins.enumerate function in aioitertools

To help you get started, we’ve selected a few aioitertools examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jreese / aioitertools / aioitertools / itertools.py View on Github external
raise ValueError("must pass stop index")
    if len(args) == 1:
        stop, = args
    elif len(args) == 2:
        start, stop = args  # type: ignore
    elif len(args) == 3:
        start, stop, step = args  # type: ignore
    else:
        raise ValueError("too many arguments given")
    assert start >= 0 and (stop is None or stop >= 0) and step >= 0
    step = max(1, step)

    if stop == 0:
        return

    async for index, item in enumerate(itr):
        if index >= start and (index - start) % step == 0:
            yield item
        if stop is not None and index + 1 >= stop:
            break