download

Download and extract files over HTTP(S) with a single async call

Library
npm
v8.0.0
1,301stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
44/100Fair
Development Activity0
Maintenance20
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
55/100Fair
Architecture50
Code Quality55
Innovation45
Learning Curve70

download is a small Node.js library for fetching files over HTTP(S) that layers convenience on top of the got HTTP client. A single call returns both a Promise and a Node.js Duplex stream, so callers can await the downloaded buffer or pipe it directly to a destination.

Beyond plain fetching, download detects filenames from Content-Disposition headers or the URL path, infers missing extensions from the response MIME type, and can automatically extract downloaded archives (zip, tar, etc.) via the decompress package when the extract option is set.

What You Get

  • A single function that returns both a Promise<Buffer> and a readable/writable Duplex stream
  • Automatic destination filename resolution from Content-Disposition headers, URL path, or MIME type
  • Optional automatic extraction of downloaded archives via the decompress package
  • Pass-through of all got HTTP client options (proxies, headers, retries, etc.)
  • Support for downloading multiple URLs concurrently via Promise.all

Common Use Cases

  • Fetching a remote asset (image, dataset, binary) into memory during a build or CLI script
  • Downloading and unpacking a release tarball or zip as part of a scaffolding tool
  • Streaming a large remote file directly to disk without buffering it all in memory
  • Batch-downloading a list of URLs in parallel during a data pipeline

Under The Hood

Architecture: download’s entire implementation lives in a single ~100-line index.js. The exported function creates a got.stream(uri, opts) request stream immediately, then attaches a Promise chain via pEvent(stream, 'response') that buffers the response with get-stream, optionally runs it through decompress when opts.extract is set and the buffer is recognized as an archive by archive-type, or writes it to disk via make-dir + a promisified fs.writeFile. The Promise’s .then/.catch are copied onto the returned stream object, so callers can treat the same value as either a stream or a thenable. Tech Stack: built on got for the HTTP layer, decompress/archive-type/file-type for archive detection and extraction, content-disposition and ext-name for filename/extension resolution, and filenamify/make-dir/pify for filesystem safety — all CommonJS, targeting Node >=10. Code Quality: a single test.js (via ava + nock) covers the main download, extract, and stream-piping paths; the module is linted with xo. There are no type definitions and no code comments beyond the README, but the code is short enough that intent stays clear from structure alone. API Design: the API is a single function with heavily overloaded arguments (output can be omitted and shift into the options position), which keeps common calls terse but makes the signature harder to read from the type alone; documentation is limited to the README’s three usage snippets, and the package has been unmaintained since 2020 with contributors recommending got directly or newer alternatives for new projects.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search