Skip to content Skip to sidebar Skip to footer

Do Something N Times Using Bluebird Promises

I am trying the Promises everyone is so excited about. They're are supposed to reduce code complexity which is a feature I've yet to observe. In my case, I have a function that ret

Solution 1:

To achieve your goal you could use mapSeries() to iterate n times over an empty array:

    return Promise.mapSeries(new Array(4), function() {
        return press(B_KEY, 3000, client, device);
    });

For more info about mapSeries() see the reference


Post a Comment for "Do Something N Times Using Bluebird Promises"