Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7855967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:32:36+00:00 2026-06-02T20:32:36+00:00

EDIT thx to all the answers, and finally I decide to use some tools

  • 0

EDIT

thx to all the answers,
and finally I decide to use some tools like Step,

all I need is “flow control” and don’t want any thing else which may slow down the performance (I don’t know how much exactly it would effect or the effect just can be ignored).

So I just create a little tool for flow control:

line.js

/**
 * Create the "next" function
 * 
 * @param {Array} tasks 
 * @param {Number} index
 * @param {Number} last
 */
var next = function(tasks, index, last) {

    if (index == last) {

        return tasks[index + 1];
    }
    else {

        return function(data) {

            var nextIndex = index + 1;
            tasks[nextIndex](next(tasks, nextIndex, last), data);
        };
    }
};

/**
 * Invoke functions in line.
 */
module.exports = function() {

    var tasks = arguments,
        last = tasks.length - 2;

    tasks[0](next(tasks, 0, last));
};

usage:

var line = require("line.js");
line(function(next) {

    someObj.find(function(err, docs) {

        // codes
        next(docs);
    });
}, function(next, docs) {

    // codes
});

Hope this helps.

EDIT END

As all know,
Node’s built-in or third-part modules often provides async API,
and using “callback” function for dealing the results.

It’s cool but sometimes would code like this:

                   //some codes
              }
         }
    }
}

codes like this are hard to read.

I know “deferred” library can solve such problem,
Is there any good “deferred” module for Node?
And How is the performance if I code Node with “deferred”?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T20:32:39+00:00Added an answer on June 2, 2026 at 8:32 pm

    It is a large problem with Node-based code; you frequently grow “callback pyramids”. There are several approaches to dealing with the problem:

    Code style:

    Use this annoyance as an opportunity to break your code into bite sized chunks. It means you’re likely going to have a proliferation of tiny named funcs – that’s probably just fine, though! You might also find more opportunities for reuse.

    Flow-control Libraries

    There are exactly 593.72 billion flow control libraries out there. Here’s some of the more popular ones:

    • Step super basic serial & parallel flow management.
    • seq is a heavier but more feature-full flow control library.
    • There’s plenty more. Search the npm registry for “flow” and “flow control” (sorry, doesn’t appear to be linkable)

    Language Extensions

    There are several attempts to provide a more synchronous-feeling syntax on top of JavaScript (or CoffeeScript), often based on the concepts behind the tame paper.

    • TameJS is the OkCupid team’s answer to this.
    • IcedCoffeeScript they’ve also ported TameJS over CoffeeScript as a fork.
    • streamline.js is very similar to TameJS.
    • StratifiedJS is a heavier approach to the problem.

    This route is a deal-breaker for some:

    • It’s not standard JavaScript; if you are building libraries/frameworks/etc, finding help will be more difficult.
    • Variable scope can behave in unexpected ways, depending on the library.
    • The generated code can be difficult to debug & match to the original source.

    The Future:

    The node core team is very aware of the problem, and are also working on lower level components to help ease the pain. It looks like they’ll be introducing a basic version of domains in v0.8, which provide a way of rolling up error handling (avoiding the common return err if err pattern, primarily).

    This should start to lay a great foundation for cleaner flow control libraries, and start to pave the way for a more consistent way of dealing with callback pyramids. There’s too much choice out there right now, and the community isn’t close to agreeing on even a handful of standards yet.

    References:

    • Mixu’s Node book has an awesome chapter on this subject.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

edit 2 If you stumble across this, check both answers as I'd now use
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
EDIT: Thx to suggestions from the mailing list I realized that the problem I
I'd like to select all the checkboxes that are children of where I clicked.
I try to kill all processes of a specified user. i use Try Shell(C:\WINDOWS\system32\taskkill.exe
EDIT 07/14 As Bill Burgess mentionned in a comment of his answer, this question
EDIT: I was an idiot. I simply had an image that was vertically long,
EDIT: See my answer below--> I am wanting to have a view that when
Edit (updated question) I have a simple C program: // it is not important
EDIT: iam using ajax to load text in my content that is why onload

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.