@turf/difference
Advanced tools
Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3
@@ -40,12 +40,15 @@ import polygonClipping from 'polygon-clipping'; | ||
function difference(polygon1, polygon2) { | ||
var geom1 = getGeom(polygon1); | ||
var geom2 = getGeom(polygon2); | ||
var properties = polygon1.properties || {}; | ||
var geom1 = getGeom(polygon1); | ||
var geom2 = getGeom(polygon2); | ||
var properties = polygon1.properties || {}; | ||
var differenced = polygonClipping.difference(geom1.coordinates, geom2.coordinates); | ||
if (differenced.length === 0) return null; | ||
if (differenced.length === 1) return polygon(differenced[0], properties); | ||
return multiPolygon(differenced, properties); | ||
var differenced = polygonClipping.difference( | ||
geom1.coordinates, | ||
geom2.coordinates | ||
); | ||
if (differenced.length === 0) return null; | ||
if (differenced.length === 1) return polygon(differenced[0], properties); | ||
return multiPolygon(differenced, properties); | ||
} | ||
export default difference; |
@@ -44,13 +44,15 @@ 'use strict'; | ||
function difference(polygon1, polygon2) { | ||
var geom1 = invariant.getGeom(polygon1); | ||
var geom2 = invariant.getGeom(polygon2); | ||
var properties = polygon1.properties || {}; | ||
var geom1 = invariant.getGeom(polygon1); | ||
var geom2 = invariant.getGeom(polygon2); | ||
var properties = polygon1.properties || {}; | ||
var differenced = polygonClipping.difference(geom1.coordinates, geom2.coordinates); | ||
if (differenced.length === 0) return null; | ||
if (differenced.length === 1) return helpers.polygon(differenced[0], properties); | ||
return helpers.multiPolygon(differenced, properties); | ||
var differenced = polygonClipping.difference( | ||
geom1.coordinates, | ||
geom2.coordinates | ||
); | ||
if (differenced.length === 0) return null; | ||
if (differenced.length === 1) return helpers.polygon(differenced[0], properties); | ||
return helpers.multiPolygon(differenced, properties); | ||
} | ||
module.exports = difference; | ||
module.exports.default = difference; |
@@ -1,2 +0,2 @@ | ||
import { Polygon, MultiPolygon, Feature } from '@turf/helpers' | ||
import { Polygon, MultiPolygon, Feature } from "@turf/helpers"; | ||
@@ -7,5 +7,4 @@ /** | ||
export default function difference( | ||
polygon1: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon, | ||
polygon2: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon | ||
polygon1: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon, | ||
polygon2: Feature<Polygon | MultiPolygon> | Polygon | MultiPolygon | ||
): Feature<Polygon | MultiPolygon> | null; | ||
{ | ||
"name": "@turf/difference", | ||
"version": "6.2.0-alpha.2", | ||
"version": "6.2.0-alpha.3", | ||
"description": "turf difference module", | ||
@@ -24,2 +24,6 @@ "author": "Turf Authors", | ||
"module": "dist/es/index.js", | ||
"exports": { | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
}, | ||
"types": "index.d.ts", | ||
@@ -32,8 +36,7 @@ "sideEffects": false, | ||
"scripts": { | ||
"bench": "npm-run-all prepare bench:run", | ||
"bench:run": "node bench.js", | ||
"bench": "node -r esm bench.js", | ||
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", | ||
"docs": "node ../../scripts/generate-readmes", | ||
"posttest": "node -r esm ../../scripts/validate-es5-dependencies.js", | ||
"prepare": "rollup -c ../../rollup.config.js", | ||
"test": "npm-run-all prepare test:*", | ||
"test": "npm-run-all test:*", | ||
"test:tape": "node -r esm test.js" | ||
@@ -51,7 +54,7 @@ }, | ||
"dependencies": { | ||
"@turf/helpers": "^6.2.0-alpha.2", | ||
"@turf/invariant": "^6.2.0-alpha.2", | ||
"@turf/helpers": "^6.2.0-alpha.3", | ||
"@turf/invariant": "^6.2.0-alpha.3", | ||
"polygon-clipping": "^0.14.3" | ||
}, | ||
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09" | ||
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409" | ||
} |
13390
9
261