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 4.7.3 to 5.0.0

main.js

16

index.d.ts

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

/// <reference types="geojson" />
import { Units, Point, Feature, Position } from '@turf/helpers'
import {Units} from '@turf/helpers'
type Point = GeoJSON.Feature<GeoJSON.Point> | GeoJSON.Point | number[];
/**
* http://turfjs.org/docs/#distance
*/
declare function distance(from: Point, to: Point, units?: Units): number;
declare namespace distance { }
export = distance;
export default function distance(
from: Feature<Point> | Point | Position,
to: Feature<Point> | Point | Position,
options?: {
units?: Units
}
): number;

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

var getCoord = require('@turf/invariant').getCoord;
var radiansToDistance = require('@turf/helpers').radiansToDistance;
import { getCoord } from '@turf/invariant';
import { radiansToDistance } from '@turf/helpers';
//http://en.wikipedia.org/wiki/Haversine_formula

@@ -15,3 +16,4 @@ //http://www.movable-type.co.uk/scripts/latlong.html

* @param {Geometry|Feature<Point>|Array<number>} to destination point
* @param {string} [units=kilometers] can be degrees, radians, miles, or kilometers
* @param {Object} [options={}] Optional parameters
* @param {string} [options.units='kilometers'] can be degrees, radians, miles, or kilometers
* @returns {number} distance between the two points

@@ -29,3 +31,6 @@ * @example

*/
module.exports = function (from, to, units) {
function distance(from, to, options) {
// Backwards compatible with v4.0
var units = (typeof options === 'object') ? options.units : options;
var degrees2radians = Math.PI / 180;

@@ -43,2 +48,4 @@ var coordinates1 = getCoord(from);

return radiansToDistance(2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)), units);
};
}
export default distance;
{
"name": "@turf/distance",
"version": "4.7.3",
"version": "5.0.0",
"description": "turf distance module",
"main": "index.js",
"main": "main",
"module": "index",
"jsnext:main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"main.js"
],
"scripts": {
"test": "node test.js",
"bench": "node bench.js"
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"posttest": "uglifyjs main.js -o main.min.js",
"bench": "node -r @std/esm bench.js"
},

@@ -32,11 +37,18 @@ "repository": {

"devDependencies": {
"benchmark": "^2.1.4",
"load-json-file": "^2.0.0",
"tape": "^4.6.3",
"write-json-file": "^2.0.0"
"benchmark": "*",
"load-json-file": "*",
"tape": "*",
"write-json-file": "*",
"rollup": "*",
"@std/esm": "*",
"uglify-js": "*"
},
"dependencies": {
"@turf/helpers": "^4.7.3",
"@turf/invariant": "^4.7.3"
"@turf/helpers": "5.0.0",
"@turf/invariant": "5.0.0"
},
"@std/esm": {
"esm": "js",
"cjs": true
}
}
# @turf/distance
# distance
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## distance
Calculates the distance between two [points](http://geojson.org/geojson-spec.html#point) in degrees, radians,

@@ -14,3 +16,3 @@ miles, or kilometers. This uses the

- `to` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[Point](http://geojson.org/geojson-spec.html#point)> | [Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** destination point
- `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`)
- `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`)

@@ -17,0 +19,0 @@ **Examples**

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