@turf/bbox-polygon 6.5.0 → 7.0.0-alpha.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
@@ -6,14 +6,15 @@
6
6
 
7
7
  Takes a bbox and returns an equivalent [polygon][1].
8
8
 
9
- **Parameters**
9
+ ### Parameters
10
10
 
11
- - `bbox` **[BBox][2]** extent in [minX, minY, maxX, maxY] order
12
- - `options` **[Object][3]** Optional parameters (optional, default `{}`)
13
- - `options.properties` **Properties** Translate properties to Polygon (optional, default `{}`)
14
- - `options.id` **([string][4] \| [number][5])** Translate Id to Polygon (optional, default `{}`)
11
+ * `bbox` **[BBox][2]** extent in \[minX, minY, maxX, maxY] order
12
+ * `options` **[Object][3]** Optional parameters (optional, default `{}`)
15
13
 
16
- **Examples**
14
+ * `options.properties` **Properties** Translate properties to Polygon (optional, default `{}`)
15
+ * `options.id` **([string][4] | [number][5])** Translate Id to Polygon (optional, default `{}`)
16
+
17
+ ### Examples
17
18
 
18
19
  ```javascript
19
20
  var bbox = [0, 0, 10, 10];
@@ -24,7 +25,7 @@ var poly = turf.bboxPolygon(bbox);
24
25
  var addToMap = [poly]
25
26
  ```
26
27
 
27
- Returns **[Feature][6]<[Polygon][7]>** a Polygon representation of the bounding box
28
+ Returns **[Feature][6]<[Polygon][7]>** a Polygon representation of the bounding box
28
29
 
29
30
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.6
30
31
 
package/dist/es/index.js CHANGED
@@ -16,21 +16,20 @@ import { polygon } from "@turf/helpers";
16
16
  * //addToMap
17
17
  * var addToMap = [poly]
18
18
  */
19
- export default function bboxPolygon(bbox, options) {
20
- if (options === void 0) { options = {}; }
19
+ export default function bboxPolygon(bbox, options = {}) {
21
20
  // Convert BBox positions to Numbers
22
21
  // No performance loss for including Number()
23
22
  // https://github.com/Turfjs/turf/issues/1119
24
- var west = Number(bbox[0]);
25
- var south = Number(bbox[1]);
26
- var east = Number(bbox[2]);
27
- var north = Number(bbox[3]);
23
+ const west = Number(bbox[0]);
24
+ const south = Number(bbox[1]);
25
+ const east = Number(bbox[2]);
26
+ const north = Number(bbox[3]);
28
27
  if (bbox.length === 6) {
29
28
  throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");
30
29
  }
31
- var lowLeft = [west, south];
32
- var topLeft = [west, north];
33
- var topRight = [east, north];
34
- var lowRight = [east, south];
35
- return polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox: bbox, id: options.id });
30
+ const lowLeft = [west, south];
31
+ const topLeft = [west, north];
32
+ const topRight = [east, north];
33
+ const lowRight = [east, south];
34
+ return polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox, id: options.id });
36
35
  }
@@ -1,4 +1,5 @@
1
- import { BBox, Feature, Id, Polygon, Properties } from "@turf/helpers";
1
+ import { BBox, Feature, Polygon, GeoJsonProperties } from "geojson";
2
+ import { Id } from "@turf/helpers";
2
3
  /**
3
4
  * Takes a bbox and returns an equivalent {@link Polygon|polygon}.
4
5
  *
@@ -16,7 +17,7 @@ import { BBox, Feature, Id, Polygon, Properties } from "@turf/helpers";
16
17
  * //addToMap
17
18
  * var addToMap = [poly]
18
19
  */
19
- export default function bboxPolygon<P = Properties>(bbox: BBox, options?: {
20
+ export default function bboxPolygon<P = GeoJsonProperties>(bbox: BBox, options?: {
20
21
  properties?: P;
21
22
  id?: Id;
22
23
  }): Feature<Polygon, P>;
package/dist/js/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var helpers_1 = require("@turf/helpers");
3
+ const helpers_1 = require("@turf/helpers");
4
4
  /**
5
5
  * Takes a bbox and returns an equivalent {@link Polygon|polygon}.
6
6
  *
@@ -18,22 +18,21 @@ var helpers_1 = require("@turf/helpers");
18
18
  * //addToMap
19
19
  * var addToMap = [poly]
20
20
  */
21
- function bboxPolygon(bbox, options) {
22
- if (options === void 0) { options = {}; }
21
+ function bboxPolygon(bbox, options = {}) {
23
22
  // Convert BBox positions to Numbers
24
23
  // No performance loss for including Number()
25
24
  // https://github.com/Turfjs/turf/issues/1119
26
- var west = Number(bbox[0]);
27
- var south = Number(bbox[1]);
28
- var east = Number(bbox[2]);
29
- var north = Number(bbox[3]);
25
+ const west = Number(bbox[0]);
26
+ const south = Number(bbox[1]);
27
+ const east = Number(bbox[2]);
28
+ const north = Number(bbox[3]);
30
29
  if (bbox.length === 6) {
31
30
  throw new Error("@turf/bbox-polygon does not support BBox with 6 positions");
32
31
  }
33
- var lowLeft = [west, south];
34
- var topLeft = [west, north];
35
- var topRight = [east, north];
36
- var lowRight = [east, south];
37
- return helpers_1.polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox: bbox, id: options.id });
32
+ const lowLeft = [west, south];
33
+ const topLeft = [west, north];
34
+ const topRight = [east, north];
35
+ const lowRight = [east, south];
36
+ return helpers_1.polygon([[lowLeft, lowRight, topRight, topLeft, lowLeft]], options.properties, { bbox, id: options.id });
38
37
  }
39
38
  exports.default = bboxPolygon;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/bbox-polygon",
3
- "version": "6.5.0",
3
+ "version": "7.0.0-alpha.1",
4
4
  "description": "turf bbox-polygon module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -28,6 +28,7 @@
28
28
  "exports": {
29
29
  "./package.json": "./package.json",
30
30
  ".": {
31
+ "types": "./dist/js/index.d.ts",
31
32
  "import": "./dist/es/index.js",
32
33
  "require": "./dist/js/index.js"
33
34
  }
@@ -38,25 +39,26 @@
38
39
  "dist"
39
40
  ],
40
41
  "scripts": {
41
- "bench": "ts-node bench.js",
42
+ "bench": "tsx bench.js",
42
43
  "build": "npm-run-all build:*",
43
44
  "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
44
45
  "build:js": "tsc",
45
- "docs": "node ../../scripts/generate-readmes",
46
+ "docs": "tsx ../../scripts/generate-readmes",
46
47
  "test": "npm-run-all test:*",
47
- "test:tape": "ts-node -r esm test.js"
48
+ "test:tape": "tsx test.js"
48
49
  },
49
50
  "devDependencies": {
50
51
  "@types/tape": "*",
51
52
  "benchmark": "*",
52
53
  "npm-run-all": "*",
53
54
  "tape": "*",
54
- "ts-node": "*",
55
55
  "tslint": "*",
56
+ "tsx": "*",
56
57
  "typescript": "*"
57
58
  },
58
59
  "dependencies": {
59
- "@turf/helpers": "^6.5.0"
60
+ "@turf/helpers": "^7.0.0-alpha.1",
61
+ "tslib": "^2.3.0"
60
62
  },
61
- "gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
63
+ "gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
62
64
  }