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

@luminati-io/miniget

v4.2.2-lum.1

Published

A small HTTP(S) GET request library, with redirects and streaming.

Downloads

5

Readme

node-miniget

A small http(s) GET library with redirects, retries, reconnects, concatenating or streaming, and no dependencies. This keeps filesize small for potential browser use.

Depfu codecov

Usage

Concatenates a response

const miniget = require('miniget');

miniget('http://mywebsite.com', (err, res, body) => {
  console.log('webpage contents: ', body);
});

// with await
let body = await miniget('http://yourwebsite.com').text();

Request can be streamed right away

miniget('http://api.mywebsite.com/v1/messages.json')
  .pipe(someWritableStream());

API

miniget(url, [options])

Makes a GET request. url can be a string or a URL object. options can have any properties from the http.request() function, in addition to

  • maxRedirects - Default is 10.
  • maxRetries - Number of times to retry the request if there is a 500 or connection error. Default is 2.
  • maxReconnects - During a big download, if there is a disconnect, miniget can try to reconnect and continue the download where it left off. Default is 0.
  • backoff - An object with inc and max used to calculate how long to wait to retry a request. Default is { inc: 100, max: 10000 }.
  • highWaterMark - Amount of data to buffer when in stream mode.
  • transform - Use this to add additional features. Called with the object that http.get() or https.get() would be called with. Must return a transformed object.
  • acceptEncoding - An object with encoding name as the key, and the value as a function that returns a decoding stream.
    acceptEncoding: { gzip: () => require('zlip').createGunzip(stream) }
    Given encodings will be added to the Accept-Encoding header, and the response will be decoded if the server responds with encoded content.

Defaults are held in miniget.defaultOptions and can be adjusted globally.

Miniget returns a readable stream, errors will then be emitted on the stream. Returned stream has additional methods added, and can emit the following events.

Stream#destroy([error])

Destroys the request.

Stream#destroyed

Set to true after Stream#destroy() has been called.

Stream#text()

Returns a promise that resolves to the concatenated contents of the response.

let body = await miniget('http://yourwebsite.com').text();

Event: redirect

  • string - URL redirected to.

Emitted when the request was redirected with a redirection status code.

Event: retry

  • number - Number of retry.
  • Error - Request or status code error.

Emitted when the request fails, or the response has a status code >= 500.

Event: reconnect

  • number - Number of reconnect.
  • Error - Request or response error.

Emitted when the request or response fails after download has started.

Event: request

Emitted when a video request is made, including after any redirects, retries, and reconnects.

Event: response

Emitted when a video response has been found and has started downloading, including after any successful reconnects.

Forwarded events

Any events emitted from the request or response objects will be forwarded to the miniget stream.

Install

npm install miniget

Tests

Tests are written with mocha

npm test