节点asynchronous每个循环之间的延迟

我有一个对象,我正在迭代。 现在对于这个对象中的每一个键值对,我都需要调用一个可以产生a / o请求的函数,但是我需要在这些迭代之间等待。 这是函数会迭代,读取第一个对象,传递它的function,并等待n毫秒,n毫秒后它将读取第二对,传递它的function,并再次等待,直到列表中的对象结束。 我该怎么做呢?

目前这是我的代码大纲

async.forEachOfSeries(object1, function(value, key, callback) { //send switch status if(object1.key1 == some condition){ sql.query1 } some io request based on query result callback(); want some delay here }, function(err) { if( err ) { handle error } else { report success } } ) 

 Try this - async.forEachOfSeries(object1, function(value, key, callback) { //send switch status if(object1.key1 == some condition){ sql.query1 } some io request based on query result setTimeout(function () { callback(); }, 10000) }, function(err) { if( err ) { handle error } else { report success } } ) Set the timer delay to whatever time you want. Hope this helps.