Socket
Book a DemoInstallSign in
Socket

stream-hint

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

stream-hint

detect type of a stream based on match on first dataevent

latest
npmnpm
Version
0.0.1
Version published
Weekly downloads
1
-50%
Maintainers
1
Weekly downloads
 
Created
Source

node-stream-hint

detect type of a stream based on match on first dataevent.

works on flowing streams of all types with varying usefullness.

var hint = require('stream-hint');
var net = require('net');

net.createServer(function(con){
  hint(con,["HTTP","tacos","replication"],function(err,type,con){

    if(type === "HTTP"){
      // handle http. note the string HTTP is removed from the first data event so you should add it back.
      con.write(type); 
    } else if(type == "replication") {
      // do magic event streams! or some such.
      con.pipe(db.replication());
    } else if(type == "tacos"){
      // feede tacos!
      con.write("mmm tacos.");
      con.end();
    } else {h
      // no!
      con.destroy();
    }

  });

}).listen(0);


  • you can compare strings to either strings or buffers.
  • with objects i will check to see if a property exists
  • with other data types i will check to see if the data === the value in the hint array

FAQs

Package last updated on 27 Jan 2014

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