{"id":24987683,"url":"https://github.com/soniex2/loadx","last_synced_at":"2025-09-10T04:39:36.865Z","repository":{"id":150583920,"uuid":"43750636","full_name":"SoniEx2/loadx","owner":"SoniEx2","description":"loadx is a Lua module which provides a better load().","archived":false,"fork":false,"pushed_at":"2015-10-06T23:15:18.000Z","size":160,"stargazers_count":6,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T19:37:29.014Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SoniEx2.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-10-06T12:57:18.000Z","updated_at":"2021-03-13T20:13:54.000Z","dependencies_parsed_at":"2023-04-09T03:54:12.695Z","dependency_job_id":null,"html_url":"https://github.com/SoniEx2/loadx","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoniEx2%2Floadx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoniEx2%2Floadx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoniEx2%2Floadx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SoniEx2%2Floadx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SoniEx2","download_url":"https://codeload.github.com/SoniEx2/loadx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248497902,"owners_count":21113982,"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","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":[],"created_at":"2025-02-04T11:48:34.076Z","updated_at":"2025-04-11T23:41:29.468Z","avatar_url":"https://github.com/SoniEx2.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# loadx\nloadx is a Lua module which provides a better load().\n\n# Usage\n\nThis module provides the following functions:\n\n### `loadx(chunk,  [, chunkname [, mode [, upvalues...]]])`\n\nLoads a chunk.\n\nThis function is similar to Lua's native `load`, and has the following differences:\n\nIf the resulting function has upvalues, the upvalues are set to the values of `upvalues`,\nif that parameter is given. The first upvalue, if not given, is set to the global environment.\n(When you load a main chunk, the resulting function will always have exactly one upvalue,\nthe `_ENV` variable. However, when you load a binary chunk created from a function (e.g.\n`string.dump`), the resulting function can have an arbitrary number of upvalues.)\n\nSee the native `load` for the definitions of `chunk`, `chunkname` and `mode`.\n\nAll caveats from the native `load` may apply.\n\nSee also:\n\n- `load`:\n[Lua 5.2](http://www.lua.org/manual/5.2/manual.html#pdf-load),\n[Lua 5.3](http://www.lua.org/manual/5.3/manual.html#pdf-load).\n- `string.dump`:\n[Lua 5.2](http://www.lua.org/manual/5.2/manual.html#pdf-string.dump),\n[Lua 5.3](http://www.lua.org/manual/5.3/manual.html#pdf-string.dump).\n\n### `newupval()`\n\nCreates an upvalue object.\n\nUpvalue objects can be passed to loadx() in place of upvalue values. They allow you to share\nupvalues between functions.\n\n## Examples\n\n### Shared upvalues\n\n```lua\nlocal loadx = require\"loadx\"\n\nlocal up1 = loadx.newupval()\nlocal up2 = loadx.newupval()\nlocal env = loadx.newupval()\n\nlocal UP1, UP2 -- dummies\nlocal fc1 = string.dump(function(a, b, e) _ENV = e UP1 = a UP2 = b end) -- function code 1\nlocal fc2 = string.dump(function() print(UP1[UP2]) end) -- function code 2\n\nlocal set = loadx.loadx(fc1, nil, nil, env, up1, up2)\nlocal prnt = loadx.loadx(fc2, nil, nil, env, up1, up2)\n\nassert(not pcall(prnt)) -- should fail because we have no env\nset(nil, nil, {print=print}) -- a, b, e, where e sets the _ENV\nassert(not pcall(prnt)) -- should fail because we can't index nil\nset({key=\"hi\"}, \"key\", {print=print}) -- a, b, e. a[b] is \"hi\"\nassert(pcall(prnt)) -- should print \"hi\"\n```\n\n## Compiling\n\nTo compile, on Linux, with gcc:\n\n    gcc -fPIC loadx.c -shared -o loadx.so -I/path/to/lua/include/\n\nThis produces a `loadx.so` which you can then require().\n\nUntested on Windows and OSX.\n\n## Compatibility\n\nloadx is fully compatible with Lua 5.2 and Lua 5.3. loadx is incompatible with Lua 5.1.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoniex2%2Floadx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoniex2%2Floadx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoniex2%2Floadx/lists"}