Here is my code:
var transformed = _(original).map(function (c) {
return {
lat: wgs2gcj(c.latitude, c.longitude).lat
lng: wgs2gcj(c.latitude, c.longitude).lng
}
});
Let's say wgs2gcj
is a function from a third-party library and will take a long time to compute. Is there a way to do the calculation only once?