From 69ffbb76c237fcbba24de80f1b5346d92642e800 Mon Sep 17 00:00:00 2001 From: Will Hopkins Date: Tue, 12 Dec 2023 12:27:24 -0800 Subject: feat(iter): add `Iter.take` (#26525) --- runtime/doc/lua.txt | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'runtime/doc') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index f7f722bc0e..7e0ad5f4c3 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -3639,6 +3639,25 @@ Iter:slice({first}, {last}) *Iter:slice()* Return: ~ Iter +Iter:take({n}) *Iter:take()* + Transforms an iterator to yield only the first n values. + + Example: >lua + local it = vim.iter({ 1, 2, 3, 4 }):take(2) + it:next() + -- 1 + it:next() + -- 2 + it:next() + -- nil +< + + Parameters: ~ + • {n} (integer) + + Return: ~ + Iter + Iter:totable() *Iter:totable()* Collect the iterator into a table. -- cgit