Questions tagged [node-async]

Async is a utility module for node.js (although it can also be used in the browser) that provides powerful functions for working with asynchronous JavaScript

Async provides around 20 functions that include the usual 'functional' suspects (map, reduce, filter, each...) as well as some common patterns for asynchronous control flow (parallel, series, waterfall...).

All these functions assume you follow the convention of providing a single callback as the last argument of your async function.


Documentation :

185 questions
2
votes
2 answers

How to run parallel process with limit?

How to run in Nodejs parallel process but limit the number of process that exist in the current bulk? Example, I have an Array with 200 items ['word.doc', 'foo.pdf', 'a.txt', ...] and I need to run Work process for each item like so: Work.exe…
raxinaga
  • 411
  • 1
  • 6
  • 18
2
votes
2 answers

return true actually returns undefined using async

I'm trying to do something if the value is not exist, so I can update it. but isExist function always return undefined. what can I do with this? reference: Ero is already defined. async.forEachOf(idArray, function(value, key, cb) { rp(baseURL +…
boombamboo
  • 459
  • 2
  • 5
  • 14
2
votes
1 answer

How can I call callback function in async.eachSeries callback function

I'm trying to call callback function after eachSeries is done, but IT doesn't work at all. It doesn't print 2 that's supposed to print when It's called but It prints 4 after first function is called. Is there any idea about it? Thank…
boombamboo
  • 459
  • 2
  • 5
  • 14
2
votes
1 answer

Utilizing Async NPM Module

So... I recently came across this node module: async. I just need a little "show and tell" or a Best Practice approach for the situation I have below. Below you can see my function GetBearerToken which takes an argument {bearer_token:token} without…
2
votes
1 answer

Perform async functions in webdriverio

I've stuck with this problem as I am new to webdriverio. My requirement is I have a page which contains list of items(like buttons etc.) and I need to click each item one by one. But after clicking each item it will redirect to another section/page.…
chikku
  • 863
  • 1
  • 7
  • 19
2
votes
2 answers

async.parallel for large number of functions

I have a function that I want to call 1 million times. The function makes two calls to the database (first a SELECT and then an UPDATE). My current approach is to store these functions in an array and then call async.parallel on this array. I am…
pranavk
  • 1,774
  • 3
  • 17
  • 25
2
votes
2 answers

Resize images right after download in NodeJS, using request and gm modules

I'm trying to resize images right after I've downloaded them using nodejs, request and gm modules but I'm having a hard time understading to pipe stuff properly. var fs = require('fs'); var path = require('path'); var gm =…
Gab
  • 2,216
  • 4
  • 34
  • 61
2
votes
1 answer

No value for `distinct` has been declared

I am trying to add a new static method to my Mongoose Model. The method should accept the names of several fields and return an object with the distinct values of each of those fields. var mongoose = require('Mongoose'); var Schema =…
doicomehereoften1
  • 537
  • 1
  • 4
  • 12
2
votes
1 answer

Iterate large number of async calls / results in node.js (using ES6 / async / bluebird / generators)?

I am writing a utility in node.js that has to process and concatenate a large number of files every night. In synchronous pseudocode it would look like that (omitting try / catch for clarity): while (true) { var next = db.popNext(); if…
left4bread
  • 1,514
  • 2
  • 15
  • 25
2
votes
2 answers

async.series nested in async.eachSeries loop terminates early sending POST response

I am on the recieving end of a POST call which contains an array of objects (requestArray). Before I respond to the POST, I need to pass the array's objects through a series of functions, in sequence. I chose the async library to help me with this…
coolcat44
  • 31
  • 4
2
votes
1 answer

Making async callback functions in nodejs

I have confusing code that I'd like to modularize. I have a general ledger implemented in Mongodb. Transferring credits from john to adam appends the following document in the db.dummyTx: { "debitAccount": "john", "creditAccount": "adam", …
Amin Shah Gilani
  • 8,675
  • 5
  • 37
  • 79
2
votes
1 answer

Managing asynchronous Callbacks in Meteor

I'm using Meteor 1.* and Iron Router 1.*. I'm using Node.js calls on the server side in Meteor, outside of a Meteor-method -- specifically inside a server side Iron Router route. A portion of the code inside of the route looks similar to the…
Aaron
  • 3,068
  • 2
  • 21
  • 44
2
votes
1 answer

Node async.series trouble

While building a fairly complex scraper i stumbled upon a problem with a control flow of my code. What's going on in code below: 1) request a URL 2) scrape NEWURL from the results 3) pass it to readability API as first async function 4) here comes…
2
votes
1 answer

Does async.parallel also parallelise blocking code?

I'm trying to understand the behaviour of the async package in relation to parallelisation of code. From what I understand, it is helpful to structure code in order to avoid callback hell/soup, but is that the only advantage? async.parallel([ …
Julian H. Lam
  • 25,501
  • 13
  • 46
  • 73
2
votes
2 answers

Why async.map function works with the native fs.stat function?

async.map(['file1','file2','file3'], fs.stat, function(err, results){ // results is now an array of stats for each file }); As per documentation, the second argument is: iterator(item, callback) - A function to apply to each item in the …
gremo
  • 47,186
  • 75
  • 257
  • 421
1 2
3
12 13