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

chrome-https

v2.0.1

Published

https module compatability for chrome apps

Downloads

19

Readme

chrome-https

This is a fork of https://www.npmjs.com/package/stream-http

There are two reasons for the fork

  1. A call to https.request with an options parameter without a scheme but with a port throws an error in chrome-apps

  2. The default https-browserify inherits the all the calls from which ever http is required but with the scheme change. This breaks in chromiumify asthe full http stack guards against using the incorrect protocol.

So to use the https module from node.js in chrome apps the stream-http module has been taken, the scheme update applied, and published as chome-https.

When you require('https') in a chromiumify app, this module will be loaded.

example

var https = require('https');

var options = {
  hostname: 'encrypted.google.com',
  port: 443,
  path: '/',
  method: 'GET'
};

var req = https.request(options, function(res) {
  console.log("statusCode: ", res.statusCode);
  console.log("headers: ", res.headers);

  res.on('data', function(d) {
    process.stdout.write(d);
  });
});
req.end();

req.on('error', function(e) {
  console.error(e);
});

http methods

var https = require('https');

var req = https.request(opts, cb)

where opts are:

  • opts.method='GET' - http method verb
  • opts.path - path string, example: '/foo/bar?baz=555'
  • opts.headers={} - as an object mapping key names to string or Array values
  • opts.host=window.location.host - http host
  • opts.port=window.location.port - http port
  • opts.responseType - response type to set on the underlying xhr object

The callback will be called with the response object.

var req = https.get(options, cb)

A shortcut for

options.method = 'GET';
var req = https.request(options, cb);
req.end();

request methods

req.setHeader(key, value)

Set an http header.

req.getHeader(key)

Get an http header.

req.removeHeader(key)

Remove an http header.

req.write(data)

Write some data to the request body.

If only 1 piece of data is written, data can be a FormData, Blob, or ArrayBuffer instance. Otherwise, data should be a string or a buffer.

req.end(data)

Close and send the request body, optionally with additional data to append.

response methods

res.getHeader(key)

Return an http header, if set. key is case-insensitive.

response attributes

  • res.statusCode, the numeric http response code
  • res.headers, an object with all lowercase keys

in order to map "chrome-https" over require('https') in your browserified source.

install

With npm do:

npm install chrome-https

license

MIT