{"id":16453137,"url":"https://github.com/italomaia/lua_table","last_synced_at":"2025-09-13T05:34:59.310Z","repository":{"id":66731785,"uuid":"174424477","full_name":"italomaia/lua_table","owner":"italomaia","description":"Set of useful lua functions for manipulating tables.  ","archived":false,"fork":false,"pushed_at":"2020-01-22T22:44:33.000Z","size":39,"stargazers_count":11,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T07:35:48.005Z","etag":null,"topics":["lua","manipulation","manipulation-methods","table"],"latest_commit_sha":null,"homepage":"https://italomaia.github.io/lua_table/","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/italomaia.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-07T21:41:02.000Z","updated_at":"2023-10-11T17:08:21.000Z","dependencies_parsed_at":"2023-04-21T07:58:49.858Z","dependency_job_id":null,"html_url":"https://github.com/italomaia/lua_table","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/italomaia/lua_table","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italomaia%2Flua_table","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italomaia%2Flua_table/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italomaia%2Flua_table/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italomaia%2Flua_table/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/italomaia","download_url":"https://codeload.github.com/italomaia/lua_table/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/italomaia%2Flua_table/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274920134,"owners_count":25373961,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-13T02:00:10.085Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lua","manipulation","manipulation-methods","table"],"created_at":"2024-10-11T10:14:46.772Z","updated_at":"2025-09-13T05:34:59.303Z","avatar_url":"https://github.com/italomaia.png","language":"Lua","readme":"*lua_table* is a friendly library to help you get more productive with Lua. It packs\ncommon operations over tables that might save you some coding in the long run.\n\n**compatibility:** lua5.3\n\n## Why?\n\n*lua_table* was created because I've not found a module that makes working\nwith `tables` more productive without adding to much to the stack. *lua_table*\nattempts to provide just enough with good compatibility with Lua standard modules.\n\n## Install\n\nluarocks install lua_table\n\n## Getting Started\n\n[Documentation](https://italomaia.github.io/lua_table/)\n\n*lua_table* usage is advised in one of the following ways:\n\n```\n-- as a module\nlocal ltable = require('lua_table')\n\n-- exteding table\nrequire('lua_table').patch(table, ltable)\n\n-- extending the environment\nrequire('lua_table').patch(_G, ltable)\n```\n\n## Examples\n\n```\nlocal ltable = require('lua_table')\nlocal append = ltable.append\nlocal copy = ltable.copy\nlocal distinct = ltable.distinct\nlocal keys = ltable.keys\nlocal same = ltable.same\nlocal flat = ltable.flat\nlocal foreach = ltable.foreach\nlocal proxy = ltable.proxy\nlocal immutable = ltable.immutable\nlocal join = ltable.join\nlocal merge = ltable.merge\nlocal set = ltable.set\nlocal patch = ltable.patch\nlocal slice = ltable.slice\nlocal sorted = ltable.sorted\nlocal union = ltable.union\nlocal values = ltable.values\n\n-- you can patch the table module with ltable, so all functions of ltable\n-- become available from table\n-- ltable.patch(table, ltable)\n\n-- you can also patch _G and make all functions available globally\n-- DON'T DO THIS FOR ANYTHING BUT SIMPLE SCRIPTS\n-- ltable.patch(_G, ltable)\n\nlocal a1, a2, a3 = {1, 2}, {3, 4}, {5, 6, 7}\nlocal t1, t2, t3 = {a=1}, {b=2, c=3}, {d=4, e=5, f=6}\n\n-- creates a new table with the items of a1 and a2\nassert(same(union(a1, a2), {1, 2, 3, 4}))\n\n-- creates a new table with the items of t1 and t2\nassert(same(union(t1, t2), {a=1, b=2, c=3}))\n\n-- distinct removes duplicate values\nassert(same(union(a1, a1), {1, 2, 1, 2}))\nassert(same(distinct(union(a1, a1)), {1, 2}))\n\n-- keys and values behavior\nassert(same(sorted(keys({a=1, b=2, c=3})), {'a', 'b', 'c'}))  -- keys\nassert(same(sorted(values({a=1, b=2, c=3})), {1, 2, 3}))  -- keys\nassert(same(keys(a2), {1, 2}))  -- values\nassert(same(values(a2), {3, 4}))  -- values\n\n-- create a immutable array (aka: tuple)\ntable.insert(immutable({5, 6, 7}), 8)  -- error\n\n-- set ignores repeated values\nlocal s1 = set({5, 6, 7})\ntable.insert(s1, 7)\ntable.insert(s1, 8)\nassert(\"#s1 == 4: \", #s1 == 4)\n\n-- checks if set contains value in O(1)\nassert(\"s1:has(8): \", s1:has(8))\nassert(\"s1:has(9): \", s1:has(9))\n\n-- flattens nested arrays\nassert(same(flat({1, 2, {3}}), {1, 2, 3}))\n\n-- retrives a slice of an array\nassert(same(slice({5, 6, 7, 8, 9, 10}, 1, 2), {5, 6}))\n\n-- merges and returns first table\nlocal m1, m2 = {a=1}, {b=2}\n\nassert(m1 == merge(m1, m2))  -- same instance\nassert(same(m1, {a=1, b=2}))  -- key/value pairs of m1 and m2\n\n-- join\nlocal j1, j2 = {a=1}, {b=2}\nlocal j3 = join(j1, j2)\nassert(j1 ~= j3)  -- join returns a new table\nassert(same(j3, {a=1, b=2}))  -- behavior similar to merge\n\n-- append is ideal to merge arrays\nlocal ap1, ap2 = {3, 4, 5}, {4, 5, 6}\nlocal ap3 = append(ap1, ap2)\nassert(ap3 == ap1)  -- append reuses the instance\nassert(same(ap3, {3, 4, 5, 4, 5, 6}))\n\n-- patch\nlocal p1, p2 = {a=1}, {b=2}\n\npatch(p1, p1)  -- raises an error on key collision\nassert(patch(p1, p2) == nil)  -- returns nil\nassert(same(p1, {a=1, b=2}))  -- behavior similar to merge\n\n-- sorted behaves like table.sort, but actually returns a new sorted array\nassert(same(sorted({3, 2, 1}), {1, 2, 3}))\n\n-- copy creates a new instance\nassert(copy({2, 3, 4}) ~= {2, 3, 4})\nassert(same(copy({2, 3, 4}), {2, 3, 4}))\n```\n\n## Functional Programming\n\nIf you need to add functional programming behavior to your program,\nbe sure to check the [lua_fun project](https://github.com/italomaia/lua_fun).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitalomaia%2Flua_table","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fitalomaia%2Flua_table","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fitalomaia%2Flua_table/lists"}