Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function difference(polygon1, polygon2) {
const geom1 = getGeom(polygon1);
const geom2 = getGeom(polygon2);
const properties = polygon1.properties || {};
const differenced = polygonClipping.difference(geom1.coordinates, geom2.coordinates);
if (differenced.length === 0) return null;
return multiPolygon(differenced, properties);
}