Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

stack-queue

findhit9GPL v30.0.6

Execution stacks compatible with promises

stack, queue, promisable, bluebird, connect, http, node, express, util

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! :)

changelog

upcoming

0.0.6

  • Add support for auto-nexting sync functions (detection is made by checking if the length of function parameters is the same as the length of arguments supplied on .dispatch arguments)

0.0.5

  • Support for providing options on construction: new Stack( options )
  • Added options.breakOn option which allows developers to set when a stack should break. Note: Stack will ALWAYS break on Error.

0.0.4

  • Debug is now using pattern module-name:file/path

0.0.3

  • Allow stack break with a string or an object return

0.0.2

  • Allow queue pass on instance construction

0.0.1

  • First production ready version