8484local packedmt = {}
8585
8686local function unpack (t )
87- if type (t ) == ' table' and getmetatable (t ) == packedmt then
87+ if type (t ) == " table" and getmetatable (t ) == packedmt then
8888 return _G .unpack (t , 1 , t .n )
8989 end
9090 return t
9191end
9292
9393local function pack (...)
94- local n = select (' # ' , ... )
94+ local n = select (" # " , ... )
9595 if n > 1 then
9696 return setmetatable ({ n = n , ... }, packedmt )
9797 end
9898 return ...
9999end
100100
101101local function sanitize (t )
102- if type (t ) == ' table' and getmetatable (t ) == packedmt then
102+ if type (t ) == " table" and getmetatable (t ) == packedmt then
103103 -- Remove length tag
104104 t .n = nil
105105 end
448448---
449449--- @return Iter
450450function Iter .rev (self )
451- error (' rev() requires a list-like table' )
451+ error (" rev() requires a list-like table" )
452452 return self
453453end
454454
479479---
480480--- @return any
481481function Iter .peek (self ) -- luacheck: no unused args
482- error (' peek() requires a list-like table' )
482+ error (" peek() requires a list-like table" )
483483end
484484
485485--- @private
513513---
514514--- @return any
515515function Iter .find (self , f )
516- if type (f ) ~= ' function' then
516+ if type (f ) ~= " function" then
517517 local val = f
518518 f = function (v )
519519 return v == val
@@ -560,12 +560,12 @@ end
560560---
561561--- @return any
562562function Iter .rfind (self , f ) -- luacheck: no unused args
563- error (' rfind() requires a list-like table' )
563+ error (" rfind() requires a list-like table" )
564564end
565565
566566--- @private
567567function ListIter .rfind (self , f ) -- luacheck: no unused args
568- if type (f ) ~= ' function' then
568+ if type (f ) ~= " function" then
569569 local val = f
570570 f = function (v )
571571 return v == val
599599---
600600--- @return any
601601function Iter .nextback (self ) -- luacheck: no unused args
602- error (' nextback() requires a list-like table' )
602+ error (" nextback() requires a list-like table" )
603603end
604604
605605function ListIter .nextback (self )
628628---
629629--- @return any
630630function Iter .peekback (self ) -- luacheck: no unused args
631- error (' peekback() requires a list-like table' )
631+ error (" peekback() requires a list-like table" )
632632end
633633
634634function ListIter .peekback (self )
686686--- @param n number Number of values to skip.
687687--- @return Iter
688688function Iter .skipback (self , n ) -- luacheck: no unused args
689- error (' skipback() requires a list-like table' )
689+ error (" skipback() requires a list-like table" )
690690 return self
691691end
692692
760760--- @param last number
761761--- @return Iter
762762function Iter .slice (self , first , last ) -- luacheck: no unused args
763- error (' slice() requires a list-like table' )
763+ error (" slice() requires a list-like table" )
764764 return self
765765end
766766
909909--- @private
910910function Iter .new (src , ...)
911911 local it = {}
912- if type (src ) == ' table' then
912+ if type (src ) == " table" then
913913 local mt = getmetatable (src )
914- if mt and type (mt .__call ) == ' function' then
914+ if mt and type (mt .__call ) == " function" then
915915 --- @private
916916 function it .next ()
917917 return src ()
@@ -937,7 +937,7 @@ function Iter.new(src, ...)
937937 return ListIter .new (t )
938938 end
939939
940- if type (src ) == ' function' then
940+ if type (src ) == " function" then
941941 local s , var = ...
942942
943943 --- Use a closure to handle var args returned from iterator
@@ -957,7 +957,7 @@ function Iter.new(src, ...)
957957
958958 setmetatable (it , Iter )
959959 else
960- error (' src must be a table or function' )
960+ error (" src must be a table or function" )
961961 end
962962 return it
963963end
0 commit comments