@turf/difference 4.7.3 → 4.7.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -39,7 +39,7 @@ var difference = turf.difference(polygon1, polygon2);
39
39
  var addToMap = [polygon1, polygon2, difference];
40
40
  ```
41
41
 
42
- Returns **([Feature](http://geojson.org/geojson-spec.html#feature-objects)<([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))> | [undefined](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/undefined))** a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `undefined`)
42
+ Returns **([Feature](http://geojson.org/geojson-spec.html#feature-objects)<([Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))> | [null](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/null))** a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)
43
43
 
44
44
  <!-- This file is automatically generated. Please don't edit it directly:
45
45
  if you find an error, edit the source file (likely index.js), and re-run
package/index.d.ts CHANGED
@@ -3,7 +3,7 @@
3
3
  import {Polygon, MultiPolygon, Feature} from '@turf/meta'
4
4
 
5
5
  type Input = Feature<Polygon|MultiPolygon> | Polygon | MultiPolygon;
6
- type Output = Feature<Polygon|MultiPolygon> | undefined;
6
+ type Output = Feature<Polygon|MultiPolygon> | null;
7
7
 
8
8
  /**
9
9
  * http://turfjs.org/docs/#difference
package/index.js CHANGED
@@ -11,7 +11,7 @@ var flattenEach = require('@turf/meta').flattenEach;
11
11
  * @name difference
12
12
  * @param {Feature<Polygon|MultiPolygon>} polygon1 input Polygon feature
13
13
  * @param {Feature<Polygon|MultiPolygon>} polygon2 Polygon feature to difference from polygon1
14
- * @returns {Feature<Polygon|MultiPolygon>|undefined} a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `undefined`)
14
+ * @returns {Feature<Polygon|MultiPolygon>|null} a Polygon or MultiPolygon feature showing the area of `polygon1` excluding the area of `polygon2` (if empty returns `null`)
15
15
  * @example
16
16
  * var polygon1 = turf.polygon([[
17
17
  * [128, -26],
@@ -47,7 +47,7 @@ module.exports = function (polygon1, polygon2) {
47
47
  // Issue #721 - JSTS can't handle empty polygons
48
48
  geom1 = removeEmptyPolygon(geom1);
49
49
  geom2 = removeEmptyPolygon(geom2);
50
- if (!geom1) return undefined;
50
+ if (!geom1) return null;
51
51
  if (!geom2) return feature(geom1, properties);
52
52
 
53
53
  // JSTS difference operation
@@ -55,7 +55,7 @@ module.exports = function (polygon1, polygon2) {
55
55
  var a = reader.read(geom1);
56
56
  var b = reader.read(geom2);
57
57
  var differenced = a.difference(b);
58
- if (differenced.isEmpty()) return undefined;
58
+ if (differenced.isEmpty()) return null;
59
59
  var writer = new jsts.io.GeoJSONWriter();
60
60
  var geom = writer.write(differenced);
61
61
 
@@ -67,13 +67,13 @@ module.exports = function (polygon1, polygon2) {
67
67
  *
68
68
  * @private
69
69
  * @param {Geometry<Polygon|MultiPolygon>} geom Geometry Object
70
- * @returns {Geometry<Polygon|MultiPolygon>|undefined} removed any polygons with no areas
70
+ * @returns {Geometry<Polygon|MultiPolygon>|null} removed any polygons with no areas
71
71
  */
72
72
  function removeEmptyPolygon(geom) {
73
73
  switch (geom.type) {
74
74
  case 'Polygon':
75
75
  if (area(geom) > 1) return geom;
76
- return undefined;
76
+ return null;
77
77
  case 'MultiPolygon':
78
78
  var coordinates = [];
79
79
  flattenEach(geom, function (feature) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/difference",
3
- "version": "4.7.3",
3
+ "version": "4.7.4",
4
4
  "description": "turf difference module",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",