@turf/length 7.0.0-alpha.1 → 7.0.0-alpha.111

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
@@ -42,26 +42,21 @@ Returns **[number][8]** length of GeoJSON
42
42
 
43
43
  [8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
44
44
 
45
- <!-- This file is automatically generated. Please don't edit it directly:
46
- if you find an error, edit the source file (likely index.js), and re-run
47
- ./scripts/generate-readmes in the turf project. -->
45
+ <!-- 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. -->
48
46
 
49
47
  ---
50
48
 
51
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
52
- module collection dedicated to geographic algorithms. It is maintained in the
53
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
54
- PRs and issues.
49
+ 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.
55
50
 
56
51
  ### Installation
57
52
 
58
- Install this module individually:
53
+ Install this single module individually:
59
54
 
60
55
  ```sh
61
56
  $ npm install @turf/length
62
57
  ```
63
58
 
64
- Or install the Turf module that includes it as a function:
59
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
65
60
 
66
61
  ```sh
67
62
  $ npm install @turf/turf
@@ -0,0 +1,23 @@
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 _distance = require('@turf/distance');
6
+ var _meta = require('@turf/meta');
7
+ function length(geojson, options = {}) {
8
+ return _meta.segmentReduce.call(void 0,
9
+ geojson,
10
+ (previousValue, segment) => {
11
+ const coords = segment.geometry.coordinates;
12
+ return previousValue + _distance.distance.call(void 0, coords[0], coords[1], options);
13
+ },
14
+ 0
15
+ );
16
+ }
17
+ __name(length, "length");
18
+ var turf_length_default = length;
19
+
20
+
21
+
22
+ exports.default = turf_length_default; exports.length = length;
23
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";;;;AACA,SAAS,gBAAgB;AAEzB,SAAS,qBAAqB;AAkB9B,SAAS,OACP,SACA,UAEI,CAAC,GACG;AAER,SAAO;AAAA,IACL;AAAA,IACA,CAAC,eAAe,YAAY;AAC1B,YAAM,SAAS,QAAS,SAAS;AACjC,aAAO,gBAAiB,SAAS,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,IACA;AAAA,EACF;AACF;AAfS;AAkBT,IAAO,sBAAQ","sourcesContent":["import { Feature, FeatureCollection, GeometryCollection } from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { Units } from \"@turf/helpers\";\nimport { segmentReduce } from \"@turf/meta\";\n\n/**\n * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.\n *\n * @name length\n * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers\n * @returns {number} length of GeoJSON\n * @example\n * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);\n * var length = turf.length(line, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [line];\n * line.properties.distance = length;\n */\nfunction length(\n geojson: Feature<any> | FeatureCollection<any> | GeometryCollection,\n options: {\n units?: Units;\n } = {}\n): number {\n // Calculate distance from 2-vertex line segments\n return segmentReduce(\n geojson,\n (previousValue, segment) => {\n const coords = segment!.geometry.coordinates;\n return previousValue! + distance(coords[0], coords[1], options);\n },\n 0\n );\n}\n\nexport { length };\nexport default length;\n"]}
@@ -1,5 +1,6 @@
1
- import { Feature, FeatureCollection, GeometryCollection } from "geojson";
2
- import { Units } from "@turf/helpers";
1
+ import { Feature, FeatureCollection, GeometryCollection } from 'geojson';
2
+ import { Units } from '@turf/helpers';
3
+
3
4
  /**
4
5
  * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.
5
6
  *
@@ -16,6 +17,8 @@ import { Units } from "@turf/helpers";
16
17
  * var addToMap = [line];
17
18
  * line.properties.distance = length;
18
19
  */
19
- export default function length(geojson: Feature<any> | FeatureCollection<any> | GeometryCollection, options?: {
20
+ declare function length(geojson: Feature<any> | FeatureCollection<any> | GeometryCollection, options?: {
20
21
  units?: Units;
21
22
  }): number;
23
+
24
+ export { length as default, length };
@@ -1,5 +1,6 @@
1
- import distance from "@turf/distance";
2
- import { segmentReduce } from "@turf/meta";
1
+ import { Feature, FeatureCollection, GeometryCollection } from 'geojson';
2
+ import { Units } from '@turf/helpers';
3
+
3
4
  /**
4
5
  * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.
5
6
  *
@@ -16,10 +17,8 @@ import { segmentReduce } from "@turf/meta";
16
17
  * var addToMap = [line];
17
18
  * line.properties.distance = length;
18
19
  */
19
- export default function length(geojson, options = {}) {
20
- // Calculate distance from 2-vertex line segments
21
- return segmentReduce(geojson, (previousValue, segment) => {
22
- const coords = segment.geometry.coordinates;
23
- return previousValue + distance(coords[0], coords[1], options);
24
- }, 0);
25
- }
20
+ declare function length(geojson: Feature<any> | FeatureCollection<any> | GeometryCollection, options?: {
21
+ units?: Units;
22
+ }): number;
23
+
24
+ export { length as default, length };
@@ -0,0 +1,23 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // index.ts
5
+ import { distance } from "@turf/distance";
6
+ import { segmentReduce } from "@turf/meta";
7
+ function length(geojson, options = {}) {
8
+ return segmentReduce(
9
+ geojson,
10
+ (previousValue, segment) => {
11
+ const coords = segment.geometry.coordinates;
12
+ return previousValue + distance(coords[0], coords[1], options);
13
+ },
14
+ 0
15
+ );
16
+ }
17
+ __name(length, "length");
18
+ var turf_length_default = length;
19
+ export {
20
+ turf_length_default as default,
21
+ length
22
+ };
23
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, FeatureCollection, GeometryCollection } from \"geojson\";\nimport { distance } from \"@turf/distance\";\nimport { Units } from \"@turf/helpers\";\nimport { segmentReduce } from \"@turf/meta\";\n\n/**\n * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.\n *\n * @name length\n * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers\n * @returns {number} length of GeoJSON\n * @example\n * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);\n * var length = turf.length(line, {units: 'miles'});\n *\n * //addToMap\n * var addToMap = [line];\n * line.properties.distance = length;\n */\nfunction length(\n geojson: Feature<any> | FeatureCollection<any> | GeometryCollection,\n options: {\n units?: Units;\n } = {}\n): number {\n // Calculate distance from 2-vertex line segments\n return segmentReduce(\n geojson,\n (previousValue, segment) => {\n const coords = segment!.geometry.coordinates;\n return previousValue! + distance(coords[0], coords[1], options);\n },\n 0\n );\n}\n\nexport { length };\nexport default length;\n"],"mappings":";;;;AACA,SAAS,gBAAgB;AAEzB,SAAS,qBAAqB;AAkB9B,SAAS,OACP,SACA,UAEI,CAAC,GACG;AAER,SAAO;AAAA,IACL;AAAA,IACA,CAAC,eAAe,YAAY;AAC1B,YAAM,SAAS,QAAS,SAAS;AACjC,aAAO,gBAAiB,SAAS,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,OAAO;AAAA,IAChE;AAAA,IACA;AAAA,EACF;AACF;AAfS;AAkBT,IAAO,sBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/length",
3
- "version": "7.0.0-alpha.1",
3
+ "version": "7.0.0-alpha.111+08576cb50",
4
4
  "description": "turf length module",
5
5
  "author": "Turf Authors",
6
6
  "contributors": [
@@ -28,46 +28,51 @@
28
28
  "units",
29
29
  "gis"
30
30
  ],
31
- "main": "dist/js/index.js",
32
- "module": "dist/es/index.js",
31
+ "type": "commonjs",
32
+ "main": "dist/cjs/index.cjs",
33
+ "module": "dist/esm/index.mjs",
34
+ "types": "dist/cjs/index.d.ts",
33
35
  "exports": {
34
36
  "./package.json": "./package.json",
35
37
  ".": {
36
- "types": "./dist/js/index.d.ts",
37
- "import": "./dist/es/index.js",
38
- "require": "./dist/js/index.js"
38
+ "import": {
39
+ "types": "./dist/esm/index.d.mts",
40
+ "default": "./dist/esm/index.mjs"
41
+ },
42
+ "require": {
43
+ "types": "./dist/cjs/index.d.ts",
44
+ "default": "./dist/cjs/index.cjs"
45
+ }
39
46
  }
40
47
  },
41
- "types": "dist/js/index.d.ts",
42
48
  "sideEffects": false,
43
49
  "files": [
44
50
  "dist"
45
51
  ],
46
52
  "scripts": {
47
- "bench": "tsx bench.js",
48
- "build": "npm-run-all build:*",
49
- "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json",
50
- "build:js": "tsc",
51
- "docs": "tsx ../../scripts/generate-readmes",
52
- "test": "npm-run-all test:*",
53
- "test:tape": "tsx test.js"
53
+ "bench": "tsx bench.ts",
54
+ "build": "tsup --config ../../tsup.config.ts",
55
+ "docs": "tsx ../../scripts/generate-readmes.ts",
56
+ "test": "npm-run-all --npm-path npm test:*",
57
+ "test:tape": "tsx test.ts"
54
58
  },
55
59
  "devDependencies": {
56
- "@types/tape": "*",
57
- "benchmark": "*",
58
- "load-json-file": "*",
59
- "npm-run-all": "*",
60
- "tape": "*",
61
- "tslint": "*",
62
- "tsx": "*",
63
- "typescript": "*",
64
- "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"
65
70
  },
66
71
  "dependencies": {
67
- "@turf/distance": "^7.0.0-alpha.1",
68
- "@turf/helpers": "^7.0.0-alpha.1",
69
- "@turf/meta": "^7.0.0-alpha.1",
70
- "tslib": "^2.3.0"
72
+ "@turf/distance": "^7.0.0-alpha.111+08576cb50",
73
+ "@turf/helpers": "^7.0.0-alpha.111+08576cb50",
74
+ "@turf/meta": "^7.0.0-alpha.111+08576cb50",
75
+ "tslib": "^2.6.2"
71
76
  },
72
- "gitHead": "cf7a0c507b017ca066acffd0ce23bda5b393fb5a"
77
+ "gitHead": "08576cb50376e0199aea02dbd887e3af83672246"
73
78
  }
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const distance_1 = tslib_1.__importDefault(require("@turf/distance"));
5
- const meta_1 = require("@turf/meta");
6
- /**
7
- * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored.
8
- *
9
- * @name length
10
- * @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure
11
- * @param {Object} [options={}] Optional parameters
12
- * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers
13
- * @returns {number} length of GeoJSON
14
- * @example
15
- * var line = turf.lineString([[115, -32], [131, -22], [143, -25], [150, -34]]);
16
- * var length = turf.length(line, {units: 'miles'});
17
- *
18
- * //addToMap
19
- * var addToMap = [line];
20
- * line.properties.distance = length;
21
- */
22
- function length(geojson, options = {}) {
23
- // Calculate distance from 2-vertex line segments
24
- return meta_1.segmentReduce(geojson, (previousValue, segment) => {
25
- const coords = segment.geometry.coordinates;
26
- return previousValue + distance_1.default(coords[0], coords[1], options);
27
- }, 0);
28
- }
29
- exports.default = length;