{"id":19534037,"url":"https://github.com/foxglove/cdr","last_synced_at":"2025-04-26T14:34:38.017Z","repository":{"id":43287845,"uuid":"380364493","full_name":"foxglove/cdr","owner":"foxglove","description":"Common Data Representation serialization and deserialization library","archived":false,"fork":false,"pushed_at":"2024-02-29T16:51:13.000Z","size":181,"stargazers_count":13,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-04T14:02:10.180Z","etag":null,"topics":["cdr","dds","deserialization","omg-dds","ros2","rtps","serde","serialization","typescript"],"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/foxglove.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}},"created_at":"2021-06-25T22:13:36.000Z","updated_at":"2025-03-16T16:14:02.000Z","dependencies_parsed_at":"2024-01-02T15:44:40.310Z","dependency_job_id":"84e68ca5-9986-4e9f-9328-519dd7c51dbf","html_url":"https://github.com/foxglove/cdr","commit_stats":{"total_commits":27,"total_committers":5,"mean_commits":5.4,"dds":"0.33333333333333337","last_synced_commit":"1ddc301ecc1e984b7c9c22d2249651f3f2c2e798"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxglove%2Fcdr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxglove%2Fcdr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxglove%2Fcdr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/foxglove%2Fcdr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/foxglove","download_url":"https://codeload.github.com/foxglove/cdr/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250366715,"owners_count":21418772,"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":["cdr","dds","deserialization","omg-dds","ros2","rtps","serde","serialization","typescript"],"created_at":"2024-11-11T02:12:02.618Z","updated_at":"2025-04-26T14:34:37.497Z","avatar_url":"https://github.com/foxglove.png","language":"TypeScript","readme":"# @foxglove/cdr\n\n\u003e _Common Data Representation serialization and deserialization library_\n\n[![npm version](https://img.shields.io/npm/v/@foxglove/cdr.svg?style=flat)](https://www.npmjs.com/package/@foxglove/cdr)\n\n## Introduction\n\nCommon Data Representation (CDR) defines a serialization format for primitive types. When combined with an Interface Definition Language (IDL) it can be used to create complex types that can be serialized to disk, transmitted over the network, etc. while transparently handling endianness and alignment requirements. It's specified by https://www.omg.org/spec/DDSI-RTPS/2.3/PDF (chapter 10) and https://www.omg.org/cgi-bin/doc?formal/02-06-51.\n\nXCDR implementation follows [DDS-XTypes V1.3 specification](https://www.omg.org/spec/DDS-XTypes/1.3/PDF).\n\nCDR is found in OMG DDS (Data Distributed Service) implementations such as the Real-Time Publish Subscribe (RTPS) protocol. This is the wire protocol found in ROS2, and CDR is the default serialization format used in rosbag2.\n\n## Usage\n\n```Typescript\nimport { CdrReader, CdrSizeCalculator, CdrWriter } from \"@foxglove/cdr\";\n\nconst calc = new CdrSizeCalculator();\ncalc.int8();\ncalc.uint8();\ncalc.int16();\ncalc.uint16();\ncalc.int32();\ncalc.uint32();\ncalc.int64();\ncalc.uint64();\ncalc.float32();\ncalc.float64();\ncalc.string(\"abc\".length);\ncalc.sequenceLength();\nconsole.log(calc.size);\n\nconst writer = new CdrWriter();\nwriter.int8(-1);\nwriter.uint8(2);\nwriter.int16(-300);\nwriter.uint16(400);\nwriter.int32(-500_000);\nwriter.uint32(600_000);\nwriter.int64(-7_000_000_001n);\nwriter.uint64(8_000_000_003n);\nwriter.float32(-9.14);\nwriter.float64(1.7976931348623158e100);\nwriter.string(\"abc\");\nwriter.sequenceLength(0);\n\nconst reader = new CdrReader(writer.data);\nconsole.log(reader.int8());\nconsole.log(reader.uint8());\nconsole.log(reader.int16());\nconsole.log(reader.uint16());\nconsole.log(reader.int32());\nconsole.log(reader.uint32());\nconsole.log(reader.int64());\nconsole.log(reader.uint64());\nconsole.log(reader.float32());\nconsole.log(reader.float64());\nconsole.log(reader.string());\nconsole.log(reader.sequenceLength());\n```\n\n## Alternatives\n\n[jscdr](https://github.com/atolab/jscdr) - Does not support bigint, pre-allocated buffers, or buffer length calculations.\n\n## License\n\n@foxglove/cdr is licensed under the [MIT License](https://opensource.org/licenses/MIT).\n\n## Releasing\n\n1. Run `yarn version --[major|minor|patch]` to bump version\n2. Run `git push \u0026\u0026 git push --tags` to push new tag\n3. GitHub Actions will take care of the rest\n\n## Stay in touch\n\nJoin our [Slack channel](https://foxglove.dev/slack) to ask questions, share feedback, and stay up to date on what our team is working on.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxglove%2Fcdr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffoxglove%2Fcdr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffoxglove%2Fcdr/lists"}