A fire-and-forget HTTP request queue implementation for browsers.


License
ICU
Install
npm install @style/http-queue@3.3.0-beta.4

Documentation

@style/http-queue Standard Version wercker status

A fire-and-forget HTTP request queue implementation for browsers.

Installation

npm i --save @style/http-queue

Usage example

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();
};

Debugging

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:*';

Development

Available npm scripts

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.

Semantic commit messages

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.