fetch-scheduler
v0.4.0
Published
Large-scale fetch request scheduling library
Downloads
5
Readme
fetch-scheduler
Large-scale fetch request scheduling library
DEMO
Install
NPM
npm i fetch-scheduler
# or
yarn add fetch-scheduler
CDN
<script src="https://unpkg.com/fetch-scheduler/dist/fetch-scheduler.js"></script>
API
FetchScheduler
- constructor(options)
import {
FetchScheduler
} from 'fetch-scheduler';
const fetchScheduler = new FetchScheduler({
requestCount: 6 //Concurrent number of fetch requests
});
// if you use cdn
// const fdnd = new fs.FetchScheduler({...});
methods
createFetch(url, fetchOptions)
create a fetch,return a Promise
const promise = fetchScheduler.createFetch('http://abc.com', {
// ...
});
promise.then(res => {
res.json()
}).then(json => {
// ....
}).catch(err => {
//...
})
// promise.cancel(); cancel fetch request
// promise.remove(); //remove promise from fetchScheduler
- getCurrentInfo()
get current fetchScheduler statistical information
const info = fetchScheduler.getCurrentInfo();
console.log(info);