0
async.map
이상의 일련의 통화가있는 경우 결과가 보장됩니까? 아니면 단순히 요청이 끝난 결과입니까? 예 :async.map 보장 결과가 순서대로 전달됩니까?
var requestList = [
{ method: 'GET', url: '/something1' },
{ method: 'GET', url: '/something2' },
{ method: 'GET', url: '/something3' }];
// async map the requests together, and handle the result in
// the callback.
async.map(requestList, function(obj, callback) {
request(obj, function(error, response, body) {
if(!error && response.statusCode == 200) {
var body = JSON.parse(body);
callback(null, body);
} else {
callback(error || response.statusCode);
}
});
}, function(err, result) {
if(err) {
console.log('Error!');
} else {
// is result guarenteed to be in the order: [/something1, /something2, /something3] ?
}
});
네, 반복기와 배열에 대한 순서가 정해져 있습니다. 객체 키의 순서가 유지되도록 시도됩니다. – megawac