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

iso-stream-http

v0.1.2

Published

Isomorphic/Universal implementation of the node http module

Readme

iso-stream-http NPM Version NPM Downloads NPM License

This module is an implementation of Node's native http module for the browser. It tries to match Node's API and behavior as closely as possible, but some features aren't available, since browsers don't give nearly as much control over requests.

This is heavily inspired by, and intended to replace, stream-http.

What does it do?

In accordance with its name, stream-http tries to provide data to its caller before the request has completed whenever possible.

All other supported browsers support pseudo-streaming, where the data is available before the request finishes, but the entire response must be held in memory. This works for both text and binary data.

Usage

const { https, http, getRequest } = require('iso-stream-http');

const req = new http.request('http://localhost/unicorns');
const req = new https.request('https://secure/unicorns');

// Detects url and returns http/https in node, just a helper function.
const req = new getRequest('https://secure/unicorns');

Extra features compared to Node

  • The message.url property provides access to the final URL after all redirects. This is useful since the browser follows all redirects silently, unlike Node. It is available in Chrome 37 and newer, Firefox 32 and newer, and Safari 9 and newer.

  • The options.withCredentials boolean flag, used to indicate if the browser should send cookies or authentication information with a CORS request. Default false.

  • options.requestTimeout allows setting a timeout in millisecionds for XHR and fetch (if supported by the browser). This is a limit on how long the entire process takes from beginning to end. Note that this is not the same as the node setTimeout functions, which apply to pauses in data transfer over the underlying socket, or the node timeout option, which applies to opening the connection.

Features missing compared to Node

  • http.Agent is only a stub
  • The 'socket', 'connect', 'upgrade', and 'continue' events on http.ClientRequest.
  • Any operations, including request.setTimeout, that operate directly on the underlying socket.
  • Any options that are disallowed for security reasons. This includes setting or getting certain headers.
  • message.httpVersion
  • message.rawHeaders is modified by the browser, and may not quite match what is sent by the server.
  • message.trailers and message.rawTrailers will remain empty.
  • Redirects are followed silently by the browser, so it isn't possible to access the 301/302 redirect pages.
  • The timeout event/option and setTimeout functions, which operate on the underlying socket, are not available. However, see options.requestTimeout above.

Example

http.get('/bundle.js', function (res) {
	var div = document.getElementById('result');
	div.innerHTML += 'GET /beep<br>';

	res.on('data', function (buf) {
		div.innerHTML += buf;
	});

	res.on('end', function () {
		div.innerHTML += '<br>__END__';
	});
})

Running tests

There are two sets of tests: the tests that run in Node (found in test/node) and the tests that run in the browser (found in test/browser). Normally the browser tests run on Sauce Labs.

Running npm test will run both sets of tests, but in order for the Sauce Labs tests to run you will need to sign up for an account (free for open source projects) and put the credentials in a .airtaprc file. You will also need to run a Sauce Connect Proxy with the same credentials.

To run just the Node tests, run npm run test-node.

To run the browser tests locally, run npm run test-browser-local and point your browser to the link shown in your terminal.

License

MIT © Hugo Dias