# jscdr

> A DDS-CDR encoder/decoder library.

Latest version **0.0.3** (published 2024-07-08) · EPL-2.0 OR Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install jscdr
pnpm add jscdr
yarn add jscdr
bun add jscdr
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2024-07-08 |
| First published | 2021-03-17 |
| Weekly downloads | 0 |
| License | EPL-2.0 OR Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 1.1 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Julien Enoch |
| Maintainers | julien.enoch |
| Keywords | DDS, CDR, ROS2, serialization, encode, decode |

## Links

- npm: https://www.npmjs.com/package/jscdr
- Repository: https://github.com/atolab/jscdr
- Homepage: https://github.com/atolab/jscdr#readme
- Issues: https://github.com/atolab/jscdr/issues
- npm.io page: https://npm.io/package/jscdr

## Dependencies (2)

- [core-js](https://npm.io/package/core-js.md) 3.15.1
- [bytebuffer](https://npm.io/package/bytebuffer.md) 5.0.1

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads
- [datasets-fi-postalcodes](https://npm.io/package/datasets-fi-postalcodes.md) — 1.1K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2024-07-08
- 0.0.1-beta.3 (beta) — 2021-03-18
- 0.0.2 — 2021-06-28
- 0.0.1 — 2021-03-18
- 0.0.1-beta.2 — 2021-03-18
- 0.0.1-beta.1 — 2021-03-18
- 0.0.1-beta.0 — 2021-03-17

## README

[![jsDelivr](https://data.jsdelivr.com/v1/package/npm/jscdr/badge)](https://www.jsdelivr.com/package/npm/jscdr)
[![License](https://img.shields.io/badge/License-EPL%202.0-blue)](https://choosealicense.com/licenses/epl-2.0/)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

# jscdr

A DDS-CDR encoder/decoder library in Javascript.

CDR stands for the O.M.G.'s Common Data Representation that is used in DDS (Data Distributed Service) implementations.
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.

In the current version, this library only handles the basic types.
It doesn't include an IDL compiler generating Javascript encoder/decoder for complex types.



## Usage

Add the following to your HTML page:
```html
<script src="https://cdn.jsdelivr.net/npm/jscdr@0.0.3/dist/index.umd.js"></script>
```

Assuming a DDS type is defined with the following IDL:
```c
module HelloWorldData
{
  struct Msg
  {
    long userID;
    string message;
  };
  #pragma keylist Msg userID
};
```

The code to encode such type will be:
```js
var m = Msg(1, "Hello World!");

var writer = new CDRWriter();
writer.writeInt32(m.userId);
writer.writeString(m.message);

// get the resulting dcodeIO.ByteBuffer
var byteBuffer = writer.buffer;
```

The code to decode such type will be:
```js
// Get a dcodeIO.ByteBuffer of bytes to decode
var byteBuffer = ...;

CDRReader reader = new CDRReader(byteBuffer);
var userId = reader.readInt32();
var message = reader.readString();
var m = new HelloWorldData.Msg(userId, message);
```

---
_Source: https://npm.io/package/jscdr · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
