🗐 QuickList - Making Lua tables better

Very cool, i’ve always hated roblox’s table system
I’ll try this out later!

1 Like

v1.0.2.1

This is a sub-fix and not a full release but I have updated the source on github and the ModuleScript. (Not the github releases)

  • Added the ability to remove things in the table using the object/string itself.
  • added self.setEach(func) which takes in a function call back and calls func(i,v) and the returned value each iteration is set to the current value. (I didn’t add this in the module yet)
local myTable = _{'hi', 'bye'}
myTable.setEach(function(i, v)
    if v == 'hi' then
        return 'good'
    end
    return v
end)
print(myTable) -- prints {good, bye}

Very cool and useful plugin with a lot of potential!
However you might want to consider using self[#self + 1] = value for the .append function as I heard it is faster.

Edit: Forgot to mention .insert but you should do the same thing with it

1 Like

Huh, I never thought it was faster. I’m using table.insert(pos, value) for appending and same for inserting. I don’t know how fast both are but if someone could benchmark it that would be useful. Insert just automatically pushes everything forward so I don’t really care much though.

Also it’s not a plugin lol its just a module. (joke)
Thanks :+1:

Just to clarify, this module makes lists better, not quicker? Why is it called QuickList then? It’s impossible to make lists faster than normal luau lists because you need to use them to do that.

QuickList now works with CactusBase 2

Can I use this with QuickList?

Yes, setting data is possible using my QuickList class. Unfortunately, the data returned from GetAsync() is a dictionary and you’ll have to re-convert the returned data into a quicklist. It’s as simple as doing _( data ). Also I don’t suggest using arrays as it’s cleaner using dictionaries.

Go check out CactusBase 2 as well.

2 Likes

The reason I called it QuickList was because BetterTable was already taken, and also the fact that these only work for the array side of things.
I doubt these run faster than table and table methods themselves. Probably because I’m using the table functions to work with tables. There’s no way around that in Luau and I don’t have enough freedom or knowledge to make these faster. Suggestions to make things faster and better are always appreciated.

QuickList just reduces the amount of lines needed for the same functionality and let’s you use self and table objects rather than doing table.method(table, args).

2 Likes

It’s not really faster by a lot (I used a for i = 1, 10000000 loop) , but it’s still faster. However do whatever you think looks better (code-wise) for you, since no one is going to use the methods 10,000,000 times simultaneously lol
image

2 Likes

Cool module, but if someone isnt a fan of OOP I can highly recommend Sift which adds a lot of the same functionality QL adds but using the functional paradigm

1 Like

Honestly the entire point of QuickList is that it’s based on OOP.
You could just use the normal table.method(table, args) library and work normally. But mine provides OOP and more functionality, it’s pretty much a wrapper over the normal one.

3 Likes

after testing around with it for a while i found out that string indexing isnt supported most likely due to tonumber(key) in the __index function of the metatable

Yeah so in the latest update (check github) I think I added string indexing. If not then you’ll have to wait.

v1.0.3

A lot of new changes!

  • Autocomplete now works better and you can see all the functions of the QuickList table
  • Chaining also supports autocomplete
  • Added setEach(function(i, v))
  • Module code was revamped and is slightly easier to look around.
  • Removed as many warnings as possible in the Roblox code editor.
  • .new() method assert text was changed. (“Nil, table or QuickList must be provided.”)
  • get_dictionary() was renamed to get_table()

Big change

Quicklist now has “support” for dictionaries. The only thing that works in it is

  • Creating dictionaries using
local _ = require('QuickLIst')
_{
    hello = 'world'
    test = {
        foo = 'bar'
    }
}
  • Remove a key-value pair from a dictionary. table.remove(key:string)
  • Printing/tostring dictionaries + arrays change.

Thanks @Cookibot on github for helping me with some stuff such as the autocomplete and forking the repo.

Speaking of dictionaries, I don’t know if I should keep support for them or get rid of support entirely.

Give ideas on what I could add though. remove(key_name) is the only known supported function as of now.

You should adopt the JavaScript approach and make dictionaries a separate thing. In JavaScript you have three “table-like” classes: Object, Array, and Map (Set not included*) They’re done this way because some methods may only apply nicely to arrays and not dictionaries/maps. They seemingly are the same while also being vastly different at the same time. It is worth noting a Map should be able to be converted into an Array and keep its data.

Object is the closest relative to Lua tables, but iterator functions have to pretty much be pre-defined and they always feel inferior to use over the other two.

Yup, I wanted to make it as seemless as possible (somewhat). And making different objects would make it slightly annoying to work with.

Mostly because it would be annoying to keep everything in a single module, and using it outside of Roblox would be slightly harder.

Also the fact that everything (arrays, dictionaries, maps) is a table in lua would be a bit annoying.

I wouldn’t be focusing on dictionaries at all but I wanted to try it. QuickList is still 90% for arrays though.

One more thing I wanted to address was sending ql objects through remote events.
Just use ql.get_table() as the argument, and remake the QuickList after in the connection.

Client (LocalScript)

local RemoteEvent = game.ReplicatedStorage.RE
local _ = require('QuickList')

local myTable = {"Hello", "World"}
RemoteEvent:FireServer(myTable.get_table()) -- Convert QuickList into a table

Server (Script)

local RemoteEvent = game.ReplicatedStorage.RE
local _ = require('QuickList')

RemoteEvent.OnServerEvent:Connect(function(player, myTable)
    local QL_myTable = _(myTable) -- Convert the table into a quicklist
    print(QL_myTable)
end)
1 Like

Another update!

  • I will change the __tostring() method and fix it to actually work better for dictionaries.
  • Added removeIf(func)
myTable.removeIf(function(i, v)
    if v == "hi" then
        return 1
    end
    return false
end)

If the function returns a true-type value then it will delete the instance, it loops through the entire list and returns a copy of it.

hey there, sorry for bumping but you should definetly add this to wally

1 Like

Good idea, and thanks.

Wally Integration

You can now use the Wally package manager to install quicklist.

Steps

  • initialize wally using wally init
  • in the wally.toml file, add this:
quicklist = "creepersaur/quicklist@^1.0"
  • run wally install

You’ll have installed quicklist. (Version number may vary, github may still have the latest version.)