{"id":17551615,"url":"https://github.com/mati365/ts-union-struct","last_synced_at":"2026-02-22T16:34:57.775Z","repository":{"id":42868189,"uuid":"258785866","full_name":"Mati365/ts-union-struct","owner":"Mati365","description":"Small typescript utility class that helps with creating bit fields","archived":false,"fork":false,"pushed_at":"2023-01-06T04:24:01.000Z","size":1289,"stargazers_count":4,"open_issues_count":12,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T01:39:59.918Z","etag":null,"topics":["bitfield","bits","decorators","struct","union"],"latest_commit_sha":null,"homepage":"","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/Mati365.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-04-25T13:44:30.000Z","updated_at":"2023-03-16T11:29:48.000Z","dependencies_parsed_at":"2023-02-05T07:16:06.513Z","dependency_job_id":null,"html_url":"https://github.com/Mati365/ts-union-struct","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mati365/ts-union-struct","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mati365%2Fts-union-struct","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mati365%2Fts-union-struct/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mati365%2Fts-union-struct/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mati365%2Fts-union-struct/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mati365","download_url":"https://codeload.github.com/Mati365/ts-union-struct/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mati365%2Fts-union-struct/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29718454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-22T15:10:41.462Z","status":"ssl_error","status_checked_at":"2026-02-22T15:10:04.636Z","response_time":110,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["bitfield","bits","decorators","struct","union"],"created_at":"2024-10-21T04:46:54.309Z","updated_at":"2026-02-22T16:34:57.756Z","avatar_url":"https://github.com/Mati365.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ts-union-struct\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](https://opensource.org/licenses/MIT)\n[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\nSmall typescript utility class that helps with creating bit fields and C unions\n\n## Installation\n```\nyarn add ts-union-struct\n```\n\n## Usage\n\n```typescript\nimport UnionStruct, {bits} from 'ts-union-struct';\n\nclass Register extends UnionStruct {\n  @bits(0) lsb: number;\n  @bits(15) msb: number;\n\n  @bits(0, 7) low: number;\n  @bits(8, 15) high: number;\n}\n\n// later in code..\nconst reg = new Register(0xFF_EE);\n\nreg.number; // =\u003e 0xFF_EE\nreg.low = 0x0;\nreg.number; // =\u003e 0xFF_00\n\n// pack plain object into union\nconst reg1 = Register.pack(\n  {\n    low: 0x0,\n    high: 0xFF,\n  }\n);\nreg1.number; // =\u003e 0xFF_00\n\n// unpack\nconst reg = new Register(0xFF_EE);\nreg.unpack(); // {low: 0xEE, high: 0xFF}\n```\n\n## License\n\nThe MIT License (MIT)\nCopyright (c) 2020 Mateusz Bagiński\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmati365%2Fts-union-struct","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmati365%2Fts-union-struct","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmati365%2Fts-union-struct/lists"}