2
노드 jsync forEach 루프에서 작업하고 있습니다. 특정 조건이 발생할 때 비동기 루프를 종료하고 싶습니다. 나는 콜백 콜백을 시도했다. 하지만 작동하지 않는 것 같습니다. 어떻게 해결할 수 있을까요? 비동기 루프를 종료 할 수 있습니까?특정 조건이 발생할 때 async.forEach 루프를 종료하는 방법 + 노드
async.forEach(usertype.permissions, function (permission, cb) {
if (usertype.type === 'super_admin') {
console.log('super admin')
flag = 1;
// here i want to exit from the loop
//return cb();
}
if (permission.description === 'Can this use?' && permission.default_value.indexOf('YES') > -1) {
flag = 1;
return cb();
}
else {
if (permission.description === 'Ca?' && permission.default_value.indexOf('YES') > -1) {
flag = 1;
console.log('permission to advance')
return cb();
}
else {
cb();
}
}
}, function() {
// The code i want to execute after exit from the loop
})