nyc-bookstores/node_modules/mapbox.js/src/util.js

24 lines
567 B
JavaScript
Raw Normal View History

2013-05-27 20:45:59 +00:00
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));
}
}
};