Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cobs-transform-streams

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cobs-transform-streams

Encode or decode using COBS (Consistent Overhead Byte Stuffing)

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Consistent Overhead Byte Stuffing Transform Streams

Encode or decode using COBS (Consistent Overhead Byte Stuffing) using COBS Transfors Streams (https://streams.spec.whatwg.org/#ts-class)

More info: https://en.wikipedia.org/wiki/Consistent_Overhead_Byte_Stuffing

Example

Instantiation and use

  const decoder = new TransformStream(new COBSDecoderTransformer);

Reading data

  const reader = decoder.readable.getReader();

  function processData(chunk) {
    let { done, value } = chunk;
    if (done) {
      return;
    }

    const view = new DataView(value.buffer);

    // do stuff with data.
    return reader.read().then(processData);
  };

  reader.read().then(processData);

Writing data

  const writer = decoder.readable.getWriter();

  async readFromDevice() {
    // Example using Web USB to get 32 bytes on endpoint 5
    const transfer = await this.device.transferIn(5, 32);

    const data = new Uint8Array(transfer.data.buffer);
    writer.write(data);

    this.readFromDevice();
  }

Keywords

FAQs

Package last updated on 11 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc