Hacker News new | ask | show | jobs
by tonyle 3712 days ago
When I first got into promises, they were annoying for certain tasks. Something as simple as download a list of 1000 files was hard to do since you didn't want all the calls to fire off at once. After a long journey with various techniques, I found out Bluebird map had a concurrency parameter.

return Promise.map(arrayOfUrlsToDownload,downloadAndParseFunction,{concurrency:1})

One line for all your basic scraping/parsing needs.

1 comments

There's also [Bottleneck](https://github.com/SGrondin/bottleneck) for more fine grained concurrency.