nyc-bookstores/node_modules/mapbox.js/src/util.js
2013-05-27 13:45:59 -07:00

24 lines
567 B
JavaScript

if (typeof mapbox === 'undefined') mapbox = {};
mapbox.util = {
// Asynchronous map that groups results maintaining order
asyncMap: function(values, func, callback) {
var remaining = values.length,
results = [];
function next(index) {
return function(result) {
results[index] = result;
remaining--;
if (!remaining) callback(results);
};
}
for (var i = 0; i < values.length; i++) {
func(values[i], next(i));
}
}
};