JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 100753
  • Score
    100M100P100Q157711F
  • License MIT

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

Package Exports

  • miniget

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (miniget) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-miniget

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

Build Status Dependency Status codecov

Usage

Concatenates a response

const miniget = require('miniget');

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

Request can be streamed right away

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

API

miniget(url, [options], [callback(err, body)])

Makes a GET request. options can have any options from the http.request() function, in addition to

maxRedirects - Default is 3. 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.

If callback is given, will concatenate the response, and call callback with a possible error, and the response body.

Miniget returns a readable stream if callback is not given, errors will then be emitted on the stream. Returned stream also contains an .abort() method.

Install

npm install miniget

Tests

Tests are written with mocha

npm test

License

MIT