A fire-and-forget HTTP request queue implementation for browsers.
npm i --save @style/http-queue
import queue from '@style/http-queue';
async () => {
const { schedule, drain } = queue();
// Schedule some HTTP requests
schedule({verb: 'POST', url: 'http://analytics.stylelounge.de', data: {character: 'Almec'}});
schedule({verb: 'POST', url: 'http://analytics.stylelounge.de', data: {character: 'Amee'}});
schedule({verb: 'POST', url: 'http://analytics.stylelounge.de', data: {character: 'Darth Bane'}});
schedule({verb: 'POST', url: 'http://analytics.stylelounge.de', data: {character: 'Beed'}});
schedule({verb: 'POST', url: 'http://analytics.stylelounge.de', data: {character: 'Sio Bibble'}});
schedule({verb: 'POST', url: 'http://analytics.stylelounge.de', data: {character: 'Dengar'}});
schedule({verb: 'POST', url: 'http://analytics.stylelounge.de', data: {character: 'Feral'}});
// Let's drain the queue ("waits" until all requests has been sent OR terminates after configurable
// timeout; default = 3000 ms)
await drain();
};
The library uses the debug library internally. You can activate the debug messages by executing the following in your console:
localStorage.debug = '@stylelounge/http-queue:*';
name | description |
---|---|
npm run build |
Creates a clean build of this library (installs all npm packages , the TS typings and compiles everything). |
npm run lint |
Lints the TS code via tslint . |
npm run test (a.k.a. npm test ) |
Performs all the tests within the project. |
This project follows a pattern, called semantic commit messages. By using this convention it is possible to infer the next version number based on the last commit messages when creating a new release.