Socket
Socket
Sign inDemoInstall

download-use-throw

Package Overview
Dependencies
23
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    download-use-throw

Download something - use it - finally delete it


Version published
Weekly downloads
3
Maintainers
1
Created
Weekly downloads
 

Readme

Source

download-use-throw

Download something - use it - finally delete it

npm Build Status styled with prettier npm Built with generator-ts-np

What?

This package helps you to temporarily download an image and apply your method on it. When you are finished using the downloaded content, the image will automatically get deleted.

This package is using Nodejs streams, means, more efficient.

Install

npm i --save download-use-throw

Usage

const useAndThrow = require('download-use-throw');
const path = require('path');

// path to the directory to which
// images are temporarily downloaded
const dirPath = path.join(__dirname, '/temp');

// url of the image to be downloaded
const imgUrl = "https://i.ytimg.com/vi/YQHsXMglC9A/maxresdefault.jpg";

// use and throw
useAndThrow(imgUrl, dirPath, imageHandler);

// function to apply on the downloaded image
function imageHandler(err, pathToImage, done) {
    if(err){
        // handle err

        return done(); // call to done will trigger the deletion process.
    }

    // use the image
    useTheImage(pathToImage); // your function
    // ...
    // ...
    // ...

    // when you finished using the image, call done()
    // which will trigger the deletion process
    done();
}

Call done() when you finished using the image, or you finished handling errors. It will initiate the deletion process.

Unclear about something? Please rise an issue.
Please report any issues at github.

used version of ts-np generator

Licence

MIT © Vajahath Ahmed

FAQs

Last updated on 03 Aug 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc