New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

stream-frame

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stream-frame

TCP stream framer for Node.JS

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

StreamFrame Build Status

NPM

StreamFrame is a stream framing library for node.js.

Install

npm install stream-frame --save

Installing the latest version

$ npm install git+https://github.com/majimboo/stream-frame.git

Usage

var StreamFrame = require('stream-frame');

var server = net.createServer(function (socket) {
  var B = new StreamFrame();
  B.wrap(socket);

  B.on('data', function(data) {
    console.log(data);
  });
});

You can also pass the socket as a parameter of StreamFrame().

var B = new StreamFrame(socket);
B.on('data', data_handler);

Options

  • lengthSize (default: 2) - The length in bytes of the prepended message size.
  • bigEndian (default: false) - The byte order of the prepended length.
  • offset (default: 0) - The offset where the packet size can be found.
  • ignore (default: false) - Will not try to frame the message.
var StreamFrame = require('stream-frame');
var B = new StreamFrame();

B.set('lengthSize', 1); // uint8
B.set('lengthSize', 2); // uint16
B.set('lengthSize', 4); // uint32

B.set('offset', 2);    // size starts at 3rd byte.
B.set('ignore', true); // will emit data immedietely without framing.

B.set('bigEndian', true);  // uses bigEndian order
B.set('bigEndian', false); // uses default little endian order

Benchmark

v 0.0.3
StreamFrame x 623,238 ops/sec ±1.72% (87 runs sampled)

v 0.0.4
StreamFrame x 886,578 ops/sec ±0.56% (90 runs sampled)

Keywords

tcp

FAQs

Package last updated on 11 Feb 2015

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