Socket
Socket
Sign inDemoInstall

@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 4.4.0 to 4.5.1

5

index.d.ts

@@ -118,1 +118,6 @@ /// <reference types="geojson" />

export function convertDistance(distance: number, originalUnit: Units, finalUnit?: Units): number
/**
* http://turfjs.org/docs/#convertarea
*/
export function convertArea(area: number, originalUnit?: Units, finalUnit?: Units): number

36

index.js

@@ -45,3 +45,3 @@ /**

if (coordinates.length < 2) throw new Error('Coordinates must be at least 2 numbers long');
if (typeof coordinates[0] !== 'number' || typeof coordinates[1] !== 'number') throw new Error('Coordinates must numbers');
if (typeof coordinates[0] !== 'number' || typeof coordinates[1] !== 'number') throw new Error('Coordinates must contain numbers');

@@ -276,2 +276,15 @@ return feature({

var areaFactors = {
kilometers: 0.000001,
kilometres: 0.000001,
meters: 1,
metres: 1,
centimetres: 10000,
millimeter: 1000000,
acres: 0.000247105,
miles: 3.86e-7,
yards: 1.195990046,
feet: 10.763910417,
inches: 1550.003100006
};
/**

@@ -406,3 +419,23 @@ * Round number to precision

/**
* Converts a area to the requested unit.
* Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, acre, mile, yard, foot, inch
* @param {number} area to be converted
* @param {string} [originalUnit=meters] of the distance
* @param {string} [finalUnit=kilometers] returned unit
* @returns {number} the converted distance
*/
function convertArea(area, originalUnit, finalUnit) {
if (area === null || area === undefined) throw new Error('area is required');
if (!(area >= 0)) throw new Error('area must be a positive number');
var startFactor = areaFactors[originalUnit || 'meters'];
if (!startFactor) throw new Error('invalid original units');
var finalFactor = areaFactors[finalUnit || 'kilometers'];
if (!finalFactor) throw new Error('invalid final units');
return (area / startFactor) * finalFactor;
}
module.exports = {

@@ -425,3 +458,4 @@ feature: feature,

convertDistance: convertDistance,
convertArea: convertArea,
round: round
};

5

package.json
{
"name": "@turf/helpers",
"version": "4.4.0",
"version": "4.5.1",
"description": "turf helpers module",

@@ -29,3 +29,4 @@ "main": "index.js",

"Stefano Borghi <@stebogit>",
"Denis Carriere <@DenisCarriere>"
"Denis Carriere <@DenisCarriere>",
"William Nordmann <@wnordmann>"
],

@@ -32,0 +33,0 @@ "license": "MIT",

@@ -329,2 +329,15 @@ # @turf/helpers

# convertArea
Converts a area to the requested unit.
Valid units: kilometers, kilometres, meters, metres, centimetres, millimeter, acre, mile, yard, foot, inch
**Parameters**
- `area` **[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 (optional, default `meters`)
- `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
<!-- This file is automatically generated. Please don't edit it directly:

@@ -331,0 +344,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