# @dcos/recordio

> Provides a function to read records in the RecordIO format from the input string

Latest version **0.1.8** (published 2018-08-14) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @dcos/recordio
pnpm add @dcos/recordio
yarn add @dcos/recordio
bun add @dcos/recordio
```

## 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.1.8 |
| Published | 2018-08-14 |
| First published | 2017-10-24 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 926.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Mesosphere DC/OS UI Team |
| Maintainers | dschmidt, fabsn, juliangieseke, mesosphere-frontend-ci, mesosphere-it, mperrotti, nlight, orlandohohmeier, specone |

## Links

- npm: https://www.npmjs.com/package/@dcos/recordio
- Repository: https://github.com/dcos-labs/recordio
- Homepage: https://github.com/dcos-labs/recordio#readme
- Issues: https://github.com/dcos-labs/recordio/issues
- npm.io page: https://npm.io/package/@dcos/recordio

## Dependencies (1)

- [@dcos/copychars](https://npm.io/package/@dcos/copychars.md) ^0.1.2

## Recent versions

- 0.1.8 (latest) — 2018-08-14
- 0.1.7 — 2018-06-27
- 0.1.6 — 2018-01-09
- 0.1.5 — 2017-11-16
- 0.1.4 — 2017-10-30
- 0.1.3 — 2017-10-25
- 0.1.2 — 2017-10-25
- 0.1.1 — 2017-10-24
- 0.1.0 — 2017-10-24

## README

# RecordIO [![Build Status](https://travis-ci.org/dcos-labs/recordio.svg?branch=master)](https://travis-ci.org/dcos-labs/recordio)

---
👩‍🔬  Please be aware that this package is still experimental —
changes to the interface  and underlying implementation are likely,
and future development or maintenance is not guaranteed.

---

This package provides a function to read records in the RecordIO format from the input string.

## Usage

```javascript
import { read } from "@dcos/recordio";

const [records, rest] = read(input);
```

Function `read` returns a tuple whose first element is an array of records and the second element is the rest part of the input that is either empty or contains partial records.

## RecordIO format

Prepends to a single record its length in bytes, followed by a newline and then the data:

The BNF grammar for a RecordIO-encoded streaming response is:
```
records         = *record

record          = record-size LF record-data

record-size     = 1*DIGIT
record-data     = record-size(OCTET)
```
`record-size` should be interpreted as an unsigned 64-bit integer (uint64).

For example, a stream may look like:

```
121\n
{"type": "SUBSCRIBED","subscribed": {"framework_id": {"value":"12220-3440-12532-2345"},"heartbeat_interval_seconds":15.0}20\n
{"type":"HEARTBEAT"}675\n
...
```

Further documentation can be found in the [Apache Mesos documentation](http://mesos.apache.org/documentation/latest/scheduler-http-api/#recordio-response-format).

## Testing

The implementation is tested with different UTF-8 character sets to verify that it reads the correct number of bytes from the input string.

You can use the following python snippet to create test records from the provided messages array.

```python
messages = [u"foo", u"bar"]

for message in messages:
    chars = len(message)
    size = len(message.encode("utf-8"))
    print("Message")
    print("> Chars: %s" % chars)
    print("> Size: %s" % size)
    print("> Message: %s" % message)
    print("> Record: %s\\n%s" % (size, message))
```

Some of the tests use character sets from the [UTF-8 decoder capability and stress test](https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt) developed by [Markus Kuhn](http://www.cl.cam.ac.uk/~mgk25/) to ensure that parsing of character with different byte sequences works properly.

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