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

tunnel-stream

v0.0.1

Published

A test tunnel stream to simulate intermediate streams with different characteristics

Downloads

2

Readme

tunnel-stream

A test tunnel stream to simulate intermediate streams with different characteristics

Features

  • should be readable and writable at both ends
  • should cause the other end of the TunnelStream to emit data and end events on calls to write and end
  • should support pause and resume but emit a paused data event when data arrives
  • #pause
    • should buffer multiple events separately
  • #discardBufferedEvents
    • should discard events buffered up to now while paused
  • should support the setEncoding method
  • should emit end events on both streams on end from one side
  • should optionally rewrite data events into specified message sizes
  • #flush
    • should flush any unwritten buffered data due to a messageSize setting

Installation

npm install tunnel-stream

API

A simple use case

var TunnelStream = require('tunnel-stream');

var tunnel = new TunnelStream();

tunnel.downstream.setEncoding('utf8');
tunnel.upstream.setEncoding('utf8');

tunnel.downstream.on('data', function(data) {
  tunnel.downstream.write('hello, upstream');
});

tunnel.downstream.on('end', function(data) {
  // ended
});

tunnel.upstream.on('data', function(data) {
  tunnel.upstream.end('goodbye, downstream');
});

tunnel.upstream.on('end', function(data) {
  // ended
});

tunnel.upstream.write('hello, downstream');

To use pause and resume

var tunnel = new TunnelStream();

tunnel.downstream.setEncoding('utf8');

tunnel.downstream.on('data', function(data) {
  // should only receive the 'after discarded' message here
});

tunnel.downstream.on('pausedData', function(data) {
  // should receive the 'to be discarded' message here

  tunnel.downstream.discardBufferedEvents();
  tunnel.downstream.resume();
});

tunnel.downstream.pause();

tunnel.upstream.write('to be discarded');
tunnel.upstream.write('after discarded');

To set the message size

var tunnel = new TunnelStream({
  messageSize: 5
});

tunnel.downstream.setEncoding('utf8');
tunnel.downstream.on('data', function(data) {
  /* 
    should receieve the following messages

      'This '
      'is a '
      'testT'
      'his i'
      's als'
      'o a t'
      'estok'
      ' that'
      ' is a'
      'll'
  */
});
tunnel.downstream.on('end', function() {
  // finished
});

tunnel.upstream.write('This is a test');
tunnel.upstream.write('This is also a test');
tunnel.upstream.end('ok that is all'); // ending the connection will flush the last few bytes

// it is also possible to flush the last few bytes from the tunnel without ending the stream
// by calling the flush method, eg...
tunnel.upstream.flush();

Roadmap

  • Nothing yet

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using ./grunt.sh or .\grunt.bat.

License

Copyright (c) 2012 Peter Halliday
Licensed under the MIT license.