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

@luojia/browser-filedownloader

v1.0.4

Published

file downloader for browser

Downloads

7

Readme

browser-FileDownloader

File downloader for browser

Feature

This downloader will try resume the progress at the breakpoint if available.

Note: This downloader uses fetch() to fetch content, resources from other domains must have correct CORS headers.

Get

1. Directly use dist/FileDownloader.js

Just load FileDownloader.js by script tag and the FileDownloader is the class object.

2. Install from npm

npm i @luojia/browser-filedownloader

Then in your javascript code:

import FileDownloader from '@luojia/browser-filedownloader'

Usage

const downloader=new FileDownloader(url,{
	//should it start downloading after the instance created.
	autoStart:true,

	autoRetry:10,//retry times

	//if you don't want to process the result, set this to true and the result will be saved to you device.
	autoSave:false,

	//when autoSavem is true, you can set the filename here.
	//the file extension is not required, the browser will add it automatically based on file mime type.
	fileName:`name`,

	fetchOptions:{},//options for fetch()

	//retry if stream stucked. If there is no byte received in 1 second, it is treated as stucked.
	retryWhenStuck:true,

	//a function for progress events
	progress(loaded,total){
		console.log('downloaded:',loaded,'of',total,'bytes');
	},

	//a function for loaded result
	load(blob,objectURL){
		//you don't need to set this function if autoSave is true

		//here is what autoSave does
		let a = document.createElement('a');
		a.href=objectURL;
		a.download = encodeURIComponent(this.opts.filename);
		a.click();
	},

	//a function for download error
	error(err){
		console.error(err);
		//if an error occurred, the downloader will stop the task
		//when retry times reach the limit, an error will emit too
	}
});

//start downloading, you don't need to call this if autoStart is true
downloader.start();

//abort the downloader
downloader.abort();

//close the downloader and clear buffers
downloader.close();