我使用node.js异步包,特别是forEachSeries,根据从数组中绘制的参数进行一系列http请求。在每个请求的回调中,我有一些if/else语句来响应不同类型的响应。当使用node.js async forEachSeries时,是否存在与“继续”等效的语句?
// 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
}
}
有没有等同于'继续',我可以使用里面的其他如果上面?这在技术上不在循环内,所以继续不起作用。
有一个理由让你没有访问到内部的'continue'声明像'if/else'这样的控制结构。你究竟想要做什么?因为它看起来像你需要检查你的逻辑... – 2012-04-11 13:18:55
!response.results很可能是由于服务器的一些速率限制。目前,我可以返回上面的请求所在的forEachSeries上的回调函数(),但这种方法存在一些潜在的数据丢失问题。试图找出是否有相当于在node.js forEachSeries中继续。类似于每个jQuery $中使用return true的方式。 – TankofVines 2012-04-11 13:29:06