aioplus.ahead

aioplus.ahead(aiterable, /, *, n)

Return the first n items of the aiterable.

Parameters:
  • aiterable (AsyncIterable[T]) – An asynchronous iterable to retrieve items from.

  • n (SupportsIndex) – The number of items to retrieve from the start.

Returns:

An asynchronous iterable yielding the first n items of the aiterable.

Return type:

AsyncIterable[T]

Examples

>>> import asyncio
>>>
>>> from aioplus import ahead, arange
>>>
>>> async def main() -> None:
>>>     '''Run the program.'''
>>>     async for num in ahead(arange(23), n=4):
>>>         print(num)
>>>
>>> if __name__ == '__main__':
>>>     asyncio.run(main())