Answer the question
In order to leave comments, you need to log in
Execution status of a nodejs async function?
There is an asynchronous function:
var fun = async(function(){
var list = 0;
while(await(status())){
list += await(anotherFun());
}
return list;
});
Answer the question
In order to leave comments, you need to log in
var counters = [] // массив
var fun = async(function(){
var state = {val: 0, id: Math.random()} // при запуске новый счетчик
var counterId = counters.push(state) - 1 // и теперь он доступен снаружи
var list = 0;
while(await(status())){
list += await(anotherFun());
state.val++ // увеличиваем значение счетчика
}
// delete counters[counterId] // если хотите, можно подчистить
return list;
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question