Skip to content

Commit

Permalink
fix!: remove i,j params in unpack
Browse files Browse the repository at this point in the history
These are less efficient thatn :limit():skip() and could cause an infinite stream to block forever
  • Loading branch information
aarondill committed Feb 23, 2024
1 parent ae71bee commit f299dbb
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lua/stream/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -364,11 +364,12 @@ function Stream:join(delim)
end

--- Returns each element of this stream
---@param i? integer
---@param j? integer
--- Note: to use unpack(s, i, j), call stream:limit(j):skip(i):unpack()
---@return ...: the stream elements
function Stream:unpack(i, j)
return unpack(self:toarray(), i, j)
--- NOTE: unpack has an inherent limit on the number of elements it can return
--- (around 255). If you need more, use :toarray instead!
function Stream:unpack()
return unpack(self:toarray())
end

-- Returns the count of elements in this stream.
Expand Down

0 comments on commit f299dbb

Please sign in to comment.