npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

pipecast

v0.0.1

Published

Broadcast POST requests into GET long-polling streams

Downloads

6

Readme

pipecast Build Status

$ npm install pipecast

The following example starts an http pipe on http://localhost:5000/pipe. POST requests body will be sent as downstream to all open GET requests.

var pipecast = require('pipecast');
var http = require('http');

// create an http pipe - everything POSTed will be broadcasted
// to all GETters.
var pipe = pipecast();

// serve the pipe through '/pipe'
http.createServer(function(req, res) {
	if (req.url === "/pipe") {
		return pipe(req, res);
	}

	res.write("GET /pipe: Start a downstream\n");
	res.write("POST /pipe: Send message into all downstreams\n");
	res.end();
}).listen(5000);
console.log('Listening on 5000');

Note that by default, pipecast will add a newline after each data chunk. If you wish not to alter the data at all, set options.map to function(d) { return d; }

Start the server:

$ node pipecast.js &
[1] 20992
Listening on 5000

Fire up a few listeners:

$ curl http://localhost:5000/pipe &
[2] 20996
$ curl http://localhost:5000/pipe &
[3] 20997
$ curl http://localhost:5000/pipe &
[4] 20998

Now start writing:

$ curl http://localhost:5000/pipe -d "Hello 1"
Hello 1
Hello 1
Hello 1
$ curl http://localhost:5000/pipe -d "Hello 2"
Hello 2
Hello 2
Hello 2

API

pipecast([options])

Returns function(req, res) which is an HTTP handler that can be used with the http module, express, connect and whatnot.

options.headers are headers to reply with for GET requests. Default is { 'content-type': 'text/plain' }

options.logger alternative logger (must conform to console). Default is null, in which case no logs will be emitted.

options.map is an optional function(data) => data that maps incoming data to outgoing data and can be used to transform upstream content. One common usage of this is to add a newline after each data chunk so that buffers will flush to downstream consumers. Default is to add a newline at the end of data.

pipecast.pipe()

Returns an object that conforms to node.js StreamReader and StreamWriter and pipes data from write() operations to data events.

LICENSE

MIT