1.0.2 • Published 5 years ago

fetchsource v1.0.2

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

fetchsource

High performance fetch source, support continue transfering from break point.

NPM version License npm node

npm install fetchsource
const Fetch = require('fetchsource');
// options: maxRedirects:number timeout:number(ms) headers:object output:string(fetch file path) url:string

const fetchUrl = 'https://github.com/chenxianming/sqapi/archive/master.zip';

let fetchSource = new Fetch({
    url:fetchUrl,
    timeout: 6000,
    output: './temp',
    onProgress(len, cur, tol) {
        console.log( ~~( cur / tol * 100 ) + '%' );
        console.log( len, cur, tol );
    }
});
// By chain called
fetchSource.then( ( request ) => {
    console.log('The file save as ./temp');
} ).catch( e => console.log(e) );
// By async/await
( async() => {
    try{
        await fetchSource;
        console.log('The file save as ./temp');
    }catch(e){
        console.log(e);
    }
} )();
1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago