Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/distance

Package Overview
Dependencies
Maintainers
4
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/distance - npm Package Compare versions

Comparing version 5.1.5 to 6.0.0

index.ts

41

index.js

@@ -1,12 +0,10 @@

import { getCoord } from '@turf/invariant';
import { radiansToLength, isObject, degreesToRadians } from '@turf/helpers';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var invariant_1 = require("@turf/invariant");
var helpers_1 = require("@turf/helpers");
//http://en.wikipedia.org/wiki/Haversine_formula
//http://www.movable-type.co.uk/scripts/latlong.html
/**
* Calculates the distance between two {@link Point|points} in degrees, radians,
* miles, or kilometers. This uses the
* [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula)
* to account for global curvature.
* Calculates the distance between two {@link Point|points} in degrees, radians, miles, or kilometers.
* This uses the [Haversine formula](http://en.wikipedia.org/wiki/Haversine_formula) to account for global curvature.
*

@@ -32,20 +30,13 @@ * @name distance

function distance(from, to, options) {
// Optional parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
var units = options.units;
var coordinates1 = getCoord(from);
var coordinates2 = getCoord(to);
var dLat = degreesToRadians((coordinates2[1] - coordinates1[1]));
var dLon = degreesToRadians((coordinates2[0] - coordinates1[0]));
var lat1 = degreesToRadians(coordinates1[1]);
var lat2 = degreesToRadians(coordinates2[1]);
if (options === void 0) { options = {}; }
var coordinates1 = invariant_1.getCoord(from);
var coordinates2 = invariant_1.getCoord(to);
var dLat = helpers_1.degreesToRadians((coordinates2[1] - coordinates1[1]));
var dLon = helpers_1.degreesToRadians((coordinates2[0] - coordinates1[0]));
var lat1 = helpers_1.degreesToRadians(coordinates1[1]);
var lat2 = helpers_1.degreesToRadians(coordinates2[1]);
var a = Math.pow(Math.sin(dLat / 2), 2) +
Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
return radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), units);
Math.pow(Math.sin(dLon / 2), 2) * Math.cos(lat1) * Math.cos(lat2);
return helpers_1.radiansToLength(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), options.units);
}
export default distance;
exports.default = distance;
{
"name": "@turf/distance",
"version": "5.1.5",
"version": "6.0.0",
"description": "turf distance 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"

@@ -38,6 +34,5 @@ },

"devDependencies": {
"@std/esm": "*",
"benchmark": "*",
"load-json-file": "*",
"rollup": "*",
"typescript": "*",
"tape": "*",

@@ -47,9 +42,5 @@ "write-json-file": "*"

"dependencies": {
"@turf/helpers": "^5.1.5",
"@turf/invariant": "^5.1.5"
},
"@std/esm": {
"esm": "js",
"cjs": true
"@turf/helpers": "6.x",
"@turf/invariant": "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