Answer the question
In order to leave comments, you need to log in
How to restrict reduce in node.js?
Good afternoon, there is an array which I sort through
result.reduce((lastRequestDone, item) => {
return lastRequestDone.then(() => somefunc());
})
result.reduce((lastRequestDone, item) => {
if(result.name !== 'some' && i <= 5){
return lastRequestDone.then(() => somefunc());
}
})
Answer the question
In order to leave comments, you need to log in
primitive example -
async.waterfall([
(callback) => {
// do something
if(result.name !== 'some' && i <= 5) callback(null, data);
return callback('err');
},
(data, callback) => {
return callback(result.reduce((lastRequestDone, item) => {
return lastRequestDone.then(() => somefunc());
}));
}
], function(err, result) {
if (err) return callback(err);
// do something
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question