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

requestsp

v0.1.2

Published

[![Made by unshift][made-by]](http://unshift.io)[![Version npm][version]](http://browsenpm.org/package/requests)[![Build Status][build]](https://travis-ci.org/unshiftio/requests)[![Dependencies][david]](https://david-dm.org/unshiftio/requests)[![Coverage

Downloads

4

Readme

requests

Made by unshiftVersion npmBuild StatusDependenciesCoverage StatusIRC channel

Requests is a small library that implements fully and true streaming XHR for browsers that support these methods. It uses a variety of proprietary responseType properties to force a streaming connection, even for binary data. For browsers that don't support this we will simply fallback to a regular but async XHR 1/2 request or ActiveXObject in even older deprecated browsers.

  • Internet Explorer >= 10: ms-stream
  • FireFox >= 9: moz-chunked
  • FireFox < 20: multipart

This module comes with build-in protection against ActiveX blocking that is frequently used in firewalls & virus scanners.

Installation

The module is released in the public npm registry and can be installed using:

npm install --save requests

Usage

The API is a mix between the Fetch API, mixed with EventEmitter API for the event handling.

'use strict';

var requests = require('requests');

Now that we've included the library we can start making requests. The exported method accepts 2 arguments:

  • url Required URL that you want to have requested.
  • options Optional object with additional configuration options:
    • streaming Should we use streaming API's to fetch the data, defaults to false.
    • method The HTTP method that should be used to get the contents, defaults to GET.
    • mode The request mode, defaults to cors
    • headers Object with header name/value that we need to send to the server.
    • timeout The timeout in ms before we should abort the request.
    • manual Manually open the request, defaults to false.
requests('https://google.com/foo/bar', { streaming })
.on('data', function (chunk) {
  console.log(chunk)
})
.on('end', function (err) {
  if (err) return console.log('connection closed due to errors', err);

  console.log('end');
});

Events

In the example above you can see the that we're listing to various of events. The following events are emitted:

  • data A new chunk of data has been received. It can be a small chunk but also the full response depending on the environment it's loaded in.
  • destroy The request instance has been fully destroyed.
  • error An error occurred while requesting the given URL.
  • end Done with requesting the URL. An error argument can be supplied if the connection was closed due to an error.
  • before Emitted before we send the actual request.
  • send Emitted after we've succesfully started the sending of the data.

requests#destroy

Destroy the running XHR request and release all the references that the requests instance holds. It returns a boolean as indication of a successful destruction.

requests.destroy();

Requests.requested

The total amount of requests that we've made in this library. It also serves as unique id for each request that we store in .active.

Requests.active

An object that contains all running and active requests. Namespaced under request.requested id and the requests instance.

License

MIT