@turf/kinks 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
@@ -10,62 +10,66 @@ returns [points][5] at all self-intersections.
10
10
 
11
11
  ### Parameters
12
12
 
13
- - `featureIn` **[Feature][6]<([LineString][7] | [MultiLineString][8] | [MultiPolygon][9] | [Polygon][10])>** input feature
13
+ * `featureIn` **[Feature][6]<([LineString][7] | [MultiLineString][8] | [MultiPolygon][9] | [Polygon][10])>** input feature
14
14
 
15
15
  ### Examples
16
16
 
17
17
  ```javascript
18
- var poly = turf.polygon([
19
- [
20
- [-12.034835, 8.901183],
21
- [-12.060413, 8.899826],
22
- [-12.03638, 8.873199],
23
- [-12.059383, 8.871418],
24
- [-12.034835, 8.901183],
25
- ],
26
- ]);
18
+ var poly = turf.polygon([[
19
+ [-12.034835, 8.901183],
20
+ [-12.060413, 8.899826],
21
+ [-12.03638, 8.873199],
22
+ [-12.059383, 8.871418],
23
+ [-12.034835, 8.901183]
24
+ ]]);
27
25
 
28
26
  var kinks = turf.kinks(poly);
29
27
 
30
28
  //addToMap
31
- var addToMap = [poly, kinks];
29
+ var addToMap = [poly, kinks]
32
30
  ```
33
31
 
34
32
  Returns **[FeatureCollection][11]<[Point][12]>** self-intersections
35
33
 
36
34
  [1]: https://tools.ietf.org/html/rfc7946#section-3.1.4
35
+
37
36
  [2]: https://tools.ietf.org/html/rfc7946#section-3.1.5
37
+
38
38
  [3]: https://tools.ietf.org/html/rfc7946#section-3.1.7
39
+
39
40
  [4]: https://tools.ietf.org/html/rfc7946#section-3.1.6
41
+
40
42
  [5]: https://tools.ietf.org/html/rfc7946#section-3.1.2
43
+
41
44
  [6]: https://tools.ietf.org/html/rfc7946#section-3.2
45
+
42
46
  [7]: https://tools.ietf.org/html/rfc7946#section-3.1.4
47
+
43
48
  [8]: https://tools.ietf.org/html/rfc7946#section-3.1.5
49
+
44
50
  [9]: https://tools.ietf.org/html/rfc7946#section-3.1.7
51
+
45
52
  [10]: https://tools.ietf.org/html/rfc7946#section-3.1.6
53
+
46
54
  [11]: https://tools.ietf.org/html/rfc7946#section-3.3
55
+
47
56
  [12]: https://tools.ietf.org/html/rfc7946#section-3.1.2
48
57
 
49
- <!-- This file is automatically generated. Please don't edit it directly:
50
- if you find an error, edit the source file (likely index.js), and re-run
51
- ./scripts/generate-readmes in the turf project. -->
58
+ <!-- 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. -->
52
59
 
53
60
  ---
54
61
 
55
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
56
- module collection dedicated to geographic algorithms. It is maintained in the
57
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
58
- PRs and issues.
62
+ 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.
59
63
 
60
64
  ### Installation
61
65
 
62
- Install this module individually:
66
+ Install this single module individually:
63
67
 
64
68
  ```sh
65
69
  $ npm install @turf/kinks
66
70
  ```
67
71
 
68
- Or install the Turf module that includes it as a function:
72
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
69
73
 
70
74
  ```sh
71
75
  $ npm install @turf/turf
@@ -0,0 +1,30 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ var _sweeplineintersections = require('sweepline-intersections'); var _sweeplineintersections2 = _interopRequireDefault(_sweeplineintersections);
6
+ var _helpers = require('@turf/helpers');
7
+ function kinks(featureIn) {
8
+ const results = {
9
+ type: "FeatureCollection",
10
+ features: []
11
+ };
12
+ if (featureIn.type === "Feature" && (featureIn.geometry.type === "Point" || featureIn.geometry.type === "MultiPoint")) {
13
+ throw new Error(
14
+ "Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry"
15
+ );
16
+ }
17
+ const intersections = _sweeplineintersections2.default.call(void 0, featureIn, false);
18
+ for (let i = 0; i < intersections.length; ++i) {
19
+ const intersection = intersections[i];
20
+ results.features.push(_helpers.point.call(void 0, [intersection[0], intersection[1]]));
21
+ }
22
+ return results;
23
+ }
24
+ __name(kinks, "kinks");
25
+ var turf_kinks_default = kinks;
26
+
27
+
28
+
29
+ exports.default = turf_kinks_default; exports.kinks = kinks;
30
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AASA,OAAO,uBAAuB;AAC9B,SAAS,aAAa;AAwBtB,SAAS,MACP,WAC0B;AAC1B,QAAM,UAAoC;AAAA,IACxC,MAAM;AAAA,IACN,UAAU,CAAC;AAAA,EACb;AACA,MACE,UAAU,SAAS,cACjB,UAAsB,SAAS,SAAS,WACvC,UAAsB,SAAS,SAAS,eAC3C;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,gBAAgB,kBAAkB,WAAW,KAAK;AACxD,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,EAAE,GAAG;AAC7C,UAAM,eAAe,cAAc,CAAC;AACpC,YAAQ,SAAS,KAAK,MAAM,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAAA,EACjE;AACA,SAAO;AACT;AAvBS;AA0BT,IAAO,qBAAQ","sourcesContent":["import {\n Feature,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport findIntersections from \"sweepline-intersections\";\nimport { point } from \"@turf/helpers\";\n\n/**\n * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},\n * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and\n * returns {@link Point|points} at all self-intersections.\n *\n * @name kinks\n * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature\n * @returns {FeatureCollection<Point>} self-intersections\n * @example\n * var poly = turf.polygon([[\n * [-12.034835, 8.901183],\n * [-12.060413, 8.899826],\n * [-12.03638, 8.873199],\n * [-12.059383, 8.871418],\n * [-12.034835, 8.901183]\n * ]]);\n *\n * var kinks = turf.kinks(poly);\n *\n * //addToMap\n * var addToMap = [poly, kinks]\n */\nfunction kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(\n featureIn: Feature<T>\n): FeatureCollection<Point> {\n const results: FeatureCollection<Point> = {\n type: \"FeatureCollection\",\n features: [],\n };\n if (\n featureIn.type === \"Feature\" &&\n ((featureIn as Feature).geometry.type === \"Point\" ||\n (featureIn as Feature).geometry.type === \"MultiPoint\")\n ) {\n throw new Error(\n \"Input must be a LineString, MultiLineString, \" +\n \"Polygon, or MultiPolygon Feature or Geometry\"\n );\n }\n const intersections = findIntersections(featureIn, false);\n for (let i = 0; i < intersections.length; ++i) {\n const intersection = intersections[i];\n results.features.push(point([intersection[0], intersection[1]]));\n }\n return results;\n}\n\nexport { kinks };\nexport default kinks;\n"]}
@@ -1,4 +1,5 @@
1
- import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon, Point, Polygon } from "geojson";
1
+ import { LineString, MultiLineString, Polygon, MultiPolygon, Feature, FeatureCollection, Point } from 'geojson';
2
+
2
3
  /**
3
4
  * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
4
5
  * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
@@ -21,4 +22,6 @@ import { Feature, FeatureCollection, LineString, MultiLineString, MultiPolygon,
21
22
  * //addToMap
22
23
  * var addToMap = [poly, kinks]
23
24
  */
24
- export default function kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(featureIn: Feature<T>): FeatureCollection<Point>;
25
+ declare function kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(featureIn: Feature<T>): FeatureCollection<Point>;
26
+
27
+ export { kinks as default, kinks };
@@ -0,0 +1,27 @@
1
+ import { LineString, MultiLineString, Polygon, MultiPolygon, Feature, FeatureCollection, Point } from 'geojson';
2
+
3
+ /**
4
+ * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
5
+ * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
6
+ * returns {@link Point|points} at all self-intersections.
7
+ *
8
+ * @name kinks
9
+ * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature
10
+ * @returns {FeatureCollection<Point>} self-intersections
11
+ * @example
12
+ * var poly = turf.polygon([[
13
+ * [-12.034835, 8.901183],
14
+ * [-12.060413, 8.899826],
15
+ * [-12.03638, 8.873199],
16
+ * [-12.059383, 8.871418],
17
+ * [-12.034835, 8.901183]
18
+ * ]]);
19
+ *
20
+ * var kinks = turf.kinks(poly);
21
+ *
22
+ * //addToMap
23
+ * var addToMap = [poly, kinks]
24
+ */
25
+ declare function kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(featureIn: Feature<T>): FeatureCollection<Point>;
26
+
27
+ export { kinks as default, kinks };
@@ -0,0 +1,30 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ import findIntersections from "sweepline-intersections";
6
+ import { point } from "@turf/helpers";
7
+ function kinks(featureIn) {
8
+ const results = {
9
+ type: "FeatureCollection",
10
+ features: []
11
+ };
12
+ if (featureIn.type === "Feature" && (featureIn.geometry.type === "Point" || featureIn.geometry.type === "MultiPoint")) {
13
+ throw new Error(
14
+ "Input must be a LineString, MultiLineString, Polygon, or MultiPolygon Feature or Geometry"
15
+ );
16
+ }
17
+ const intersections = findIntersections(featureIn, false);
18
+ for (let i = 0; i < intersections.length; ++i) {
19
+ const intersection = intersections[i];
20
+ results.features.push(point([intersection[0], intersection[1]]));
21
+ }
22
+ return results;
23
+ }
24
+ __name(kinks, "kinks");
25
+ var turf_kinks_default = kinks;
26
+ export {
27
+ turf_kinks_default as default,
28
+ kinks
29
+ };
30
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import {\n Feature,\n FeatureCollection,\n LineString,\n MultiLineString,\n MultiPolygon,\n Point,\n Polygon,\n} from \"geojson\";\nimport findIntersections from \"sweepline-intersections\";\nimport { point } from \"@turf/helpers\";\n\n/**\n * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},\n * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and\n * returns {@link Point|points} at all self-intersections.\n *\n * @name kinks\n * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature\n * @returns {FeatureCollection<Point>} self-intersections\n * @example\n * var poly = turf.polygon([[\n * [-12.034835, 8.901183],\n * [-12.060413, 8.899826],\n * [-12.03638, 8.873199],\n * [-12.059383, 8.871418],\n * [-12.034835, 8.901183]\n * ]]);\n *\n * var kinks = turf.kinks(poly);\n *\n * //addToMap\n * var addToMap = [poly, kinks]\n */\nfunction kinks<T extends LineString | MultiLineString | Polygon | MultiPolygon>(\n featureIn: Feature<T>\n): FeatureCollection<Point> {\n const results: FeatureCollection<Point> = {\n type: \"FeatureCollection\",\n features: [],\n };\n if (\n featureIn.type === \"Feature\" &&\n ((featureIn as Feature).geometry.type === \"Point\" ||\n (featureIn as Feature).geometry.type === \"MultiPoint\")\n ) {\n throw new Error(\n \"Input must be a LineString, MultiLineString, \" +\n \"Polygon, or MultiPolygon Feature or Geometry\"\n );\n }\n const intersections = findIntersections(featureIn, false);\n for (let i = 0; i < intersections.length; ++i) {\n const intersection = intersections[i];\n results.features.push(point([intersection[0], intersection[1]]));\n }\n return results;\n}\n\nexport { kinks };\nexport default kinks;\n"],"mappings":";;;;AASA,OAAO,uBAAuB;AAC9B,SAAS,aAAa;AAwBtB,SAAS,MACP,WAC0B;AAC1B,QAAM,UAAoC;AAAA,IACxC,MAAM;AAAA,IACN,UAAU,CAAC;AAAA,EACb;AACA,MACE,UAAU,SAAS,cACjB,UAAsB,SAAS,SAAS,WACvC,UAAsB,SAAS,SAAS,eAC3C;AACA,UAAM,IAAI;AAAA,MACR;AAAA,IAEF;AAAA,EACF;AACA,QAAM,gBAAgB,kBAAkB,WAAW,KAAK;AACxD,WAAS,IAAI,GAAG,IAAI,cAAc,QAAQ,EAAE,GAAG;AAC7C,UAAM,eAAe,cAAc,CAAC;AACpC,YAAQ,SAAS,KAAK,MAAM,CAAC,aAAa,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC;AAAA,EACjE;AACA,SAAO;AACT;AAvBS;AA0BT,IAAO,qBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/kinks",
3
- "version": "7.0.0-alpha.0",
3
+ "version": "7.0.0-alpha.110+1411d63a7",
4
4
  "description": "turf kinks module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -21,44 +21,52 @@
21
21
  "kinks",
22
22
  "self-intersection"
23
23
  ],
24
- "main": "dist/js/index.js",
25
- "module": "dist/es/index.js",
24
+ "type": "commonjs",
25
+ "main": "dist/cjs/index.cjs",
26
+ "module": "dist/esm/index.mjs",
27
+ "types": "dist/cjs/index.d.ts",
26
28
  "exports": {
27
29
  "./package.json": "./package.json",
28
30
  ".": {
29
- "import": "./dist/es/index.js",
30
- "require": "./dist/js/index.js"
31
+ "import": {
32
+ "types": "./dist/esm/index.d.mts",
33
+ "default": "./dist/esm/index.mjs"
34
+ },
35
+ "require": {
36
+ "types": "./dist/cjs/index.d.ts",
37
+ "default": "./dist/cjs/index.cjs"
38
+ }
31
39
  }
32
40
  },
33
- "types": "dist/js/index.d.ts",
34
41
  "sideEffects": false,
35
42
  "files": [
36
43
  "dist"
37
44
  ],
38
45
  "scripts": {
39
- "bench": "ts-node bench.js",
40
- "build": "npm-run-all build:*",
41
- "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
42
- "build:js": "tsc",
43
- "docs": "node ../../scripts/generate-readmes",
44
- "test": "npm-run-all test:*",
45
- "test:tape": "ts-node -r esm test.js",
46
+ "bench": "tsx bench.ts",
47
+ "build": "tsup --config ../../tsup.config.ts",
48
+ "docs": "tsx ../../scripts/generate-readmes.ts",
49
+ "test": "npm-run-all --npm-path npm test:*",
50
+ "test:tape": "tsx test.ts",
46
51
  "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
47
52
  },
48
53
  "devDependencies": {
49
- "@turf/meta": "^7.0.0-alpha.0",
50
- "benchmark": "*",
51
- "load-json-file": "*",
52
- "npm-run-all": "*",
53
- "tape": "*",
54
- "ts-node": "*",
55
- "typescript": "*",
56
- "write-json-file": "*"
54
+ "@turf/meta": "^7.0.0-alpha.110+1411d63a7",
55
+ "@types/benchmark": "^2.1.5",
56
+ "@types/tape": "^4.2.32",
57
+ "benchmark": "^2.1.4",
58
+ "load-json-file": "^7.0.1",
59
+ "npm-run-all": "^4.1.5",
60
+ "tape": "^5.7.2",
61
+ "tsup": "^8.0.1",
62
+ "tsx": "^4.6.2",
63
+ "typescript": "^5.2.2",
64
+ "write-json-file": "^5.0.0"
57
65
  },
58
66
  "dependencies": {
59
- "@turf/helpers": "^7.0.0-alpha.0",
67
+ "@turf/helpers": "^7.0.0-alpha.110+1411d63a7",
60
68
  "sweepline-intersections": "^1.5.0",
61
- "tslib": "^2.3.0"
69
+ "tslib": "^2.6.2"
62
70
  },
63
- "gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
71
+ "gitHead": "1411d63a74c275c9216fe48e9d3cb2d48a359068"
64
72
  }
package/dist/es/index.js DELETED
@@ -1,42 +0,0 @@
1
- import findIntersections from "sweepline-intersections";
2
- import { point } from "@turf/helpers";
3
- /**
4
- * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
5
- * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
6
- * returns {@link Point|points} at all self-intersections.
7
- *
8
- * @name kinks
9
- * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature
10
- * @returns {FeatureCollection<Point>} self-intersections
11
- * @example
12
- * var poly = turf.polygon([[
13
- * [-12.034835, 8.901183],
14
- * [-12.060413, 8.899826],
15
- * [-12.03638, 8.873199],
16
- * [-12.059383, 8.871418],
17
- * [-12.034835, 8.901183]
18
- * ]]);
19
- *
20
- * var kinks = turf.kinks(poly);
21
- *
22
- * //addToMap
23
- * var addToMap = [poly, kinks]
24
- */
25
- export default function kinks(featureIn) {
26
- const results = {
27
- type: "FeatureCollection",
28
- features: [],
29
- };
30
- if (featureIn.type === "Feature" &&
31
- (featureIn.geometry.type === "Point" ||
32
- featureIn.geometry.type === "MultiPoint")) {
33
- throw new Error("Input must be a LineString, MultiLineString, " +
34
- "Polygon, or MultiPolygon Feature or Geometry");
35
- }
36
- const intersections = findIntersections(featureIn, false);
37
- for (let i = 0; i < intersections.length; ++i) {
38
- const intersection = intersections[i];
39
- results.features.push(point([intersection[0], intersection[1]]));
40
- }
41
- return results;
42
- }
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const sweepline_intersections_1 = tslib_1.__importDefault(require("sweepline-intersections"));
5
- const helpers_1 = require("@turf/helpers");
6
- /**
7
- * Takes a {@link LineString|linestring}, {@link MultiLineString|multi-linestring},
8
- * {@link MultiPolygon|multi-polygon} or {@link Polygon|polygon} and
9
- * returns {@link Point|points} at all self-intersections.
10
- *
11
- * @name kinks
12
- * @param {Feature<LineString|MultiLineString|MultiPolygon|Polygon>} featureIn input feature
13
- * @returns {FeatureCollection<Point>} self-intersections
14
- * @example
15
- * var poly = turf.polygon([[
16
- * [-12.034835, 8.901183],
17
- * [-12.060413, 8.899826],
18
- * [-12.03638, 8.873199],
19
- * [-12.059383, 8.871418],
20
- * [-12.034835, 8.901183]
21
- * ]]);
22
- *
23
- * var kinks = turf.kinks(poly);
24
- *
25
- * //addToMap
26
- * var addToMap = [poly, kinks]
27
- */
28
- function kinks(featureIn) {
29
- const results = {
30
- type: "FeatureCollection",
31
- features: [],
32
- };
33
- if (featureIn.type === "Feature" &&
34
- (featureIn.geometry.type === "Point" ||
35
- featureIn.geometry.type === "MultiPoint")) {
36
- throw new Error("Input must be a LineString, MultiLineString, " +
37
- "Polygon, or MultiPolygon Feature or Geometry");
38
- }
39
- const intersections = sweepline_intersections_1.default(featureIn, false);
40
- for (let i = 0; i < intersections.length; ++i) {
41
- const intersection = intersections[i];
42
- results.features.push(helpers_1.point([intersection[0], intersection[1]]));
43
- }
44
- return results;
45
- }
46
- exports.default = kinks;