Library with useful methods to handle Lua's table when it's working as a Hash.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
.travis.yml
Hash.lua
README.md
hash-1.0.1-0.rockspec
test.lua

README.md

Hash.lua

Library with useful methods to handle Lua's table when it's working as a Hash.

Build Status

Installation

To install Hash.lua, run:

$ luarocks install hash

Or simply copy the Hash.lua file and paste in your project :)

Methods

  • Hash.copy(object:table):table
    Makes a shallow copy of the table passed by parameter.

  • Hash.deep_copy(object:table):table
    Makes a deep copy of the table passed by parameter.

  • Hash.each(object:table, callback:function):nil
    Iterates over a table, yielding each in turn to an iteratee function.

  • Hash.is_empty(object:table):boolean
    Checks if the table is empty.

  • Hash.is_hash(object:table):boolean
    Checks if the table is a Hash.

  • Hash.keys(object:table):table
    Returns a new table populated with the all keys from the table passed as parameter.

  • Hash.map(object:table, [callback:function]):table
    Returns a new table of values by mapping each value in table through a transformation function.

  • Hash.merge(object1:table, object2:table):table
    Returns a new table containing the contents of object1 and object2.

  • Hash.pick(object:table, [keys:table|callback:function]):table
    Returns a new table filtered only with values for the keys passed by parameter. Alternatively it accepts a callback where you can filter which keys to pick.

  • Hash.remove_key(object:table, key:string):boolean
    Removes the key from the table; returns true if it was found and removed, otherwise it returns false.

  • Hash.values(object:table):table
    Returns a new table populated with the all values from the table passed as paramter.