stack-queue

Execution stacks compatible with promises

Showing:

Popularity

Downloads/wk

1

GitHub Stars

6

Maintenance

Last Commit

7yrs ago

Contributors

0

Package

Dependencies

3

License

GPL-3.0-or-later

Type Definitions

Tree-Shakeable

No?

Categories

Readme

stack-queue

Test Status Dependency Status

Execution stacks compatible with promises

Installation

npm install --save stack-queue

Usage

Have you ever used express or connect?

If so, you should know how they share they stack with function ( req, res, next ).

This module allows you to apply a nextable queue method in any circunstance, and compatible with promises!

Lets see some examples:

connect Example

This is how you would implement a connect-like example:


var http = require( 'http' ),
    Stack = require( 'stack-queue' );

var stack = new Stack(),
    server = http.createServer( stack.dispatch.bind( stack ) ).listen( 80 );

// Now you should be able to stack things on request
stack.queue( function ( req, res, next ) {
    req.foo = 'bar';

    next();
});

// You can even chain stack.queue calls
stack
    .queue(function ( req, res ) {
        res.statusCode = 200;

        return somePromisedMethod();
    })
    .queue(function ( req, res, next ) {
        res.write( 'hey' );

        next();
    });

// Or provide an array with functions
stack.queue([
    function () { return true; },
    function () { throw new Error("WOW"); }
]);

Do you have more examples?

Please Pull Request them! :)

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial