New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@turf/length

Package Overview
Dependencies
Maintainers
4
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/length - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

index.d.ts

7

index.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
}
Object.defineProperty(exports, "__esModule", { value: true });
var distance_1 = require("@turf/distance");
var distance_1 = __importDefault(require("@turf/distance"));
var meta_1 = require("@turf/meta");

@@ -23,3 +26,3 @@ /**

if (options === void 0) { options = {}; }
// Calculate distance from 2-vertex line segements
// Calculate distance from 2-vertex line segments
return meta_1.segmentReduce(geojson, function (previousValue, segment) {

@@ -26,0 +29,0 @@ var coords = segment.geometry.coordinates;

@@ -1,4 +0,4 @@

import distance from '@turf/distance';
import { segmentReduce } from '@turf/meta';
import { Feature, FeatureCollection, LineString, MultiLineString, GeometryCollection, Units } from '@turf/helpers';
import distance from "@turf/distance";
import { Feature, FeatureCollection, GeometryCollection, LineString, MultiLineString, Units } from "@turf/helpers";
import { segmentReduce } from "@turf/meta";

@@ -22,9 +22,9 @@ /**

export default function length(geojson: Feature<any> | FeatureCollection<any> | GeometryCollection, options: {
units?: Units
units?: Units,
} = {}): number {
// Calculate distance from 2-vertex line segements
return segmentReduce(geojson, function (previousValue, segment) {
var coords = segment.geometry.coordinates;
return previousValue + distance(coords[0], coords[1], options);
// Calculate distance from 2-vertex line segments
return segmentReduce(geojson, (previousValue, segment) => {
const coords = segment!.geometry.coordinates;
return previousValue! + distance(coords[0], coords[1], options);
}, 0);
}
{
"name": "@turf/length",
"version": "6.0.0",
"version": "6.0.1",
"description": "turf length module",
"main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.ts"
"index.ts",
"index.d.ts"
],

@@ -44,3 +46,5 @@ "scripts": {

"tape": "*",
"write-json-file": "*"
"write-json-file": "*",
"tslint": "*",
"@types/tape": "*"
},

@@ -47,0 +51,0 @@ "dependencies": {

@@ -7,9 +7,9 @@ # @turf/length

Takes a [GeoJSON](https://tools.ietf.org/html/rfc7946#section-3) and measures its length in the specified units, [(Multi)Point](https://tools.ietf.org/html/rfc7946#section-3.1.2)'s distance are ignored.
Takes a [GeoJSON][1] and measures its length in the specified units, [(Multi)Point][2]'s distance are ignored.
**Parameters**
- `geojson` **[GeoJSON](https://tools.ietf.org/html/rfc7946#section-3)** GeoJSON to measure
- `options` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** Optional parameters (optional, default `{}`)
- `options.units` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** can be degrees, radians, miles, or kilometers (optional, default `kilometers`)
- `geojson` **[Feature][3]&lt;([LineString][4] \| [MultiLineString][5])>** GeoJSON to measure
- `options` **[Object][6]** Optional parameters (optional, default `{}`)
- `options.units` **[string][7]** can be degrees, radians, miles, or kilometers (optional, default `kilometers`)

@@ -27,4 +27,20 @@ **Examples**

Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** length of GeoJSON
Returns **[number][8]** length of GeoJSON
[1]: https://tools.ietf.org/html/rfc7946#section-3
[2]: https://tools.ietf.org/html/rfc7946#section-3.1.2
[3]: https://tools.ietf.org/html/rfc7946#section-3.2
[4]: https://tools.ietf.org/html/rfc7946#section-3.1.4
[5]: https://tools.ietf.org/html/rfc7946#section-3.1.5
[6]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
[7]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
[8]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number
<!-- This file is automatically generated. Please don't edit it directly:

@@ -31,0 +47,0 @@ if you find an error, edit the source file (likely index.js), and re-run

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc