About
Iter
is a module which allows you to create lazy iterators which can be used to simplify various tasks (such as filtering, mapping a list of Item
s), which usually require a lot of code and looks messy.
Insight
Each Iter
object has two types of functions, Iterator
functions and Consumer
functions.
Iterator
functions are functions which return another Iter
object as output. A few examples are Map
, Filter
, Take
etc.
Consumer
functions don’t return an Iter
object, hence consuming
the Iterator.
A few examples for consumer functions are ForEach
, Find
, Position
etc.
Features
-
Iter
allows you to perform method chaining.
Example:
local IsEven = function(x) return (x % 2 == 0); end;
Iterator.Iota()
:Filter(IsEven) --// Filters the odd numbers out
:Take(5) --// Takes 5 elements from the beginning
:ForEach(print) --// Prints all the items out (2, 4, 6, 8, 10)
-
Iter
is fast, thanks to native code generation
Documentation
Documentation for each of the functions can be found above each function definition in the module itself, along with example code.
If you are using external tools (such as Rojo and VSCode) to script your games, documentation for that method is automatically provided.
Since the module is typed, It provides auto-completion for all methods and properties.
Issues
If you encounter any issues with the module, feel free to create an issue at the Github page. Alternatively, you could create a pull request for an issue, which will later be merged to the main branch and released.