{"id":21715127,"url":"https://github.com/ts-defold/tstl-userdata-sugar","last_synced_at":"2025-04-12T19:22:07.332Z","repository":{"id":57167944,"uuid":"308076717","full_name":"ts-defold/tstl-userdata-sugar","owner":"ts-defold","description":"TypeScriptToLua plugin that provides syntax sugar for Userdata types in lua","archived":false,"fork":false,"pushed_at":"2023-07-11T13:31:52.000Z","size":328,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-26T13:38:37.526Z","etag":null,"topics":["lua","typescript","typings"],"latest_commit_sha":null,"homepage":"https://ts-defold.dev","language":"TypeScript","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/ts-defold.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":"2020-10-28T16:28:31.000Z","updated_at":"2024-02-23T04:48:34.000Z","dependencies_parsed_at":"2022-09-12T07:53:20.049Z","dependency_job_id":null,"html_url":"https://github.com/ts-defold/tstl-userdata-sugar","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/ts-defold%2Ftstl-userdata-sugar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-defold%2Ftstl-userdata-sugar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-defold%2Ftstl-userdata-sugar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ts-defold%2Ftstl-userdata-sugar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ts-defold","download_url":"https://codeload.github.com/ts-defold/tstl-userdata-sugar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248395685,"owners_count":21096811,"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":["lua","typescript","typings"],"created_at":"2024-11-26T00:41:18.492Z","updated_at":"2025-04-12T19:22:07.307Z","avatar_url":"https://github.com/ts-defold.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tstl-userdata-sugar\n\u003ca href=\"https://discord.gg/eukcq5m\"\u003e\u003cimg alt=\"Chat with us!\" src=\"https://img.shields.io/discord/766898804896038942.svg?colorB=7581dc\u0026logo=discord\u0026logoColor=white\"\u003e\u003c/a\u003e\n\u003e TypeScriptToLua plugin that provides syntax sugar for Userdata types in lua\n\n## Features\n\n### `...` =\u003e unpack\nSupport array-like user data object destructuring.\n\u003e Lua's `unpack` function only supports unpacking tables, even if the required metamethods of `__index` and `__len` are present to treat them like an array.\n\nTo support this feature we detect a `...` of an `Array\u003cT\u003e` \u0026 `LuaUserdata` type and implicitly inject a call to `map(x =\u003e x)`. This then returns a table from the userdata and passes it to unpack. There may exist more efficient methods of unpacking your array data directly from the userdata type, and you may want to avoid this syntax sugar if moving large amounts of data.\n\n```ts\ndeclare type UserDataArray\u003cT\u003e = Array\u003cT\u003e \u0026 LuaUserdata \u0026 {\n};\n\ndeclare function makeUserData(): UserDataArray\u003cnumber\u003e;\n\nconst userData: UserDataArray\u003cnumber\u003e = makeUserData();\nconsole.log([...userData]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-defold%2Ftstl-userdata-sugar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fts-defold%2Ftstl-userdata-sugar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fts-defold%2Ftstl-userdata-sugar/lists"}