vim.IterArray
Methods33
function IterArray.__call(self) -> any
function IterArray.filter(f: fun(v: V1, ...: ...V) -> boolean) -> vim.IterArray<V1, ...V>
@nodoc
function IterArray.flatten(depth: nil | integer) -> vim.IterArray<V1, ...V>
Flattens a |list-iterator|, un-nesting nested values up to the given {depth}. Errors if it attempts to flatten a dict-like value.
Examples:
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
depthnil | integerDepth to which |list-iterator| should be flattened (defaults to 1)
- vim.IterArray<V1, ...V>
@since 12
function IterArray.map<K1, K>(f: fun(v: V1, ...: ...V) -> ...K1) -> vim.IterArray<K1, ...K>
@nodoc
function IterArray.totable() -> any[]
function IterArray.totable(self: any) -> T[]function IterArray.totable(self: vim.IterArray<V1, V2, ...V>) -> (V1, V2, ...V)[]@nodoc
function IterArray.fold<A>(init: A, f: fun(acc: A, v: V1, ...: ...V) -> A) -> A
@nodoc
function IterArray.rev() -> vim.IterArray<V1, ...V>
Reverses a |list-iterator| pipeline.
Example:
local it = vim.iter({ 3, 6, 9, 12 }):rev()
it:totable()
-- { 12, 9, 6, 3 }
@since 12
function IterArray.rfind(f: V1 | fun(v: V1, ...: ...V) -> boolean) -> (V1 | nil, ...V)
Gets the first value satisfying a predicate, from the end of a |list-iterator|.
Advances the iterator. Returns nil and drains the iterator if no value is found.
Examples:
local it = vim.iter({ 1, 2, 3, 2, 1 }):enumerate()
it:rfind(1)
-- 5 1
it:rfind(1)
-- 1 1
|Iter:find()|
@since 12
function IterArray.pop() -> (V1 | nil, ...V)
"Pops" a value from a |list-iterator| (gets the last value and decrements the tail).
Example:
local it = vim.iter({1, 2, 3, 4})
it:pop()
-- 4
it:pop()
-- 3
@since 12
function IterArray.rpeek() -> (V1 | nil, ...V)
Gets the last value of a |list-iterator| without consuming it.
Example:
local it = vim.iter({1, 2, 3, 4})
it:rpeek()
-- 4
it:rpeek()
-- 4
it:pop()
-- 4
|Iter:last()|
@since 12
function IterArray.rskip(n: integer) -> vim.IterArray<V1, ...V>
Discards n values from the end of a |list-iterator| pipeline.
Example:
local it = vim.iter({ 1, 2, 3, 4, 5 }):rskip(2)
it:next()
-- 1
it:pop()
-- 3
@since 12
function IterArray.slice(first: integer, last: integer) -> vim.IterArray<V1, ...V>
Sets the start and end of a |list-iterator| pipeline.
Equivalent to :skip(first - 1):rskip(len - last + 1).
@since 12
function IterArray.count() -> integer
@nodoc
function IterArray.count(self: any) -> integer
function IterArray.enumerate(self: any) -> any
function IterArray.filter(self: any, f: fun(...) -> boolean) -> any
function IterArray.find(self: any, f: any) -> any
function IterArray.flatten(self: any, depth: nil | integer) -> any
function IterArray.fold(self: any, init: any, f: fun(acc: any, ...) -> any) -> any
function IterArray.last(self: any) -> any
function IterArray.map(self: any, f: fun(...) -> unknown) -> any
function IterArray.next(self: any) -> any
function IterArray.peek(self: any) -> any
function IterArray.pop(self: any) -> any
function IterArray.rev(self: any) -> any
function IterArray.rfind(self: any, f: any) -> any
function IterArray.rpeek(self: any) -> any
function IterArray.rskip(self: any, n: integer) -> any
function IterArray.skip(self: any, n: integer | fun(...) -> boolean) -> any
function IterArray.slice(self: any, first: integer, last: integer) -> any
function IterArray.take(self: any, n: integer | fun(...) -> boolean) -> any
function IterArray.totable(self: any) -> table
function IterArray.unique(self: any, key: fun(...) -> any | nil) -> any
Fields1
IterArray.__index : vim.IterArray