multipart-get
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

multipart-get Travis CI Build Status

Run multiple http requests in parallel. Useful for downloading a large file with higher speeds.

NPM Badge

Install

npm install multipart-get

Usage

const { promises: fs } = require("fs")
const multipartGet = require("multipart-get")

await fs.writeFile("unicorn.png", await multipartGet("https://example.com/unicorn.png"))

API

multipartGet(url, options?)

Returns a promise which resolves with a buffer.

url

Type: string

The url to send the http requests to.

options

Type: object

Same options as got in addition to the following:

threads

Type: number
Default: Amount of cpu cores

The number of request threads to use in parallel.

retries

Type: number
Default: 3

The maximum amount of times to try downloading each chunk of data before failing.

Progress updates

You can call .onProgress on the resulting promise and provide it with a callback to receive progress updates on the http request. The callback will be called with a decimal between 0 and 1 representing the completion percentage.

const { promises: fs } = require("fs")
const multipartGet = require("multipart-get")

const request = multipartGet("https://example.com/unicorn.png")

request.onProgress(percent => {
	console.log(`The request is now ${Math.round(percent * 100)}% complete.`)
})

await fs.writeFile("unicorn.png", await request)

Package Sidebar

Install

npm i multipart-get

Weekly Downloads

1

Version

1.1.1

License

MIT

Unpacked Size

6.7 kB

Total Files

6

Last publish

Collaborators

  • richienb