{"id":28167388,"url":"https://github.com/patrickroberts/struct-view","last_synced_at":"2026-02-26T07:40:50.031Z","repository":{"id":292075304,"uuid":"449854084","full_name":"patrickroberts/struct-view","owner":"patrickroberts","description":"Simple DSL for defining binary structures in JavaScript","archived":false,"fork":false,"pushed_at":"2025-05-10T06:18:25.000Z","size":660,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-12T15:26:12.717Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://patrickroberts.dev/struct-view/","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/patrickroberts.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-01-19T21:01:22.000Z","updated_at":"2025-05-10T06:07:19.000Z","dependencies_parsed_at":"2025-06-26T00:05:25.129Z","dependency_job_id":"65497b2a-6ef2-4500-9554-73d1da944c74","html_url":"https://github.com/patrickroberts/struct-view","commit_stats":null,"previous_names":["patrickroberts/struct-view"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/patrickroberts/struct-view","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fstruct-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fstruct-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fstruct-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fstruct-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/patrickroberts","download_url":"https://codeload.github.com/patrickroberts/struct-view/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/patrickroberts%2Fstruct-view/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29851640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-25T22:37:40.667Z","status":"online","status_checked_at":"2026-02-26T02:00:06.774Z","response_time":89,"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":[],"created_at":"2025-05-15T14:12:36.519Z","updated_at":"2026-02-26T07:40:50.016Z","avatar_url":"https://github.com/patrickroberts.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# struct-view\n\n[![build](https://badgen.net/github/checks/patrickroberts/struct-view?icon=github\u0026label=build)](https://github.com/patrickroberts/struct-view/actions)\n[![coverage](https://badgen.net/codecov/c/github/patrickroberts/struct-view?icon=codecov)](https://codecov.io/gh/patrickroberts/struct-view)\n[![license](https://badgen.net/github/license/patrickroberts/struct-view)](https://github.com/patrickroberts/struct-view/blob/main/LICENSE)\n[![npm](https://badgen.net/npm/v/struct-view)](https://www.npmjs.com/package/struct-view)\n![types](https://badgen.net/npm/types/struct-view)\n\n## Simple DSL for defining binary structures in JavaScript\n\n### Why struct-view?\n\nThis library enables developers to define and use packed binary structures in JavaScript without any external dependencies. It is not intended for ABI-compliance or for use with foreign function interfaces.\n\n### Installation\n\n```sh\nnpm i struct-view\nyarn add struct-view\n```\n\n### Example Usage\n\nWriting a WAV header:\n```ts\n// wav.ts\nimport { char, struct, uint16, uint32, uint8, union } from 'struct-view';\n\nconst ChunkHeader = struct(\n  char(4)('chunkId'),\n  uint32('chunkSize'),\n);\n\nconst SubChunk1 = struct(\n  ChunkHeader,\n  uint16('audioFormat'),\n  uint16('numChannels'),\n  uint32('sampleRate'),\n  uint32('byteRate'),\n  uint16('blockAlign'),\n  uint16('bitsPerSample'),\n);\n\nconst WavHeader = struct(\n  ChunkHeader,\n  char(4)('format'),\n  SubChunk1('subChunk1'),\n  ChunkHeader('subChunk2'),\n);\n\nconst WavBytes = uint8(WavHeader.BYTES_PER_INSTANCE);\n\nconst WavView = union(\n  WavHeader('header'),\n  WavBytes('bytes'),\n);\n\nconst view = new WavView();\nconst { header, bytes } = view;\nconst { subChunk1, subChunk2 } = header;\n\nheader.chunkId = 'RIFF';\nheader.chunkSize = header.byteLength - ChunkHeader.BYTES_PER_INSTANCE;\nheader.format = 'WAVE';\n\nsubChunk1.chunkId = 'fmt ';\nsubChunk1.chunkSize = subChunk1.byteLength - ChunkHeader.BYTES_PER_INSTANCE;\nsubChunk1.audioFormat = 1;\nsubChunk1.numChannels = 1;\nsubChunk1.sampleRate = 44100;\nsubChunk1.byteRate = 88200;\nsubChunk1.blockAlign = 2;\nsubChunk1.bitsPerSample = 16;\n\nsubChunk2.chunkId = 'data';\n\nprocess.stdout.write(bytes);\n```\n\nOutput:\n```\nnpx ts-node examples/wav | xxd\n00000000: 5249 4646 2400 0000 5741 5645 666d 7420  RIFF$...WAVEfmt \n00000010: 1000 0000 0100 0100 44ac 0000 8858 0100  ........D....X..\n00000020: 0200 1000 6461 7461 0000 0000            ....data....\n```\n\n### Documentation\n\nAPI Reference available on [GitHub Pages](https://patrickroberts.github.io/struct-view)\n\n### Code Coverage\n\nAvailable on [Codecov](https://codecov.io/gh/patrickroberts/struct-view)\n\n### Todo\n\n* Bitfield Support\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickroberts%2Fstruct-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpatrickroberts%2Fstruct-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpatrickroberts%2Fstruct-view/lists"}