@turf/bbox 5.0.4 → 6.0.1

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
@@ -8,7 +8,7 @@ Takes a set of features, calculates the bbox of all input features, and returns
8
8
 
9
9
  **Parameters**
10
10
 
11
- - `geojson` **([FeatureCollection](http://geojson.org/geojson-spec.html#feature-collection-objects) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)<any>)** input features
11
+ - `geojson` **[GeoJSON][1]** any GeoJSON object
12
12
 
13
13
  **Examples**
14
14
 
@@ -21,7 +21,11 @@ var bboxPolygon = turf.bboxPolygon(bbox);
21
21
  var addToMap = [line, bboxPolygon]
22
22
  ```
23
23
 
24
- Returns **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** bbox extent in [minX, minY, maxX, maxY] order
24
+ Returns **[BBox][2]** bbox extent in [minX, minY, maxX, maxY] order
25
+
26
+ [1]: https://tools.ietf.org/html/rfc7946#section-3
27
+
28
+ [2]: https://tools.ietf.org/html/rfc7946#section-5
25
29
 
26
30
  <!-- This file is automatically generated. Please don't edit it directly:
27
31
  if you find an error, edit the source file (likely index.js), and re-run
package/index.d.ts CHANGED
@@ -1,8 +1,16 @@
1
- import { Feature, FeatureCollection, BBox } from '@turf/helpers'
2
-
1
+ import { BBox } from "@turf/helpers";
3
2
  /**
4
- * http://turfjs.org/docs/#bbox
3
+ * Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
4
+ *
5
+ * @name bbox
6
+ * @param {GeoJSON} geojson any GeoJSON object
7
+ * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
8
+ * @example
9
+ * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
10
+ * var bbox = turf.bbox(line);
11
+ * var bboxPolygon = turf.bboxPolygon(bbox);
12
+ *
13
+ * //addToMap
14
+ * var addToMap = [line, bboxPolygon]
5
15
  */
6
- export default function bbox(
7
- features: Feature<any> | FeatureCollection<any>
8
- ): BBox;
16
+ export default function bbox(geojson: any): BBox;
package/index.js CHANGED
@@ -1,11 +1,12 @@
1
- import { coordEach } from '@turf/meta';
2
-
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ var meta_1 = require("@turf/meta");
3
4
  /**
4
5
  * Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
5
6
  *
6
7
  * @name bbox
7
- * @param {FeatureCollection|Feature<any>} geojson input features
8
- * @returns {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
8
+ * @param {GeoJSON} geojson any GeoJSON object
9
+ * @returns {BBox} bbox extent in [minX, minY, maxX, maxY] order
9
10
  * @example
10
11
  * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
11
12
  * var bbox = turf.bbox(line);
@@ -15,14 +16,21 @@ import { coordEach } from '@turf/meta';
15
16
  * var addToMap = [line, bboxPolygon]
16
17
  */
17
18
  function bbox(geojson) {
18
- var BBox = [Infinity, Infinity, -Infinity, -Infinity];
19
- coordEach(geojson, function (coord) {
20
- if (BBox[0] > coord[0]) BBox[0] = coord[0];
21
- if (BBox[1] > coord[1]) BBox[1] = coord[1];
22
- if (BBox[2] < coord[0]) BBox[2] = coord[0];
23
- if (BBox[3] < coord[1]) BBox[3] = coord[1];
19
+ var result = [Infinity, Infinity, -Infinity, -Infinity];
20
+ meta_1.coordEach(geojson, function (coord) {
21
+ if (result[0] > coord[0]) {
22
+ result[0] = coord[0];
23
+ }
24
+ if (result[1] > coord[1]) {
25
+ result[1] = coord[1];
26
+ }
27
+ if (result[2] < coord[0]) {
28
+ result[2] = coord[0];
29
+ }
30
+ if (result[3] < coord[1]) {
31
+ result[3] = coord[1];
32
+ }
24
33
  });
25
- return BBox;
34
+ return result;
26
35
  }
27
-
28
- export default bbox;
36
+ exports.default = bbox;
package/package.json CHANGED
@@ -1,20 +1,19 @@
1
1
  {
2
2
  "name": "@turf/bbox",
3
- "version": "5.0.4",
3
+ "version": "6.0.1",
4
4
  "description": "turf bbox module",
5
- "main": "main",
6
- "module": "index",
7
- "jsnext:main": "index",
5
+ "main": "index",
8
6
  "types": "index.d.ts",
9
7
  "files": [
10
8
  "index.js",
11
- "index.d.ts",
12
- "main.js"
9
+ "index.d.ts"
13
10
  ],
14
11
  "scripts": {
15
- "pretest": "rollup -c ../../rollup.config.js",
16
- "test": "node -r @std/esm test.js",
17
- "bench": "node -r @std/esm bench.js"
12
+ "prepare": "tsc",
13
+ "pretest": "tsc",
14
+ "test": "node test.js",
15
+ "bench": "node bench.js",
16
+ "docs": "node ../../scripts/generate-readmes"
18
17
  },
19
18
  "repository": {
20
19
  "type": "git",
@@ -35,17 +34,14 @@
35
34
  },
36
35
  "homepage": "https://github.com/Turfjs/turf",
37
36
  "devDependencies": {
38
- "@std/esm": "*",
39
37
  "benchmark": "*",
40
- "rollup": "*",
41
- "tape": "*"
38
+ "typescript": "*",
39
+ "tape": "*",
40
+ "tslint": "*",
41
+ "@types/tape": "*"
42
42
  },
43
43
  "dependencies": {
44
- "@turf/helpers": "^5.0.4",
45
- "@turf/meta": "^5.0.4"
46
- },
47
- "@std/esm": {
48
- "esm": "js",
49
- "cjs": true
44
+ "@turf/helpers": "6.x",
45
+ "@turf/meta": "6.x"
50
46
  }
51
47
  }
package/main.js DELETED
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var meta = require('@turf/meta');
4
-
5
- /**
6
- * Takes a set of features, calculates the bbox of all input features, and returns a bounding box.
7
- *
8
- * @name bbox
9
- * @param {FeatureCollection|Feature<any>} geojson input features
10
- * @returns {Array<number>} bbox extent in [minX, minY, maxX, maxY] order
11
- * @example
12
- * var line = turf.lineString([[-74, 40], [-78, 42], [-82, 35]]);
13
- * var bbox = turf.bbox(line);
14
- * var bboxPolygon = turf.bboxPolygon(bbox);
15
- *
16
- * //addToMap
17
- * var addToMap = [line, bboxPolygon]
18
- */
19
- function bbox(geojson) {
20
- var BBox = [Infinity, Infinity, -Infinity, -Infinity];
21
- meta.coordEach(geojson, function (coord) {
22
- if (BBox[0] > coord[0]) BBox[0] = coord[0];
23
- if (BBox[1] > coord[1]) BBox[1] = coord[1];
24
- if (BBox[2] < coord[0]) BBox[2] = coord[0];
25
- if (BBox[3] < coord[1]) BBox[3] = coord[1];
26
- });
27
- return BBox;
28
- }
29
-
30
- module.exports = bbox;
31
- module.exports.default = bbox;