0.3.6 • Published 9 years ago

wgetjs v0.3.6

Weekly downloads
7
License
MIT
Repository
github
Last release
9 years ago

wgetjs NPM version Build Status Dependency Status License

Ultra simple async retrieval of remote files over http or https

Install

npm install wgetjs

Usage

var wget = require('wgetjs');

wget(url);

wget(url, callback);

wget({url: url, dest: destination_folder_or_filename}, callback);

wget({url: url, dry: true}); // dry run, nothing loaded, callback passing parsed options as data

Examples

var wget = require('wgetjs');

wget('https://raw.github.com/angleman/wgetjs/master/angleman.png');   // angleman.png saved to current folder

wget({
        url:  'https://raw.github.com/angleman/wgetjs/master/package.json',
        dest: '/tmp/',      // destination path or path with filenname, default is ./
        timeout: 2000       // duration to wait for request fulfillment in milliseconds, default is 2 seconds
    },
    function (error, response, body) {
        if (error) {
            console.log('--- error:');
            console.log(error);            // error encountered
        } else {
            console.log('--- headers:');
            console.log(response.headers); // response headers
            console.log('--- body:');
            console.log(body);             // content of package
        }
    }
);

// dry run
wget({
    url: 'https://raw.github.com/angleman/wgetjs/master/package.json',
    dest: '/tmp/',
    dry: true
    }, function(err, data) {        // data: { headers:{...}, filepath:'...' }
        console.log('--- dry run data:');
        console.log(data); // '/tmp/package.json'
    }
);

License: MIT

0.3.6

9 years ago

0.3.4

9 years ago

0.3.3

11 years ago

0.3.1

11 years ago

0.2.5

11 years ago

0.2.4

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.1.8

11 years ago

0.1.7

11 years ago

0.1.2

11 years ago

0.1.6

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.1

11 years ago