gvre / lua-gtable

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lua-gtable

A small helper library about tables (WIP).

Installation

Copy the file src/gtable.lua to your project.

Methods

  • gtable.merge(object:table, object:table):object:table
    Merges the two tables and returns a new one

  • gtable.prepend(object:table, object:table):object:table
    Prepends the values of the second table to the first one

  • gtable.append(object:table, object:table):object:table
    Appends the values of the second table to the first one

  • gtable.is_table(object:table):boolean
    Checks if the given parameter is a table

  • gtable.is_empty(object:table):boolean
    Checks if the given parameter is an empty table

  • gtable.key_exists(object:table, key:string):boolean
    Checks if the given parameter exists as a key in the given table

  • gtable.find(object:table, v, start:int):int|boolean
    Searches the table for a given value and returns the first corresponding key if successful

  • gtable.reverse(object:table):object:table
    Reverses the table

  • gtable.filter(object:table, callback:function):object:table
    Returns a new table with all values that pass the callback filter function

  • gtable.filter_map(object:table, callback:function):object:table
    Returns a new table with all keys and values that pass the callback filter function

Testing

Run make to lint and test the code (you need luacheck and luaunit)

About

License:MIT License


Languages

Language:Lua 98.6%Language:Makefile 1.4%