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 🙏

© 2026 – Pkg Stats / Ryan Hefner

filedljs

v0.1.3

Published

A small utility library for downloading files from the web, while providing a progress reporting

Readme

filedljs (file download js)

A small utility library for downloading files from the web, providing the following features:

  • Accepts an onProgress callback, which receives a state object to indicate the progress of the downloading
  • Automatically monitor the download, and abort it if it is halted for a specific period (configurable)
  • Delete file if download didn't complete successfully (configurable)
  • Automatically retry downloading the file if something went wrong, and the maximum number of download attempts is configurable

Installing

Clone using git

git clone  https://github.com/waelhasan/filedljs.git  filedljs
cd filedljs/
npm install

Install with npm

npm install --save filedljs

Testing

npm test

Usage

const { downloadFile } = require('filedljs');
const logProgress = require('./logProgress')

downloadFile(
    <file_path>, // optional
    <file_url>,
    <options_object> // optional
)
    .then(() => {})
    .catch(error => {})

Examples

  • Using the original name of the file, and specifying the download folder
const { downloadFile } = require('filedljs');
const logProgress = require('./logProgress')

downloadFile(
    'http://file.allitebooks.com/20180714/React%20in%20Action.pdf',
    {
        baseDir: './files'
    }
)
    .then(() => console.log('[!!!] END OF DOWNLOAD'))
    .catch(error => console.log('[x] ERROR DOWNLOADING', error))
  • Specifying the full path and file name
downloadFile(
    './files/test.pdf',
    'http://file.allitebooks.com/20180714/React%20in%20Action.pdf',
    {
        onProgress: (state) => logProgress(state)
    }
)
  • Prevent deleting the file if the download didn't complete (default: true)
downloadFile(
    'http://file.allitebooks.com/20180714/React%20in%20Action.pdf',
    {
        deleteIfLessSize: false
    }
)
  • Specify the maximum allowed time for download halt (default: 1 minute)
downloadFile(
    'http://file.allitebooks.com/20180714/React%20in%20Action.pdf',
    {
        downloadHaltMaxTime: 2 * 60 * 1000, // in milliseconds
    }
)
  • Prevent creating the file path if it doesn't exist (default: true)
downloadFile(
    'http://file.allitebooks.com/20180714/React%20in%20Action.pdf',
    {
        createPathIfNotExist: false
    }
)
  • Automatically retry downloading the file for 3 times
downloadFile(
    'http://file.allitebooks.com/20180714/React%20in%20Action.pdf',
    {
        maxِAttempts: 3
    }
)
  • Using all default values
downloadFile('http://file.allitebooks.com/20180714/React%20in%20Action.pdf')

Default options:

These are the default values of the option object fields:

const defaultOptions = {
    baseDir: '.',
    createPathIfNotExist: true,
    downloadHaltMaxTime: 1 * 60 * 1000,
    onProgress: function () { },
    deleteIfLessSize: true,
    maxِAttempts: 2
};

Todo:

  • Add more tests:
    • unit tests
    • testing the download functionality (mocking the network)
    • testing ProgressMonitor (mocking timers)
  • Add proper comments

Authors

Contributors

  • M4rk9696 - M4rk9696 Added some unit tests

License

This project is licensed under the MIT License - see the LICENSE.md file for details