@turf/length
Advanced tools
Comparing version 5.1.5 to 6.0.0
25
index.js
@@ -1,5 +0,5 @@ | ||
import distance from '@turf/distance'; | ||
import { segmentReduce } from '@turf/meta'; | ||
import { isObject } from '@turf/helpers'; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var distance_1 = require("@turf/distance"); | ||
var meta_1 = require("@turf/meta"); | ||
/** | ||
@@ -9,3 +9,3 @@ * Takes a {@link GeoJSON} and measures its length in the specified units, {@link (Multi)Point}'s distance are ignored. | ||
* @name length | ||
* @param {GeoJSON} geojson GeoJSON to measure | ||
* @param {Feature<LineString|MultiLineString>} geojson GeoJSON to measure | ||
* @param {Object} [options={}] Optional parameters | ||
@@ -23,16 +23,9 @@ * @param {string} [options.units=kilometers] can be degrees, radians, miles, or kilometers | ||
function length(geojson, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
// Input Validation | ||
if (!geojson) throw new Error('geojson is required'); | ||
if (options === void 0) { options = {}; } | ||
// Calculate distance from 2-vertex line segements | ||
return segmentReduce(geojson, function (previousValue, segment) { | ||
return meta_1.segmentReduce(geojson, function (previousValue, segment) { | ||
var coords = segment.geometry.coordinates; | ||
return previousValue + distance(coords[0], coords[1], options); | ||
return previousValue + distance_1.default(coords[0], coords[1], options); | ||
}, 0); | ||
} | ||
export default length; | ||
exports.default = length; |
{ | ||
"name": "@turf/length", | ||
"version": "5.1.5", | ||
"version": "6.0.0", | ||
"description": "turf length module", | ||
"main": "main.js", | ||
"module": "main.es.js", | ||
"types": "index.d.ts", | ||
"main": "index", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts", | ||
"main.js", | ||
"main.es.js" | ||
"index.ts" | ||
], | ||
"scripts": { | ||
"pretest": "rollup -c ../../rollup.config.js", | ||
"test": "node -r @std/esm test.js", | ||
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node -r @std/esm bench.js", | ||
"prepare": "tsc", | ||
"pretest": "tsc", | ||
"test": "node test.js", | ||
"bench": "node bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
@@ -44,6 +40,5 @@ }, | ||
"devDependencies": { | ||
"@std/esm": "*", | ||
"benchmark": "*", | ||
"load-json-file": "*", | ||
"rollup": "*", | ||
"typescript": "*", | ||
"tape": "*", | ||
@@ -53,10 +48,6 @@ "write-json-file": "*" | ||
"dependencies": { | ||
"@turf/distance": "^5.1.5", | ||
"@turf/helpers": "^5.1.5", | ||
"@turf/meta": "^5.1.5" | ||
}, | ||
"@std/esm": { | ||
"esm": "js", | ||
"cjs": true | ||
"@turf/distance": "6.x", | ||
"@turf/helpers": "6.x", | ||
"@turf/meta": "6.x" | ||
} | ||
} |
5
6325
5
57
+ Added@turf/distance@6.5.0(transitive)
+ Added@turf/helpers@6.5.0(transitive)
+ Added@turf/invariant@6.5.0(transitive)
+ Added@turf/meta@6.5.0(transitive)
- Removed@turf/distance@5.1.5(transitive)
- Removed@turf/helpers@5.1.5(transitive)
- Removed@turf/invariant@5.2.0(transitive)
- Removed@turf/meta@5.2.0(transitive)
Updated@turf/distance@6.x
Updated@turf/helpers@6.x
Updated@turf/meta@6.x