min-stream-pkt-line

0.0.6 • Public • Published

min-stream-pkt-line

A pkt-line codec packaged as maps and min-stream push-filters.

This is a component of the js-git project.

node support

browser support

Usage

This module exports 4 functions. There are two maps and two push-filters.

var pktLine = require('min-stream-pkt-line');
 
// Assuming source, app, and sink already exist, here is one way to insert the
// framing and deframing into the stream.
helpers.run([
  source,
    pktLine.deframer,
     app,
    pktLine.framer,
  sink
]);

The map functions are used directly as needed and not applied to the stream as a whole.

pktLine.encode(data, caps, request) -> buffer

A map function that encodes the data portion of pkt-lines

pktLine.decode(buffer) -> data

A map function that decodes the data portion of pkt-lines.

pktLine.deframer(emit) -> emit

A push-filter that consumes arbitrary sized buffers and outputs deframed message buffers.

The flush message is encoded as null

If the stream transitions to raw PACK mode, a true event is emitted to signify the transition.

pktLine.framer(emit) -> emit

A map function that accepts a buffer and returns a framed buffer.

Pass in null to encode a flush frame.

Pass in true to set the mode to raw PACK mode.

Readme

Keywords

none

Package Sidebar

Install

npm i min-stream-pkt-line

Weekly Downloads

7

Version

0.0.6

License

MIT

Last publish

Collaborators

  • creationix