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 8286091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:37:35+00:00 2026-06-08T11:37:35+00:00

Is there some framework similar to underscore that allows me to run async methods

  • 0

Is there some framework similar to underscore that allows me to run async methods on collections.

Something like _.each(collection, itemCallback, doneCallback).

For example:

_.each(items, function(item, token){
    item.someProperty = null;
  }, function(err){
     console.log("The loop is done");
  });

Edit: async.js actually doesn’t solve the problem. For example the following code

<script type="text/javascript" src="async.js"></script>
<script type="text/javascript">

var arr = ["a","b","c"];

async.forEach(arr, function(item, met){
    console.log(item);
},
function(err){
});
console.log("Done");

</script>

prints a b c Done

While I want it to print Done a b c

I can do it with underscore deffer but maybe there is some other lib that can do it without wrappers.

  • 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-08T11:37:36+00:00Added an answer on June 8, 2026 at 11:37 am

    Async.js module will do the trick. Your example is just too fast for you to fully notice it is actually working as you will expect. Here is an example with a small delay added so you can notice the actual order of execution:

    async.each([0,1,2,3,4,5,6,7,8,9], function(item, callback) {
      setTimeout(function() {
        console.log('>', item);
        callback();
      }, 2 * Math.random() * 1000);
    }, function(err) {
      console.log('> done');
    });
    
    console.log(':)');
    

    And the output:

    :)
    > 4
    > 5
    > 2
    > 7
    > 8
    > 3
    > 0
    > 1
    > 9
    > 6
    > done
    

    Also, to really do it asynchronous you might consider to use Web Workers; but for now Async.js provides you a really simple way to do something similar (but not actual Web Workers) named queue:

    var q = async.queue(function(item, callback) {
      setTimeout(function() {
        console.log('>>', item);
        callback();
      }, 2 * Math.random() * 1000);
    }, 5);
    
    q.drain = function() {
      console.log('>> done');
    };
    
    q.push([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]);
    
    console.log('B)');
    

    And the output:

    B)
    >> 1
    >> 2
    >> 5
    >> 6
    >> 4
    >> 3
    >> 0
    >> 7
    >> 8
    >> 9
    >> done
    

    And if finally you run both simultaneously, here is an example of the output:

    :)
    B)
    >> 2
    > 3
    >> 4
    >> 1
    > 8
    >> 6
    > 7
    > 1
    > 4
    >> 3
    > 0
    > 2
    >> 7
    >> 5
    > 6
    > 5
    > 9
    > done
    >> 8
    >> 0
    >> 9
    >> done
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there something similar to Stackless Python , i.e. a framework that supports continuations,
I am looking for some framework that allows me to create a Photo Gallery
i would like to ask, if there is some framework in Java which can
Using the built-in Ruby Minitest framework, is there a way to run some code
Is there some kind a engine for Json in the Zend framework, What I
Is there some kind of software that I can feed uploaded images to and
Is there some regex that can be passed to re-seq such that it will
There are some particular API's in Java that make it very good. However I
Let's say I have a PHP Model-View-Controller framework that maps an address like http://example.com/admin/posts/edit/5
Is there some open source code already written out there somewhere that will accept

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.