feat(iter): add Iter.take (#26525)

This commit is contained in:
Will Hopkins
2023-12-12 12:27:24 -08:00
committed by GitHub
parent 1907abb4c2
commit 69ffbb76c2
3 changed files with 81 additions and 0 deletions

View File

@@ -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.