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

  • Home
  • SEARCH
  • 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 7951503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:34:54+00:00 2026-06-04T02:34:54+00:00

I need some help on syntax with node.js promises . In readme for node.js

  • 0

I need some help on syntax with node.js promises. In readme for node.js module called q https://github.com/kriskowal/q is written something I don’t understand.

Why do they always write return before promise?

return Q.fcall(eventualAdd, 2, 2);

How do I make an asynchronous function with callback into function that returns promise? I try

function doThis(a,b, callback) { var result = a+ b; setTimeout( callback, 2000, result);}
Q.ncall(doThis, 2,3).then( function(result) { alert(result); });

I think after 2000 it must alert with 5 but nothing happens.

  • 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-04T02:34:55+00:00Added an answer on June 4, 2026 at 2:34 am
    1. The reason is that in that case they want to return the promise to the caller of the current function.

    2. I’ve done this in my own program and it is done thus:

      • First note that the second argument of Q.ncall([function], [this], [arguments,...]) is this.
      • Secondly note that the arguments to the callback given by Q.ncall to the given function are the same as all other node.js callbacks (error, result) thus the need to give the callback null as the error on success.

        var Q = require('q');
        
        function doThis(a,b, callback) { 
          var result = a + b;
          setTimeout(function () { callback(null, result) }, 2000);
        }
        
        Q.ncall(doThis, null, 2, 3).then(function(result) { console.error(result); });
        
      • This code works as you describe; note the differences.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Need some help from javascript gurus. I have one page where http://www.google.com/finance/converter is embedded
I need some help in C syntax, more about C casting syntax. All information
I just need some quick help on syntax. I'm doing a WPF project and
I need some help with my syntax. I need the possibility to upload either
I have a conditional statement that I need some help with the syntax: if
this might be really simple, but just need some help in getting the syntax
I need a little help with some Emacs syntax highlighting troubles. I'd like to
I need some help with jQuery syntax. I'm trying to modify the opacity effect
I am brand new to python, and I need some help with the syntax
i need some help with switch/case statement syntax im trying to use onClick to

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.