使用node.js async forEachSeries时是否有等效的'continue'语句?

时间:2012-04-11 13:15:58

标签: javascript node.js asynchronous async.js node-async

我正在使用node.js异步包,特别是forEachSeries,根据从数组中提取的参数发出一系列http请求。在每个请求的回调中,我有一些if / else语句来响应不同类型的响应。

// This is the callback of a GET request inside of a forEachSeries
function(error, response) {
    if (response.results) {
        // Do something with results
    }
    else if (!response.results) {
        // Would like to use a continue statement here, but
        // this is not inside of a loop
    }
    else {
        // Do something else
    }
}

是否有相当于'继续'如果上面我可以在其他内部使用?这在技术上不属于循环,所以继续不起作用。

1 个答案:

答案 0 :(得分:5)

因为它只是一个函数,你应该能够从return获得相同的效果:

else if (!response.results) {
    return;
}