@turf/flatten 7.0.0-alpha.2 → 7.0.0

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
@@ -37,26 +37,21 @@ Returns **[FeatureCollection][5]\<any>** all Multi-Geometries are flattened into
37
37
 
38
38
  [5]: https://tools.ietf.org/html/rfc7946#section-3.3
39
39
 
40
- <!-- This file is automatically generated. Please don't edit it directly:
41
- if you find an error, edit the source file (likely index.js), and re-run
42
- ./scripts/generate-readmes in the turf project. -->
40
+ <!-- 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. -->
43
41
 
44
42
  ---
45
43
 
46
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
47
- module collection dedicated to geographic algorithms. It is maintained in the
48
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
49
- PRs and issues.
44
+ 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.
50
45
 
51
46
  ### Installation
52
47
 
53
- Install this module individually:
48
+ Install this single module individually:
54
49
 
55
50
  ```sh
56
51
  $ npm install @turf/flatten
57
52
  ```
58
53
 
59
- Or install the Turf module that includes it as a function:
54
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
60
55
 
61
56
  ```sh
62
57
  $ npm install @turf/turf
@@ -0,0 +1,22 @@
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.ts
5
+ var _meta = require('@turf/meta');
6
+ var _helpers = require('@turf/helpers');
7
+ function flatten(geojson) {
8
+ if (!geojson)
9
+ throw new Error("geojson is required");
10
+ var results = [];
11
+ _meta.flattenEach.call(void 0, geojson, function(feature) {
12
+ results.push(feature);
13
+ });
14
+ return _helpers.featureCollection.call(void 0, results);
15
+ }
16
+ __name(flatten, "flatten");
17
+ var turf_flatten_default = flatten;
18
+
19
+
20
+
21
+ exports.default = turf_flatten_default; exports.flatten = flatten;
22
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AA6ClC,SAAS,QAAQ,SAAwC;AACvD,MAAI,CAAC;AAAS,UAAM,IAAI,MAAM,qBAAqB;AAEnD,MAAI,UAAqB,CAAC;AAC1B,cAAY,SAAS,SAAU,SAAS;AACtC,YAAQ,KAAK,OAAO;AAAA,EACtB,CAAC;AACD,SAAO,kBAAkB,OAAO;AAClC;AARS;AAWT,IAAO,uBAAQ","sourcesContent":["import { flattenEach } from \"@turf/meta\";\nimport { featureCollection } from \"@turf/helpers\";\nimport type { AllGeoJSON } from \"@turf/helpers\";\nimport type {\n Feature,\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n FeatureCollection,\n Polygon,\n MultiPolygon,\n} from \"geojson\";\n\n/**\n * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).\n *\n * @name flatten\n * @param {GeoJSON} geojson any valid GeoJSON Object\n * @returns {FeatureCollection<any>} all Multi-Geometries are flattened into single Features\n * @example\n * var multiGeometry = turf.multiPolygon([\n * [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],\n * [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],\n * [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]\n * ]);\n *\n * var flatten = turf.flatten(multiGeometry);\n *\n * //addToMap\n * var addToMap = [flatten]\n */\nfunction flatten<T extends Point | MultiPoint>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Point>;\n\nfunction flatten<T extends LineString | MultiLineString>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<LineString>;\n\nfunction flatten<T extends Polygon | MultiPolygon>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Polygon>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection<any>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection {\n if (!geojson) throw new Error(\"geojson is required\");\n\n var results: Feature[] = [];\n flattenEach(geojson, function (feature) {\n results.push(feature);\n });\n return featureCollection(results);\n}\n\nexport { flatten };\nexport default flatten;\n"]}
@@ -1,5 +1,5 @@
1
- import { flattenEach } from '@turf/meta';
2
- import { featureCollection } from '@turf/helpers';
1
+ import { AllGeoJSON } from '@turf/helpers';
2
+ import { Point, MultiPoint, Feature, FeatureCollection, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
3
3
 
4
4
  /**
5
5
  * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
@@ -19,14 +19,9 @@ import { featureCollection } from '@turf/helpers';
19
19
  * //addToMap
20
20
  * var addToMap = [flatten]
21
21
  */
22
- function flatten(geojson) {
23
- if (!geojson) throw new Error("geojson is required");
22
+ declare function flatten<T extends Point | MultiPoint>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Point>;
23
+ declare function flatten<T extends LineString | MultiLineString>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<LineString>;
24
+ declare function flatten<T extends Polygon | MultiPolygon>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Polygon>;
25
+ declare function flatten(geojson: AllGeoJSON): FeatureCollection<any>;
24
26
 
25
- var results = [];
26
- flattenEach(geojson, function (feature) {
27
- results.push(feature);
28
- });
29
- return featureCollection(results);
30
- }
31
-
32
- export default flatten;
27
+ export { flatten as default, flatten };
@@ -1,7 +1,5 @@
1
- 'use strict';
2
-
3
- var meta = require('@turf/meta');
4
- var helpers = require('@turf/helpers');
1
+ import { AllGeoJSON } from '@turf/helpers';
2
+ import { Point, MultiPoint, Feature, FeatureCollection, LineString, MultiLineString, Polygon, MultiPolygon } from 'geojson';
5
3
 
6
4
  /**
7
5
  * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).
@@ -21,15 +19,9 @@ var helpers = require('@turf/helpers');
21
19
  * //addToMap
22
20
  * var addToMap = [flatten]
23
21
  */
24
- function flatten(geojson) {
25
- if (!geojson) throw new Error("geojson is required");
26
-
27
- var results = [];
28
- meta.flattenEach(geojson, function (feature) {
29
- results.push(feature);
30
- });
31
- return helpers.featureCollection(results);
32
- }
22
+ declare function flatten<T extends Point | MultiPoint>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Point>;
23
+ declare function flatten<T extends LineString | MultiLineString>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<LineString>;
24
+ declare function flatten<T extends Polygon | MultiPolygon>(geojson: Feature<T> | FeatureCollection<T> | T): FeatureCollection<Polygon>;
25
+ declare function flatten(geojson: AllGeoJSON): FeatureCollection<any>;
33
26
 
34
- module.exports = flatten;
35
- module.exports.default = flatten;
27
+ export { flatten as default, flatten };
@@ -0,0 +1,22 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ import { flattenEach } from "@turf/meta";
6
+ import { featureCollection } from "@turf/helpers";
7
+ function flatten(geojson) {
8
+ if (!geojson)
9
+ throw new Error("geojson is required");
10
+ var results = [];
11
+ flattenEach(geojson, function(feature) {
12
+ results.push(feature);
13
+ });
14
+ return featureCollection(results);
15
+ }
16
+ __name(flatten, "flatten");
17
+ var turf_flatten_default = flatten;
18
+ export {
19
+ turf_flatten_default as default,
20
+ flatten
21
+ };
22
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { flattenEach } from \"@turf/meta\";\nimport { featureCollection } from \"@turf/helpers\";\nimport type { AllGeoJSON } from \"@turf/helpers\";\nimport type {\n Feature,\n Point,\n MultiPoint,\n LineString,\n MultiLineString,\n FeatureCollection,\n Polygon,\n MultiPolygon,\n} from \"geojson\";\n\n/**\n * Flattens any {@link GeoJSON} to a {@link FeatureCollection} inspired by [geojson-flatten](https://github.com/tmcw/geojson-flatten).\n *\n * @name flatten\n * @param {GeoJSON} geojson any valid GeoJSON Object\n * @returns {FeatureCollection<any>} all Multi-Geometries are flattened into single Features\n * @example\n * var multiGeometry = turf.multiPolygon([\n * [[[102.0, 2.0], [103.0, 2.0], [103.0, 3.0], [102.0, 3.0], [102.0, 2.0]]],\n * [[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]],\n * [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]\n * ]);\n *\n * var flatten = turf.flatten(multiGeometry);\n *\n * //addToMap\n * var addToMap = [flatten]\n */\nfunction flatten<T extends Point | MultiPoint>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Point>;\n\nfunction flatten<T extends LineString | MultiLineString>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<LineString>;\n\nfunction flatten<T extends Polygon | MultiPolygon>(\n geojson: Feature<T> | FeatureCollection<T> | T\n): FeatureCollection<Polygon>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection<any>;\n\nfunction flatten(geojson: AllGeoJSON): FeatureCollection {\n if (!geojson) throw new Error(\"geojson is required\");\n\n var results: Feature[] = [];\n flattenEach(geojson, function (feature) {\n results.push(feature);\n });\n return featureCollection(results);\n}\n\nexport { flatten };\nexport default flatten;\n"],"mappings":";;;;AAAA,SAAS,mBAAmB;AAC5B,SAAS,yBAAyB;AA6ClC,SAAS,QAAQ,SAAwC;AACvD,MAAI,CAAC;AAAS,UAAM,IAAI,MAAM,qBAAqB;AAEnD,MAAI,UAAqB,CAAC;AAC1B,cAAY,SAAS,SAAU,SAAS;AACtC,YAAQ,KAAK,OAAO;AAAA,EACtB,CAAC;AACD,SAAO,kBAAkB,OAAO;AAClC;AARS;AAWT,IAAO,uBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/flatten",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.0.0",
4
4
  "description": "turf flatten module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -27,42 +27,51 @@
27
27
  "gis",
28
28
  "featurecollection"
29
29
  ],
30
- "main": "dist/js/index.js",
31
- "module": "dist/es/index.js",
30
+ "type": "module",
31
+ "main": "dist/cjs/index.cjs",
32
+ "module": "dist/esm/index.js",
33
+ "types": "dist/esm/index.d.ts",
32
34
  "exports": {
33
35
  "./package.json": "./package.json",
34
36
  ".": {
35
- "types": "./index.d.ts",
36
- "import": "./dist/es/index.js",
37
- "require": "./dist/js/index.js"
37
+ "import": {
38
+ "types": "./dist/esm/index.d.ts",
39
+ "default": "./dist/esm/index.js"
40
+ },
41
+ "require": {
42
+ "types": "./dist/cjs/index.d.cts",
43
+ "default": "./dist/cjs/index.cjs"
44
+ }
38
45
  }
39
46
  },
40
- "types": "index.d.ts",
41
47
  "sideEffects": false,
42
48
  "files": [
43
- "dist",
44
- "index.d.ts"
49
+ "dist"
45
50
  ],
46
51
  "scripts": {
47
- "bench": "tsx bench.js",
48
- "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
49
- "docs": "tsx ../../scripts/generate-readmes",
50
- "test": "npm-run-all test:*",
51
- "test:tape": "tsx test.js",
52
- "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
52
+ "bench": "tsx bench.ts",
53
+ "build": "tsup --config ../../tsup.config.ts",
54
+ "docs": "tsx ../../scripts/generate-readmes.ts",
55
+ "test": "npm-run-all --npm-path npm test:*",
56
+ "test:tape": "tsx test.ts",
57
+ "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
53
58
  },
54
59
  "devDependencies": {
55
- "benchmark": "*",
56
- "load-json-file": "*",
57
- "npm-run-all": "*",
58
- "rollup": "*",
59
- "tape": "*",
60
- "tsx": "*",
61
- "write-json-file": "*"
60
+ "@types/benchmark": "^2.1.5",
61
+ "@types/tape": "^4.2.32",
62
+ "benchmark": "^2.1.4",
63
+ "load-json-file": "^7.0.1",
64
+ "npm-run-all": "^4.1.5",
65
+ "tape": "^5.7.2",
66
+ "tsup": "^8.0.1",
67
+ "tsx": "^4.6.2",
68
+ "typescript": "^5.2.2",
69
+ "write-json-file": "^5.0.0"
62
70
  },
63
71
  "dependencies": {
64
- "@turf/helpers": "^7.0.0-alpha.2",
65
- "@turf/meta": "^7.0.0-alpha.2"
72
+ "@turf/helpers": "^7.0.0",
73
+ "@turf/meta": "^7.0.0",
74
+ "tslib": "^2.6.2"
66
75
  },
67
- "gitHead": "dd35b52725945b4fa29a98d9a550733e06cc222e"
76
+ "gitHead": "3d3a7917025fbabe191dbddbc89754b86f9c7739"
68
77
  }
@@ -1 +0,0 @@
1
- {"type":"module"}
package/index.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import {
2
- Point,
3
- MultiPoint,
4
- LineString,
5
- MultiLineString,
6
- Polygon,
7
- MultiPolygon,
8
- Feature,
9
- FeatureCollection,
10
- } from "geojson";
11
- import { AllGeoJSON } from "@turf/helpers";
12
-
13
- /**
14
- * http://turfjs.org/docs/#flatten
15
- */
16
- declare function flatten<T extends Point | MultiPoint>(
17
- geojson: Feature<T> | FeatureCollection<T> | T
18
- ): FeatureCollection<Point>;
19
- declare function flatten<T extends LineString | MultiLineString>(
20
- geojson: Feature<T> | FeatureCollection<T> | T
21
- ): FeatureCollection<LineString>;
22
- declare function flatten<T extends Polygon | MultiPolygon>(
23
- geojson: Feature<T> | FeatureCollection<T> | T
24
- ): FeatureCollection<Polygon>;
25
- declare function flatten(geojson: AllGeoJSON): FeatureCollection<any>;
26
-
27
- export default flatten;