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

yellow-stream

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yellow-stream

Provides stream utilties, such as multi-plexing and generalized receivers.

  • 0.0.13
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
38
decreased by-22.45%
Maintainers
1
Weekly downloads
 
Created
Source

YellowStream

YellowStream is a Node.js library for managing streams. The basic core goal of YellowStream is to do to streams what Jquery did to DOM code.

This module is published under the MIT license.

Installation Instructions

Local Directory

In the directory in question, run this command:

npm install yellow-stream

Global

Assuming you have the rights to do so, run this command:

npm install -g yellow-stream

Usage instructions

consolidator

Consolidator is basically a utility function, that takes a stream, takes all of the content from that stream, and when the content is all received, allows a function to be performed with the completed content. It's pretty much a "Stream to String" feature.

Consolidators take a streaming object, and output a similar object. Consolidators have two events: "error" and "end". Error will usually have an error object as a callback parameter. "end" will always have a callback parameter, which is the value of the string in the buffer.

The received streaming object must be capable of emitting "error", "data", and "end"; in the ususual ways.

consolidator example
var https = require("https");
var yellow = require("yellow-stream");
https.get("https://www.google.com", function(raw){
  var stream = new yellow.consolidator(raw);
  stream.on("error", function(e){
    console.log(e);
  });
  stream.on("end", function(value){
    console.log(value);
  });
});

FrameStreams

FrameStreams are intended for services like VOIP services, which have a continuous stream, and need the data segmented. The problem is that, usually, TCP sends packets of a certain regular size, which may or may not be the size of the data frames the developer needs. This takes an arbitrary stream, and converts its data emission into a format some human might want.

FrameStreams take a streaming object, and output a streaming object. FrameStreams have 3 events: "error", "data", and "end". "error" is for errors in the usual way. "data" is a dataframe of a garunteed size. "end" is emitted when the source stream closes. "end"'s callback function has a parameter that is the data left over in the buffer.

The received streaming object must be capable of emitting "error", "data", and "end"; in the ususual ways.

FrameStream Example
var https = require("https");
var yellow = require("yellow-stream");
https.get("https://www.google.com", function(raw){
    var stream = new yellow.toFrameStream(raw);
    stream.frameSize = 32;
    stream.on("error", function(e){
        console.log(e);
    });
    stream.on("data", function(value){
        console.log(value);
    });
    stream.on("end", function(value){
        console.log(value);
    });
});

NewLineStreams

NewLineStreams are intended for services such as IM systems, consoles, and certain database systems where one may need to break a stream up by lines.

NewLineStreams take a streaming object, and output a streaming object. NewLineStreams have 3 events: "error", "data", and "end". "error" is for errors in the usual way. "data" is a dataframe. "end" is emitted when the source stream closes. "end"'s callback function has a parameter that is the data left over in the buffer.

The received streaming object must be capable of emitting "error", "data", and "end"; in the ususual ways.

NewLineStream Example
var https = require("https");
var yellow = require("yellow-stream");
http.get("http://www.uglydress.com/", function(raw){
    var stream = new yellow.breakByLine(raw, true, true, true, true);
    stream.on("error", function(e){
        console.log(e);
    });
    stream.on("data", function(value){
        console.log(value);
        console.log("\n");
    });
    stream.on("end", function(value){
        console.log(value);
    });
});

SplitStreams

SplitStreams are for when one wants to break up a stream by certain phrases. This is useful in things like database clients.

SplitStreams take a streaming object, and output a streaming object. SplitStreams have 3 events: "error", "data", and "end". "error" is for errors in the usual way. "data" is a dataframe. "end" is emitted when the source stream closes. "end"'s callback function has a parameter that is the data left over in the buffer.

The received streaming object must be capable of emitting "error", "data", and "end"; in the ususual ways.

SplitStream Example
var http = require("http");
http.get("http://www.uglydress.com/", function(raw){
    var stream = new yellow.splitStream(raw, "\n");
    stream.on("error", function(e){
        console.log(e);
    });
    stream.on("data", function(value){
        console.log(value);
        console.log("\n");
    });
    stream.on("end", function(value){
        console.log(value);
    });
});

Keywords

FAQs

Package last updated on 05 May 2016

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