New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

node-callback-queue

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-callback-queue

Callback queue

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-83.33%
Maintainers
1
Weekly downloads
 
Created
Source

node-callback-queue

Callback queue

Usage

    const queue = require('node-callback-queue');
    
    function onComplete(err, result){
        if(err) {
            return console.log('Error: %s', err);
        }
        console.log('Result %s', result);
    }
    
    queue
    (
        // complete callback
        onComplete,
        
        // initial callback
        function(next) {
            next(null, 'param 1', 'param 2');
        },
        
        // queued callback
        function(arg1, arg2, next){
            console.log("args %s, %s", arg1, arg2);
            // output:
            // args param 1, param 2
            next(null, arg1, arg2, true, 123);
        },
        
        // queued callback
        function(arg1, arg2, arg3, arg4, next) {
            console.log("args %s, %s, %s, %s", arg1, arg2, arg3, arg4);
            // output:
            // args param 1, param 2, true, 123
            next(null, "another arg");
        },
        
        // queued callback
        function(arg1, next){
            console.log("args %s", arg1);
            // output:
            // args another arg
            
            if(arg1 === "another arg") {
                // lets stop execution
                return next(new Error("Failed"));
            }
            
            // put args as many as next callback requires
            next(null, 1, 2, 3, 4, 5);
        },
        
        // this callback and next callbacks will be ignored
        // because previous callback send an error as first parameter
        // to "next"
        function(arg1, arg2, arg3, arg4, arg5, next){
            // if this method was executed
            // this would be final call of current queue with the result
            var result = "result";
            next(null, result);
        }
    );

Keywords

FAQs

Package last updated on 25 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc