transformed = {
if (featureCollection && featureCollection.features.length) {
const bufferWidthinKM = 10;
if (featureCollection.features.length === 1) {
return turf.buffer(featureCollection, bufferWidthinKM);
} else {
return turf.buffer(
turf.union(...featureCollection.features),
bufferWidthinKM
);
}
} else {
throw new Error(
"Click on a region in the map above to see the transformed output!"
);
}
}