@turf/square 7.0.0-alpha.0 → 7.0.0-alpha.110

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
@@ -25,26 +25,21 @@ Returns **[BBox][1]** a square surrounding `bbox`
25
25
 
26
26
  [1]: https://tools.ietf.org/html/rfc7946#section-5
27
27
 
28
- <!-- This file is automatically generated. Please don't edit it directly:
29
- if you find an error, edit the source file (likely index.js), and re-run
30
- ./scripts/generate-readmes in the turf project. -->
28
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
31
29
 
32
30
  ---
33
31
 
34
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
35
- module collection dedicated to geographic algorithms. It is maintained in the
36
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
37
- PRs and issues.
32
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
38
33
 
39
34
  ### Installation
40
35
 
41
- Install this module individually:
36
+ Install this single module individually:
42
37
 
43
38
  ```sh
44
39
  $ npm install @turf/square
45
40
  ```
46
41
 
47
- Or install the Turf module that includes it as a function:
42
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
48
43
 
49
44
  ```sh
50
45
  $ npm install @turf/turf
@@ -0,0 +1,37 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.js
5
+ var _distance = require('@turf/distance');
6
+ function square(bbox) {
7
+ var west = bbox[0];
8
+ var south = bbox[1];
9
+ var east = bbox[2];
10
+ var north = bbox[3];
11
+ var horizontalDistance = _distance.distance.call(void 0, bbox.slice(0, 2), [east, south]);
12
+ var verticalDistance = _distance.distance.call(void 0, bbox.slice(0, 2), [west, north]);
13
+ if (horizontalDistance >= verticalDistance) {
14
+ var verticalMidpoint = (south + north) / 2;
15
+ return [
16
+ west,
17
+ verticalMidpoint - (east - west) / 2,
18
+ east,
19
+ verticalMidpoint + (east - west) / 2
20
+ ];
21
+ } else {
22
+ var horizontalMidpoint = (west + east) / 2;
23
+ return [
24
+ horizontalMidpoint - (north - south) / 2,
25
+ south,
26
+ horizontalMidpoint + (north - south) / 2,
27
+ north
28
+ ];
29
+ }
30
+ }
31
+ __name(square, "square");
32
+ var turf_square_default = square;
33
+
34
+
35
+
36
+ exports.default = turf_square_default; exports.square = square;
37
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.js"],"names":[],"mappings":";;;;AAAA,SAAS,gBAAgB;AAgBzB,SAAS,OAAO,MAAM;AACpB,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAClB,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAElB,MAAI,qBAAqB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AACjE,MAAI,mBAAmB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AAC/D,MAAI,sBAAsB,kBAAkB;AAC1C,QAAI,oBAAoB,QAAQ,SAAS;AACzC,WAAO;AAAA,MACL;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,MACnC;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,IACrC;AAAA,EACF,OAAO;AACL,QAAI,sBAAsB,OAAO,QAAQ;AACzC,WAAO;AAAA,MACL,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,MACA,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;AAzBS;AA4BT,IAAO,sBAAQ","sourcesContent":["import { distance } from \"@turf/distance\";\n\n/**\n * Takes a bounding box and calculates the minimum square bounding box that\n * would contain the input.\n *\n * @name square\n * @param {BBox} bbox extent in [west, south, east, north] order\n * @returns {BBox} a square surrounding `bbox`\n * @example\n * var bbox = [-20, -20, -15, 0];\n * var squared = turf.square(bbox);\n *\n * //addToMap\n * var addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]\n */\nfunction square(bbox) {\n var west = bbox[0];\n var south = bbox[1];\n var east = bbox[2];\n var north = bbox[3];\n\n var horizontalDistance = distance(bbox.slice(0, 2), [east, south]);\n var verticalDistance = distance(bbox.slice(0, 2), [west, north]);\n if (horizontalDistance >= verticalDistance) {\n var verticalMidpoint = (south + north) / 2;\n return [\n west,\n verticalMidpoint - (east - west) / 2,\n east,\n verticalMidpoint + (east - west) / 2,\n ];\n } else {\n var horizontalMidpoint = (west + east) / 2;\n return [\n horizontalMidpoint - (north - south) / 2,\n south,\n horizontalMidpoint + (north - south) / 2,\n north,\n ];\n }\n}\n\nexport { square };\nexport default square;\n"]}
@@ -0,0 +1,8 @@
1
+ import { BBox } from 'geojson';
2
+
3
+ /**
4
+ * http://turfjs.org/docs/#square
5
+ */
6
+ declare function square(bbox: BBox): BBox;
7
+
8
+ export { square as default, square };
@@ -0,0 +1,8 @@
1
+ import { BBox } from 'geojson';
2
+
3
+ /**
4
+ * http://turfjs.org/docs/#square
5
+ */
6
+ declare function square(bbox: BBox): BBox;
7
+
8
+ export { square as default, square };
@@ -1,25 +1,13 @@
1
- import distance from '@turf/distance';
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
2
3
 
3
- /**
4
- * Takes a bounding box and calculates the minimum square bounding box that
5
- * would contain the input.
6
- *
7
- * @name square
8
- * @param {BBox} bbox extent in [west, south, east, north] order
9
- * @returns {BBox} a square surrounding `bbox`
10
- * @example
11
- * var bbox = [-20, -20, -15, 0];
12
- * var squared = turf.square(bbox);
13
- *
14
- * //addToMap
15
- * var addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]
16
- */
4
+ // index.js
5
+ import { distance } from "@turf/distance";
17
6
  function square(bbox) {
18
7
  var west = bbox[0];
19
8
  var south = bbox[1];
20
9
  var east = bbox[2];
21
10
  var north = bbox[3];
22
-
23
11
  var horizontalDistance = distance(bbox.slice(0, 2), [east, south]);
24
12
  var verticalDistance = distance(bbox.slice(0, 2), [west, north]);
25
13
  if (horizontalDistance >= verticalDistance) {
@@ -28,7 +16,7 @@ function square(bbox) {
28
16
  west,
29
17
  verticalMidpoint - (east - west) / 2,
30
18
  east,
31
- verticalMidpoint + (east - west) / 2,
19
+ verticalMidpoint + (east - west) / 2
32
20
  ];
33
21
  } else {
34
22
  var horizontalMidpoint = (west + east) / 2;
@@ -36,9 +24,14 @@ function square(bbox) {
36
24
  horizontalMidpoint - (north - south) / 2,
37
25
  south,
38
26
  horizontalMidpoint + (north - south) / 2,
39
- north,
27
+ north
40
28
  ];
41
29
  }
42
30
  }
43
-
44
- export default square;
31
+ __name(square, "square");
32
+ var turf_square_default = square;
33
+ export {
34
+ turf_square_default as default,
35
+ square
36
+ };
37
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.js"],"sourcesContent":["import { distance } from \"@turf/distance\";\n\n/**\n * Takes a bounding box and calculates the minimum square bounding box that\n * would contain the input.\n *\n * @name square\n * @param {BBox} bbox extent in [west, south, east, north] order\n * @returns {BBox} a square surrounding `bbox`\n * @example\n * var bbox = [-20, -20, -15, 0];\n * var squared = turf.square(bbox);\n *\n * //addToMap\n * var addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]\n */\nfunction square(bbox) {\n var west = bbox[0];\n var south = bbox[1];\n var east = bbox[2];\n var north = bbox[3];\n\n var horizontalDistance = distance(bbox.slice(0, 2), [east, south]);\n var verticalDistance = distance(bbox.slice(0, 2), [west, north]);\n if (horizontalDistance >= verticalDistance) {\n var verticalMidpoint = (south + north) / 2;\n return [\n west,\n verticalMidpoint - (east - west) / 2,\n east,\n verticalMidpoint + (east - west) / 2,\n ];\n } else {\n var horizontalMidpoint = (west + east) / 2;\n return [\n horizontalMidpoint - (north - south) / 2,\n south,\n horizontalMidpoint + (north - south) / 2,\n north,\n ];\n }\n}\n\nexport { square };\nexport default square;\n"],"mappings":";;;;AAAA,SAAS,gBAAgB;AAgBzB,SAAS,OAAO,MAAM;AACpB,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAClB,MAAI,OAAO,KAAK,CAAC;AACjB,MAAI,QAAQ,KAAK,CAAC;AAElB,MAAI,qBAAqB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AACjE,MAAI,mBAAmB,SAAS,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC;AAC/D,MAAI,sBAAsB,kBAAkB;AAC1C,QAAI,oBAAoB,QAAQ,SAAS;AACzC,WAAO;AAAA,MACL;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,MACnC;AAAA,MACA,oBAAoB,OAAO,QAAQ;AAAA,IACrC;AAAA,EACF,OAAO;AACL,QAAI,sBAAsB,OAAO,QAAQ;AACzC,WAAO;AAAA,MACL,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,MACA,sBAAsB,QAAQ,SAAS;AAAA,MACvC;AAAA,IACF;AAAA,EACF;AACF;AAzBS;AA4BT,IAAO,sBAAQ;","names":[]}
package/index.d.ts CHANGED
@@ -3,4 +3,7 @@ import { BBox } from "geojson";
3
3
  /**
4
4
  * http://turfjs.org/docs/#square
5
5
  */
6
- export default function (bbox: BBox): BBox;
6
+ declare function square(bbox: BBox): BBox;
7
+
8
+ export { square };
9
+ export default square;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/square",
3
- "version": "7.0.0-alpha.0",
3
+ "version": "7.0.0-alpha.110+1411d63a7",
4
4
  "description": "turf square module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -22,37 +22,45 @@
22
22
  "geojson",
23
23
  "extent"
24
24
  ],
25
- "main": "dist/js/index.js",
26
- "module": "dist/es/index.js",
25
+ "type": "commonjs",
26
+ "main": "dist/cjs/index.cjs",
27
+ "module": "dist/esm/index.mjs",
28
+ "types": "dist/cjs/index.d.ts",
27
29
  "exports": {
28
30
  "./package.json": "./package.json",
29
31
  ".": {
30
- "import": "./dist/es/index.js",
31
- "require": "./dist/js/index.js"
32
+ "import": {
33
+ "types": "./dist/esm/index.d.mts",
34
+ "default": "./dist/esm/index.mjs"
35
+ },
36
+ "require": {
37
+ "types": "./dist/cjs/index.d.ts",
38
+ "default": "./dist/cjs/index.cjs"
39
+ }
32
40
  }
33
41
  },
34
- "types": "index.d.ts",
35
42
  "sideEffects": false,
36
43
  "files": [
37
44
  "dist",
38
45
  "index.d.ts"
39
46
  ],
40
47
  "scripts": {
41
- "bench": "node -r esm bench.js",
42
- "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
43
- "docs": "node ../../scripts/generate-readmes",
44
- "test": "npm-run-all test:*",
45
- "test:tape": "node -r esm test.js"
48
+ "bench": "tsx bench.ts",
49
+ "build": "tsup --config ../../tsup.config.ts",
50
+ "docs": "tsx ../../scripts/generate-readmes.ts",
51
+ "test": "npm-run-all --npm-path npm test:*",
52
+ "test:tape": "tsx test.ts"
46
53
  },
47
54
  "devDependencies": {
48
- "benchmark": "*",
49
- "npm-run-all": "*",
50
- "rollup": "*",
51
- "tape": "*"
55
+ "benchmark": "^2.1.4",
56
+ "npm-run-all": "^4.1.5",
57
+ "tape": "^5.7.2",
58
+ "tsup": "^8.0.1",
59
+ "tsx": "^4.6.2"
52
60
  },
53
61
  "dependencies": {
54
- "@turf/distance": "^7.0.0-alpha.0",
55
- "@turf/helpers": "^7.0.0-alpha.0"
62
+ "@turf/distance": "^7.0.0-alpha.110+1411d63a7",
63
+ "@turf/helpers": "^7.0.0-alpha.110+1411d63a7"
56
64
  },
57
- "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
65
+ "gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
58
66
  }
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,51 +0,0 @@
1
- 'use strict';
2
-
3
- var distance = require('@turf/distance');
4
-
5
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
6
-
7
- var distance__default = /*#__PURE__*/_interopDefaultLegacy(distance);
8
-
9
- /**
10
- * Takes a bounding box and calculates the minimum square bounding box that
11
- * would contain the input.
12
- *
13
- * @name square
14
- * @param {BBox} bbox extent in [west, south, east, north] order
15
- * @returns {BBox} a square surrounding `bbox`
16
- * @example
17
- * var bbox = [-20, -20, -15, 0];
18
- * var squared = turf.square(bbox);
19
- *
20
- * //addToMap
21
- * var addToMap = [turf.bboxPolygon(bbox), turf.bboxPolygon(squared)]
22
- */
23
- function square(bbox) {
24
- var west = bbox[0];
25
- var south = bbox[1];
26
- var east = bbox[2];
27
- var north = bbox[3];
28
-
29
- var horizontalDistance = distance__default['default'](bbox.slice(0, 2), [east, south]);
30
- var verticalDistance = distance__default['default'](bbox.slice(0, 2), [west, north]);
31
- if (horizontalDistance >= verticalDistance) {
32
- var verticalMidpoint = (south + north) / 2;
33
- return [
34
- west,
35
- verticalMidpoint - (east - west) / 2,
36
- east,
37
- verticalMidpoint + (east - west) / 2,
38
- ];
39
- } else {
40
- var horizontalMidpoint = (west + east) / 2;
41
- return [
42
- horizontalMidpoint - (north - south) / 2,
43
- south,
44
- horizontalMidpoint + (north - south) / 2,
45
- north,
46
- ];
47
- }
48
- }
49
-
50
- module.exports = square;
51
- module.exports.default = square;