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 5.1.5 to 6.0.0

index.ts

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"
}
}
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