aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorJD <46619169+rudiejd@users.noreply.github.com>2024-01-10 21:57:51 -0500
committerGitHub <noreply@github.com>2024-01-10 20:57:51 -0600
commita767c046f4e6bff1412269d56a8edfe33857d954 (patch)
treea5a1d12f9d17118b268e135340e3c35260cab6a2 /runtime/doc
parenta7550a20e0c3084eacd2b4ede1e6a94f282c2fb8 (diff)
downloadrneovim-a767c046f4e6bff1412269d56a8edfe33857d954.tar.gz
rneovim-a767c046f4e6bff1412269d56a8edfe33857d954.tar.bz2
rneovim-a767c046f4e6bff1412269d56a8edfe33857d954.zip
feat(vim.iter): add Iter:flatten (#26786)
Co-authored-by: Gregory Anders <greg@gpanders.com> Co-authored-by: Jongwook Choi <wookayin@gmail.com>
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/lua.txt22
1 files changed, 22 insertions, 0 deletions
diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt
index 1bae1a43d4..b558a3fc8d 100644
--- a/runtime/doc/lua.txt
+++ b/runtime/doc/lua.txt
@@ -3431,6 +3431,28 @@ Iter:find({f}) *Iter:find()*
Return: ~
any
+Iter:flatten({depth}) *Iter:flatten()*
+ Flattens a |list-iterator|, un-nesting nested values up to the given
+ {depth}. Errors if it attempts to flatten a dict-like value.
+
+ Examples: >lua
+ vim.iter({ 1, { 2 }, { { 3 } } }):flatten():totable()
+ -- { 1, 2, { 3 } }
+
+ vim.iter({1, { { a = 2 } }, { 3 } }):flatten():totable()
+ -- { 1, { a = 2 }, 3 }
+
+ vim.iter({ 1, { { a = 2 } }, { 3 } }):flatten(math.huge):totable()
+ -- error: attempt to flatten a dict-like table
+<
+
+ Parameters: ~
+ • {depth} (number|nil) Depth to which |list-iterator| should be
+ flattened (defaults to 1)
+
+ Return: ~
+ Iter
+
Iter:fold({init}, {f}) *Iter:fold()*
Folds ("reduces") an iterator into a single value.