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

fetch-to-tar

v0.2.1

Published

Dowload multiple urls into single .tar archive

Downloads

7

Readme

There are many great backend based solutions for downloading multiple files into one archive. There are many great software engineers who will tell you that this is the right way. But if you need a quick and lightweight solution that just work in a browser, then fetch-to-tar is for you.

How it works?

fetch-to-tar download files in small chunks using Fetch Api and Stream Api. Then it saves them to IndexedDB immediately as part of the GNU TAR format.

At the end of the download, it sticks together all chunks and returns as single Blob. All saved data in indexedDB will be deleted.

Basically this is a very simple attempt to make download like mega.nz. Without encryption and support for older browsers. This is more like an experiment. But it works.

Limitations

Installation

You can install fetch-to-tar using npm or yarn

npm install fetch-to-tar
yarn add fetch-to-tar

Usage

Basic usage example:

const { promise } = fetchToTar({
  entries: [
    { name: 'foo.txt', src: 'http://example.com/foo.txt' },
    { name: 'bar.txt', src: 'http://example.com/bar.txt' },
  ],
});

promise.then(({ blob }) => {
  console.log('Tadaaa:', blob);
});

How to show progress:

fetchToTar({
  entries: [
    { name: 'foo.txt', src: 'http://example.com/foo.txt' },
    { name: 'bar.txt', src: 'http://example.com/bar.txt' },
  ],

  onProgress(value, max) {
    console.log(`Progress is: ${value}/${max}`)
  }
});

How to cancel download:

const { promise, cancel } = fetchToTar({
  entries: [
    { name: 'foo.txt', src: 'http://example.com/foo.txt' },
    { name: 'bar.txt', src: 'http://example.com/bar.txt' },
  ],
});

if (SomeCondition) {
  cancel()
}

You can use enry name for creating folder structure:

fetchToTar({
  entries: [
    { name: 'one/foo.txt', src: 'http://example.com/foo.txt' },
    { name: 'two/bar.txt', src: 'http://example.com/bar.txt' },
  ],
});

License

MIT © Ruslan Tatyshev