1.1.0 • Published 7 years ago

@brocan/sequ v1.1.0

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

sequ

sequ is a basic queue which will execute promise-providing functions sequentially, only one-at-a-time.

Usage

const Sequ = require('@brocan/sequ');

// create a new sequ
const sequ = Sequ();

sequ.do(() => {
    return new Promise((resolve, reject) => {
        /*
         *  do something nasty
         */
    });
})
.then(result => {
    // will be executed when the previously created promise finishes execution
})
.catch(err => {
    // will be executed if the previously created promise fails
});

API

length: Number

The number of elements in the Sequ.

do(provider: () => Promise): Promise

Places the passed promise provider function into the queue. Returns a promise which is resolved when the original promise is resolved.