aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorJosh <[email protected]>2020-12-04 09:32:53 +1000
committerGitHub <[email protected]>2020-12-03 18:32:53 -0500
commitf8e428bd5b01fb86032d727a7e8b10e3048b5fcf (patch)
tree0364361f37d876bd0325b86e18fc1368c94ced58 /docs
parentUpdate documentation for rules/updates channels (diff)
downloaddiscord.py-f8e428bd5b01fb86032d727a7e8b10e3048b5fcf.tar.xz
discord.py-f8e428bd5b01fb86032d727a7e8b10e3048b5fcf.zip
Add support for chunking AsyncIterator objects
Diffstat (limited to 'docs')
-rw-r--r--docs/api.rst20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/api.rst b/docs/api.rst
index 6790f395..892e175e 100644
--- a/docs/api.rst
+++ b/docs/api.rst
@@ -2085,6 +2085,26 @@ Certain utilities make working with async iterators easier, detailed below.
:return: A list of every element in the async iterator.
:rtype: list
+ .. method:: chunk(max_size)
+
+ Collects items into chunks of up to a given maximum size.
+ Another :class:`AsyncIterator` is returned which collects items into
+ :class:`list`\s of a given size. The maximum chunk size must be a positive integer.
+
+ .. versionadded:: 1.6
+
+ Collecting groups of users: ::
+
+ async for leader, *users in reaction.users().chunk(3):
+ ...
+
+ .. warning::
+
+ The last chunk collected may not be as large as ``max_size``.
+
+ :param max_size: The size of individual chunks.
+ :rtype: :class:`AsyncIterator`
+
.. method:: map(func)
This is similar to the built-in :func:`map <py:map>` function. Another