Catalog npm
PACKAGE EXPLORERView in registry

8b10b

npm

A JavaScript implementation of the 8b10b line codec

8b/10b8b10bbinarybytecodecdecodeencodesymbolword
Versions collected4
Direct dependencies0From release 2.0.0
Last observed20 Oct, 21:20 UTC

README

Current package documentation

8b10b

An JavaScript implementation of the 8b10b line codec.

Use it to convert bytes to 10-bit symbols and vise-versa. It only converts to and from data symbols; control symbols should be intercepted and handled by your application.

Usage

import { encode, decode } from 'npm:8b10b@2.0.0';

const encoded = encode({ word: 42 });

encoded.symbol;

// => 345

const decoded = decode({ symbol: encoded.symbol });

encoded.word;

// => 42

The object returned by the encode function also provides the running disparity for the next word to be encoded. This is how you can encode a string:

import { encode, decode } from 'npm:8b10b@2.0.0';

const words = 'hello world'.split('').map(char => char.charCodeAt(0));
const symbols = [];

let runningDisparity = -1;

for (const word of words) {
  const result = encode({ word, runningDisparity });

  runningDisparity = result.runningDisparity;
  symbols.push(result.symbol);
}

console.log(symbols);

// => [ 915, 659, 211, 211, 652, 633, 92, 371, 307, 211, 172 ]

let decodedString = '';

runningDisparity = -1;

for (const symbol of symbols) {
  const result = decode({ symbol, runningDisparity });

  runningDisparity = result.runningDisparity;
  decodedString = decodedString.concat(
    String.fromCharCode(result.word)
  );
}

console.log(decodedString);

// => hello world

Testing

The tests use the Deno runtime.

Run them with make test.

License

See LICENSE.txt

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 4

Collected releases
VersionPublishedDirect dependenciesOpen version
2.0.0Registry latest30 Dec 20220
1.3.010 May 20182
1.1.08 May 20182
1.0.08 May 20182

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
ravenstine/8b10b

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 21:20 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:5d9b810b1c6741cf9bc6ea7114cddfde0e2d60c65aad9f7d63bde61687d50ad7