Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

nue

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nue

An async control-flow library suited for the node event loop.

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5.5K
decreased by-0.98%
Maintainers
1
Weekly downloads
 
Created
Source

nue — An async control-flow library suited for the node event loop

nue is an async control-flow library.

Examples

JavaScript

var nue = require('nue');

step1();

function step1() {
  console.log('step1 start');
  nue.parallel([
    function(){
      console.log('aaa');
    },
    function(){
      console.log('bbb');
    }], 
    function(err){
      if (err) throw err;
      console.log('step1 end\n');
      step2();
    }
  );
}

function step2() {
  console.log('step2 start');
  nue.series([
    function () {
      console.log('ccc');
      this.next('test', 2);
    },
    function (a, b){
      console.log('ddd ' + a + b);
      this.next();
    }],
    function (err) {
      if (err) throw err;
      console.log('step2 end\n');
      step3();
    }
  );
}

function step3() {
  console.log("step3 start");
  var q = nue.parallelQueue(
    function (data){
      console.log('data: ' + data);
    },
    function (err) {
      if (err) throw err;
      console.log('step3 end\n');
      step4();
    }
  );
  for (var i = 0; i < 10; i++) {
    q.push(i);  
  }
  q.complete();
}

function step4() {
  console.log("step4 start");
  var q = nue.seriesQueue(
    function (data){
      console.log('data: ' + data);
      this.next();
    },
    function (err) {
      if (err) throw err;
      console.log('step4 end\n');
    }
  );
  for (var i = 0; i < 10; i++) {
    q.push(i);
  }
  q.complete();
}

Result

step1 start
aaa:
bbb:
step1 end

step2 start
ccc:
ddd: test, 2
step2 end

step3 start
data: 0
data: 1
data: 2
data: 3
data: 4
step3 end

step4 start
data: 0
data: 1
data: 2
data: 3
data: 4
step4 end

Keywords

FAQs

Package last updated on 29 Jan 2012

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