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

@turf/helpers

Package Overview
Dependencies
Maintainers
4
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/helpers - npm Package Compare versions

Comparing version 5.0.1 to 5.0.4

28

index.d.ts

@@ -102,30 +102,30 @@ /// <reference types='geojson' />

/**
* http://turfjs.org/docs/#radianstodistance
* http://turfjs.org/docs/#radianstolength
*/
export function radiansToDistance(radians: number, units?: Units): number
export function radiansToLength(radians: number, units?: Units): number
/**
* http://turfjs.org/docs/#distancetoradians
* http://turfjs.org/docs/#lengthtoradians
*/
export function distanceToRadians(distance: number, units?: Units): number
export function lengthToRadians(distance: number, units?: Units): number
/**
* http://turfjs.org/docs/#distancetodegrees
* http://turfjs.org/docs/#lengthtodegrees
*/
export function distanceToDegrees(distance: number, units?: Units): number
export function lengthToDegrees(distance: number, units?: Units): number
/**
* http://turfjs.org/docs/#bearingtoangle
* http://turfjs.org/docs/#bearingtoazimuth
*/
export function bearingToAngle(bearing: number): number
export function bearingToAzimuth(bearing: number): number
/**
* http://turfjs.org/docs/#radians2degrees
* http://turfjs.org/docs/#radianstodegrees
*/
export function radians2degrees(radians: number): number
export function radiansToDegrees(radians: number): number
/**
* http://turfjs.org/docs/#degrees2radians
* http://turfjs.org/docs/#degreestoradians
*/
export function degrees2radians(degrees: number): number
export function degreesToRadians(degrees: number): number

@@ -138,5 +138,5 @@ /**

/**
* http://turfjs.org/docs/#convertdistance
* http://turfjs.org/docs/#convertlength
*/
export function convertDistance(distance: number, originalUnit: Units, finalUnit?: Units): number
export function convertLength(length: number, originalUnit: Units, finalUnit?: Units): number

@@ -143,0 +143,0 @@ /**

@@ -89,3 +89,6 @@ /**

if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (bbox) {
if (!Array.isArray(bbox)) throw new Error('bbox must be an Array');
if (bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
}
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');

@@ -155,3 +158,3 @@

if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length === undefined) throw new Error('Coordinates must be an array');
if (!Array.isArray(coordinates)) throw new Error('Coordinates must be an Array');
if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');

@@ -417,3 +420,3 @@ if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('Coordinates must contain numbers');

*
* @name radiansToDistance
* @name radiansToLength
* @param {number} radians in radians across the sphere

@@ -423,3 +426,3 @@ * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.

*/
export function radiansToDistance(radians, units) {
export function radiansToLength(radians, units) {
if (radians === undefined || radians === null) throw new Error('radians is required');

@@ -437,3 +440,3 @@

*
* @name distanceToRadians
* @name lengthToRadians
* @param {number} distance in real units

@@ -443,3 +446,3 @@ * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.

*/
export function distanceToRadians(distance, units) {
export function lengthToRadians(distance, units) {
if (distance === undefined || distance === null) throw new Error('distance is required');

@@ -457,3 +460,3 @@

*
* @name distanceToDegrees
* @name lengthToDegrees
* @param {number} distance in real units

@@ -463,4 +466,4 @@ * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.

*/
export function distanceToDegrees(distance, units) {
return radians2degrees(distanceToRadians(distance, units));
export function lengthToDegrees(distance, units) {
return radiansToDegrees(lengthToRadians(distance, units));
}

@@ -472,7 +475,7 @@

*
* @name bearingToAngle
* @name bearingToAzimuth
* @param {number} bearing angle, between -180 and +180 degrees
* @returns {number} angle between 0 and 360 degrees
*/
export function bearingToAngle(bearing) {
export function bearingToAzimuth(bearing) {
if (bearing === null || bearing === undefined) throw new Error('bearing is required');

@@ -488,7 +491,7 @@

*
* @name radians2degrees
* @name radiansToDegrees
* @param {number} radians angle in radians
* @returns {number} degrees between 0 and 360 degrees
*/
export function radians2degrees(radians) {
export function radiansToDegrees(radians) {
if (radians === null || radians === undefined) throw new Error('radians is required');

@@ -503,7 +506,7 @@

*
* @name degrees2radians
* @name degreesToradians
* @param {number} degrees angle between 0 and 360 degrees
* @returns {number} angle in radians
*/
export function degrees2radians(degrees) {
export function degreesToRadians(degrees) {
if (degrees === null || degrees === undefined) throw new Error('degrees is required');

@@ -516,16 +519,15 @@

/**
* Converts a distance to the requested unit.
* Converts a length to the requested unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @param {number} distance to be converted
* @param {string} originalUnit of the distance
* @param {number} length to be converted
* @param {string} originalUnit of the length
* @param {string} [finalUnit='kilometers'] returned unit
* @returns {number} the converted distance
* @returns {number} the converted length
*/
export function convertDistance(distance, originalUnit, finalUnit) {
if (distance === null || distance === undefined) throw new Error('distance is required');
if (!(distance >= 0)) throw new Error('distance must be a positive number');
export function convertLength(length, originalUnit, finalUnit) {
if (length === null || length === undefined) throw new Error('length is required');
if (!(length >= 0)) throw new Error('length must be a positive number');
var convertedDistance = radiansToDistance(distanceToRadians(distance, originalUnit), finalUnit || 'kilometers');
return convertedDistance;
return radiansToLength(lengthToRadians(length, originalUnit), finalUnit || 'kilometers');
}

@@ -583,1 +585,30 @@

}
// Deprecated methods
export function radians2degrees() {
throw new Error('method has been renamed to `radiansToDegrees`');
}
export function degrees2radians() {
throw new Error('method has been renamed to `degreesToRadians`');
}
export function distanceToDegrees() {
throw new Error('method has been renamed to `lengthToDegrees`');
}
export function distanceToRadians() {
throw new Error('method has been renamed to `lengthToRadians`');
}
export function radiansToDistance() {
throw new Error('method has been renamed to `radiansToLength`');
}
export function bearingToAngle() {
throw new Error('method has been renamed to `bearingToAzimuth`');
}
export function convertDistance() {
throw new Error('method has been renamed to `convertLength`');
}

@@ -93,3 +93,6 @@ 'use strict';

if (properties && properties.constructor !== Object) throw new Error('properties must be an Object');
if (bbox && bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
if (bbox) {
if (!Array.isArray(bbox)) throw new Error('bbox must be an Array');
if (bbox.length !== 4) throw new Error('bbox must be an Array of 4 numbers');
}
if (id && ['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string');

@@ -159,3 +162,3 @@

if (!coordinates) throw new Error('No coordinates passed');
if (coordinates.length === undefined) throw new Error('Coordinates must be an array');
if (!Array.isArray(coordinates)) throw new Error('Coordinates must be an Array');
if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');

@@ -421,3 +424,3 @@ if (!isNumber(coordinates[0]) || !isNumber(coordinates[1])) throw new Error('Coordinates must contain numbers');

*
* @name radiansToDistance
* @name radiansToLength
* @param {number} radians in radians across the sphere

@@ -427,3 +430,3 @@ * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.

*/
function radiansToDistance(radians, units) {
function radiansToLength(radians, units) {
if (radians === undefined || radians === null) throw new Error('radians is required');

@@ -441,3 +444,3 @@

*
* @name distanceToRadians
* @name lengthToRadians
* @param {number} distance in real units

@@ -447,3 +450,3 @@ * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.

*/
function distanceToRadians(distance, units) {
function lengthToRadians(distance, units) {
if (distance === undefined || distance === null) throw new Error('distance is required');

@@ -461,3 +464,3 @@

*
* @name distanceToDegrees
* @name lengthToDegrees
* @param {number} distance in real units

@@ -467,4 +470,4 @@ * @param {string} [units='kilometers'] can be degrees, radians, miles, or kilometers inches, yards, metres, meters, kilometres, kilometers.

*/
function distanceToDegrees(distance, units) {
return radians2degrees(distanceToRadians(distance, units));
function lengthToDegrees(distance, units) {
return radiansToDegrees(lengthToRadians(distance, units));
}

@@ -476,7 +479,7 @@

*
* @name bearingToAngle
* @name bearingToAzimuth
* @param {number} bearing angle, between -180 and +180 degrees
* @returns {number} angle between 0 and 360 degrees
*/
function bearingToAngle(bearing) {
function bearingToAzimuth(bearing) {
if (bearing === null || bearing === undefined) throw new Error('bearing is required');

@@ -492,7 +495,7 @@

*
* @name radians2degrees
* @name radiansToDegrees
* @param {number} radians angle in radians
* @returns {number} degrees between 0 and 360 degrees
*/
function radians2degrees(radians) {
function radiansToDegrees(radians) {
if (radians === null || radians === undefined) throw new Error('radians is required');

@@ -507,7 +510,7 @@

*
* @name degrees2radians
* @name degreesToradians
* @param {number} degrees angle between 0 and 360 degrees
* @returns {number} angle in radians
*/
function degrees2radians(degrees) {
function degreesToRadians(degrees) {
if (degrees === null || degrees === undefined) throw new Error('degrees is required');

@@ -520,16 +523,15 @@

/**
* Converts a distance to the requested unit.
* Converts a length to the requested unit.
* Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet
*
* @param {number} distance to be converted
* @param {string} originalUnit of the distance
* @param {number} length to be converted
* @param {string} originalUnit of the length
* @param {string} [finalUnit='kilometers'] returned unit
* @returns {number} the converted distance
* @returns {number} the converted length
*/
function convertDistance(distance, originalUnit, finalUnit) {
if (distance === null || distance === undefined) throw new Error('distance is required');
if (!(distance >= 0)) throw new Error('distance must be a positive number');
function convertLength(length, originalUnit, finalUnit) {
if (length === null || length === undefined) throw new Error('length is required');
if (!(length >= 0)) throw new Error('length must be a positive number');
var convertedDistance = radiansToDistance(distanceToRadians(distance, originalUnit), finalUnit || 'kilometers');
return convertedDistance;
return radiansToLength(lengthToRadians(length, originalUnit), finalUnit || 'kilometers');
}

@@ -588,2 +590,31 @@

// Deprecated methods
function radians2degrees() {
throw new Error('method has been renamed to `radiansToDegrees`');
}
function degrees2radians() {
throw new Error('method has been renamed to `degreesToRadians`');
}
function distanceToDegrees() {
throw new Error('method has been renamed to `lengthToDegrees`');
}
function distanceToRadians() {
throw new Error('method has been renamed to `lengthToRadians`');
}
function radiansToDistance() {
throw new Error('method has been renamed to `radiansToLength`');
}
function bearingToAngle() {
throw new Error('method has been renamed to `bearingToAzimuth`');
}
function convertDistance() {
throw new Error('method has been renamed to `convertLength`');
}
exports.earthRadius = earthRadius;

@@ -604,11 +635,18 @@ exports.factors = factors;

exports.round = round;
exports.radiansToLength = radiansToLength;
exports.lengthToRadians = lengthToRadians;
exports.lengthToDegrees = lengthToDegrees;
exports.bearingToAzimuth = bearingToAzimuth;
exports.radiansToDegrees = radiansToDegrees;
exports.degreesToRadians = degreesToRadians;
exports.convertLength = convertLength;
exports.convertArea = convertArea;
exports.isNumber = isNumber;
exports.isObject = isObject;
exports.radians2degrees = radians2degrees;
exports.degrees2radians = degrees2radians;
exports.distanceToDegrees = distanceToDegrees;
exports.distanceToRadians = distanceToRadians;
exports.radiansToDistance = radiansToDistance;
exports.distanceToRadians = distanceToRadians;
exports.distanceToDegrees = distanceToDegrees;
exports.bearingToAngle = bearingToAngle;
exports.radians2degrees = radians2degrees;
exports.degrees2radians = degrees2radians;
exports.convertDistance = convertDistance;
exports.convertArea = convertArea;
exports.isNumber = isNumber;
exports.isObject = isObject;
{
"name": "@turf/helpers",
"version": "5.0.1",
"version": "5.0.4",
"description": "turf helpers module",

@@ -42,8 +42,7 @@ "main": "main",

"devDependencies": {
"@std/esm": "*",
"benchmark": "*",
"rollup": "*",
"tape": "*",
"@std/esm": "*"
"tape": "*"
},
"dependencies": {},
"@std/esm": {

@@ -50,0 +49,0 @@ "esm": "js",

@@ -308,3 +308,3 @@ # @turf/helpers

## radiansToDistance
## radiansToLength

@@ -321,3 +321,3 @@ Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit.

## distanceToRadians
## lengthToRadians

@@ -334,3 +334,3 @@ Convert a distance measurement (assuming a spherical Earth) from a real-world unit into radians

## distanceToDegrees
## lengthToDegrees

@@ -347,3 +347,3 @@ Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees

## bearingToAngle
## bearingToAzimuth

@@ -359,3 +359,3 @@ Converts any bearing angle from the north line direction (positive clockwise)

## radians2degrees
## radiansToDegrees

@@ -370,3 +370,3 @@ Converts an angle in radians to degrees

## degrees2radians
## degreesToradians

@@ -381,5 +381,5 @@ Converts an angle in degrees to radians

## convertDistance
## convertLength
Converts a distance to the requested unit.
Converts a length to the requested unit.
Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet

@@ -389,7 +389,7 @@

- `distance` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** to be converted
- `originalUnit` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** of the distance
- `length` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** to be converted
- `originalUnit` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** of the length
- `finalUnit` **[string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String)** returned unit (optional, default `'kilometers'`)
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the converted distance
Returns **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** the converted length

@@ -396,0 +396,0 @@ ## convertArea

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