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 🙏

© 2025 – Pkg Stats / Ryan Hefner

tenacious-http

v0.1.3

Published

a streaming http connection which will attempt to reconnect whenever the stream lost

Downloads

7

Readme

#TenaciousHttp

This library creates a streaming node Http connection which will automatically attempt recover from disconnect events.

Note that this module is promise based (via the Q library) and event based (via the EventEmitter)

##Prerequisites

  • node

##Install

  • npm install tenacious-http
  • require('tenacious-http');

##Use ###create(host, port, header, initFunction) //create a tenaciousHttp instance via the static factory var tenacious = Tenacious.create('HTTP_HOST', HOST_PORT, HTTP_HEADER_OBJECT, INIT_FUNCTION [optional]); ###SOCKET_TIMEOUT SOCKET_TIMEOUT is a static variable. If there is no activity between the http connection and the client for SOCKET_TIME (in ms), then the connection is closed and 'recover()' is called. If you want there to be no timeout then set SOCKET_TIMEOUT to 0. The SOCKET_TIMEOUT defaults to 60 seconds. A timeout event will be emitted when a timeout occurs.

Tenacious.SOCKET_TIMEOUT = 30000; //changes the timeout to 30 seconds.
Tenacious.SOCKET_TIMEOUT = 0; //sets the socket to never timeout

###start() Starts an http connection, returning a promise.

tenacious.start().then(
    function() {
        //successfully started
    } , function(err) {
        //start had error 'err'
    });

###stop(message [optional]) Stops the streaming http connection, returning a promise.

tenacious.stop().then(
    function() {
        //stopped successfully
    }, function (err) {
        //stop had error 'err'
    });

###write(message) Writes a messages to the host.

tenacious.write('message to write to the host');

###recover() Attempts to reconnect the host, returning a promise. call this when the for application level error cases.

tenacious.recover.then(
    function() {
        //successfully recovered/reconnected
    }, function(err) {
        //failed to recover
    });

###isWritable() Returns true if the state of the http connection is writable. if(tenacious.isWritable()){ //tenacious.write('foo'); will work }

##events emitted

###data(chunk, statusCode) Emits the data coming in to the Http connection, with its status code.

###end(statusCode) Emits an end once the host sends an end to the http client, with its status code. Note that tenaciousHttp calls 'recover()' once it receives an end from the host.

###timeout Emits when there was no data transferred over the underlying socket for the http connection over the specific timeout period (defaults to 60 seconds). Note that tenaciousHttp calls 'recover()' whenever a socket timeout occurs.

###recovered(reason [optional]) Emits after the recover call is successful. The consumer should do any post connection work on this event.