9.0.0-alpha.4 • Published 4 years ago
@xingrz/download2 v9.0.0-alpha.4
@xingrz/download2 
Download and extract files.
Install
npm install --save @xingrz/download2Usage
import { writeFileSync, createWriteStream } from 'fs';
import download from '@xingrz/download2';
(async () => {
await download('http://unicorn.com/foo.jpg', 'dist');
writeFileSync('dist/foo.jpg', await download('http://unicorn.com/foo.jpg'));
download('unicorn.com/foo.jpg').pipe(fs.createWriteStream('dist/foo.jpg'));
await Promise.all([
'unicorn.com/foo.jpg',
'cats.com/dancing.gif'
].map(url => download(url, 'dist')));
})();Proxies
To work with proxies, read the got documentation.
API
download(url[, destination][, options])
Returns both a Promise<Buffer> and a Duplex stream with additional events.
If extract: true is set, returns Promise<File[]> instead of Promise<Buffer>.
url
Type: string
URL to download.
destination
Type: string (optional)
Path to directory where your file will be written.
options
Type: Object
Same options as got and @xingrz/decompress in addition to the ones below.
extract
Type: boolean
If set to true, try extracting the file using @xingrz/decompress.
filename
Type: string
Name of the saved file. Will be ignored if extract is set to true.
License
MIT © Kevin Mårtensson, XiNGRZ
9.0.0-alpha.4
4 years ago
9.0.0-alpha.3
4 years ago
9.0.0-alpha.2
4 years ago
9.0.0-alpha.1
4 years ago
9.0.0-alpha.0
4 years ago