Skip to content

Simple collections class for Lua inspired by Laravel's collections.

License

Notifications You must be signed in to change notification settings

prnxdev/mta-lua-collections

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

MTA Lua collections

That simple class allows you to manipulate tables easier in Lua. Here's little example how powerfull this tool is.

local productsCollection = Collection()

productsCollection:push({name = "Milk", is_liquid = true})
  :push({name = "Orange juice", is_liquid = true})
  :push({name = "Hamburger", is_liquid = false})
  
--- now we wants only non liquid products so we will use 'where' method
--- and 'forEach' to output all elements from new table

productsCollection:where('is_liquid', false):forEach(function(product)
  outputConsole(product.name)
end)

--- and we get only 'Hamburger' because only this product
--- has variable 'is_liquid' set on false

Feel free to use and fork. I'm waiting for suggestions and also PRs :). Now here's only small example how you can use this class. Soon I will update this README and ofc. I will add more methods.

About

Simple collections class for Lua inspired by Laravel's collections.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages