@turf/helpers
Advanced tools
Comparing version 5.1.5 to 6.0.0-beta.1
120
index.js
@@ -0,5 +1,9 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { value: true }); | ||
/** | ||
* Earth Radius used with the Harvesine formula and approximates using a spherical (non-ellipsoid) Earth. | ||
*/ | ||
export var earthRadius = 6371008.8; | ||
var earthRadius = 6371008.8; | ||
@@ -9,3 +13,3 @@ /** | ||
*/ | ||
export var factors = { | ||
var factors = { | ||
meters: earthRadius, | ||
@@ -31,3 +35,3 @@ metres: earthRadius, | ||
*/ | ||
export var unitsFactors = { | ||
var unitsFactors = { | ||
meters: 1, | ||
@@ -53,3 +57,3 @@ metres: 1, | ||
*/ | ||
export var areaFactors = { | ||
var areaFactors = { | ||
meters: 1, | ||
@@ -90,3 +94,3 @@ metres: 1, | ||
*/ | ||
export function feature(geometry, properties, options) { | ||
function feature(geometry, properties, options) { | ||
// Optional Parameters | ||
@@ -102,7 +106,7 @@ options = options || {}; | ||
if (bbox) validateBBox(bbox); | ||
if (id) validateId(id); | ||
if (id !== 0 && id) validateId(id); | ||
// Main | ||
var feat = {type: 'Feature'}; | ||
if (id) feat.id = id; | ||
if (id === 0 || id) feat.id = id; | ||
if (bbox) feat.bbox = bbox; | ||
@@ -132,3 +136,3 @@ feat.properties = properties || {}; | ||
*/ | ||
export function geometry(type, coordinates, options) { | ||
function geometry(type, coordinates, options) { | ||
// Optional Parameters | ||
@@ -175,3 +179,3 @@ options = options || {}; | ||
*/ | ||
export function point(coordinates, properties, options) { | ||
function point(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -207,3 +211,3 @@ if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array'); | ||
*/ | ||
export function points(coordinates, properties, options) { | ||
function points(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -232,3 +236,3 @@ if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array'); | ||
*/ | ||
export function polygon(coordinates, properties, options) { | ||
function polygon(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -274,3 +278,3 @@ | ||
*/ | ||
export function polygons(coordinates, properties, options) { | ||
function polygons(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -301,3 +305,3 @@ if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array'); | ||
*/ | ||
export function lineString(coordinates, properties, options) { | ||
function lineString(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -332,3 +336,3 @@ if (coordinates.length < 2) throw new Error('coordinates must be an array of two or more positions'); | ||
*/ | ||
export function lineStrings(coordinates, properties, options) { | ||
function lineStrings(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -364,3 +368,3 @@ if (!Array.isArray(coordinates)) throw new Error('coordinates must be an Array'); | ||
*/ | ||
export function featureCollection(features, options) { | ||
function featureCollection(features, options) { | ||
// Optional Parameters | ||
@@ -403,3 +407,3 @@ options = options || {}; | ||
*/ | ||
export function multiLineString(coordinates, properties, options) { | ||
function multiLineString(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -430,3 +434,3 @@ | ||
*/ | ||
export function multiPoint(coordinates, properties, options) { | ||
function multiPoint(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -458,3 +462,3 @@ | ||
*/ | ||
export function multiPolygon(coordinates, properties, options) { | ||
function multiPolygon(coordinates, properties, options) { | ||
if (!coordinates) throw new Error('coordinates is required'); | ||
@@ -492,3 +496,3 @@ | ||
*/ | ||
export function geometryCollection(geometries, properties, options) { | ||
function geometryCollection(geometries, properties, options) { | ||
if (!geometries) throw new Error('geometries is required'); | ||
@@ -516,3 +520,3 @@ if (!Array.isArray(geometries)) throw new Error('geometries must be an Array'); | ||
*/ | ||
export function round(num, precision) { | ||
function round(num, precision) { | ||
if (num === undefined || num === null || isNaN(num)) throw new Error('num is required'); | ||
@@ -533,3 +537,3 @@ if (precision && !(precision >= 0)) throw new Error('precision must be a positive number'); | ||
*/ | ||
export function radiansToLength(radians, units) { | ||
function radiansToLength(radians, units) { | ||
if (radians === undefined || radians === null) throw new Error('radians is required'); | ||
@@ -552,3 +556,3 @@ | ||
*/ | ||
export function lengthToRadians(distance, units) { | ||
function lengthToRadians(distance, units) { | ||
if (distance === undefined || distance === null) throw new Error('distance is required'); | ||
@@ -571,3 +575,3 @@ | ||
*/ | ||
export function lengthToDegrees(distance, units) { | ||
function lengthToDegrees(distance, units) { | ||
return radiansToDegrees(lengthToRadians(distance, units)); | ||
@@ -584,3 +588,3 @@ } | ||
*/ | ||
export function bearingToAzimuth(bearing) { | ||
function bearingToAzimuth(bearing) { | ||
if (bearing === null || bearing === undefined) throw new Error('bearing is required'); | ||
@@ -600,3 +604,3 @@ | ||
*/ | ||
export function radiansToDegrees(radians) { | ||
function radiansToDegrees(radians) { | ||
if (radians === null || radians === undefined) throw new Error('radians is required'); | ||
@@ -615,3 +619,3 @@ | ||
*/ | ||
export function degreesToRadians(degrees) { | ||
function degreesToRadians(degrees) { | ||
if (degrees === null || degrees === undefined) throw new Error('degrees is required'); | ||
@@ -632,3 +636,3 @@ | ||
*/ | ||
export function convertLength(length, originalUnit, finalUnit) { | ||
function convertLength(length, originalUnit, finalUnit) { | ||
if (length === null || length === undefined) throw new Error('length is required'); | ||
@@ -648,3 +652,3 @@ if (!(length >= 0)) throw new Error('length must be a positive number'); | ||
*/ | ||
export function convertArea(area, originalUnit, finalUnit) { | ||
function convertArea(area, originalUnit, finalUnit) { | ||
if (area === null || area === undefined) throw new Error('area is required'); | ||
@@ -673,3 +677,3 @@ if (!(area >= 0)) throw new Error('area must be a positive number'); | ||
*/ | ||
export function isNumber(num) { | ||
function isNumber(num) { | ||
return !isNaN(num) && num !== null && !Array.isArray(num); | ||
@@ -689,3 +693,3 @@ } | ||
*/ | ||
export function isObject(input) { | ||
function isObject(input) { | ||
return (!!input) && (input.constructor === Object); | ||
@@ -715,3 +719,3 @@ } | ||
*/ | ||
export function validateBBox(bbox) { | ||
function validateBBox(bbox) { | ||
if (!bbox) throw new Error('bbox is required'); | ||
@@ -746,3 +750,3 @@ if (!Array.isArray(bbox)) throw new Error('bbox must be an Array'); | ||
*/ | ||
export function validateId(id) { | ||
function validateId(id) { | ||
if (!id) throw new Error('id is required'); | ||
@@ -753,28 +757,66 @@ if (['string', 'number'].indexOf(typeof id) === -1) throw new Error('id must be a number or a string'); | ||
// Deprecated methods | ||
export function radians2degrees() { | ||
function radians2degrees() { | ||
throw new Error('method has been renamed to `radiansToDegrees`'); | ||
} | ||
export function degrees2radians() { | ||
function degrees2radians() { | ||
throw new Error('method has been renamed to `degreesToRadians`'); | ||
} | ||
export function distanceToDegrees() { | ||
function distanceToDegrees() { | ||
throw new Error('method has been renamed to `lengthToDegrees`'); | ||
} | ||
export function distanceToRadians() { | ||
function distanceToRadians() { | ||
throw new Error('method has been renamed to `lengthToRadians`'); | ||
} | ||
export function radiansToDistance() { | ||
function radiansToDistance() { | ||
throw new Error('method has been renamed to `radiansToLength`'); | ||
} | ||
export function bearingToAngle() { | ||
function bearingToAngle() { | ||
throw new Error('method has been renamed to `bearingToAzimuth`'); | ||
} | ||
export function convertDistance() { | ||
function convertDistance() { | ||
throw new Error('method has been renamed to `convertLength`'); | ||
} | ||
exports.earthRadius = earthRadius; | ||
exports.factors = factors; | ||
exports.unitsFactors = unitsFactors; | ||
exports.areaFactors = areaFactors; | ||
exports.feature = feature; | ||
exports.geometry = geometry; | ||
exports.point = point; | ||
exports.points = points; | ||
exports.polygon = polygon; | ||
exports.polygons = polygons; | ||
exports.lineString = lineString; | ||
exports.lineStrings = lineStrings; | ||
exports.featureCollection = featureCollection; | ||
exports.multiLineString = multiLineString; | ||
exports.multiPoint = multiPoint; | ||
exports.multiPolygon = multiPolygon; | ||
exports.geometryCollection = geometryCollection; | ||
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.validateBBox = validateBBox; | ||
exports.validateId = validateId; | ||
exports.radians2degrees = radians2degrees; | ||
exports.degrees2radians = degrees2radians; | ||
exports.distanceToDegrees = distanceToDegrees; | ||
exports.distanceToRadians = distanceToRadians; | ||
exports.radiansToDistance = radiansToDistance; | ||
exports.bearingToAngle = bearingToAngle; | ||
exports.convertDistance = convertDistance; |
@@ -39,3 +39,3 @@ // Type definitions for geojson 7946.0 | ||
* Bounding box | ||
* | ||
* | ||
* https://tools.ietf.org/html/rfc7946#section-5 | ||
@@ -62,3 +62,3 @@ * A GeoJSON object MAY have a member named "bbox" to include information on the coordinate range for its Geometries, Features, or FeatureCollections. | ||
* Position | ||
* | ||
* | ||
* https://tools.ietf.org/html/rfc7946#section-3.1.1 | ||
@@ -197,4 +197,4 @@ * Array should contain between two and three elements. | ||
* https://tools.ietf.org/html/rfc7946#section-3.1.8 | ||
* | ||
* A GeoJSON object with type "GeometryCollection" is a Geometry object. | ||
* | ||
* A GeoJSON object with type "GeometryCollection" is a Geometry object. | ||
* A GeometryCollection has a member with the name "geometries". | ||
@@ -232,3 +232,3 @@ * The value of "geometries" is an array. Each element of this array is a GeoJSON Geometry object. | ||
* Feature Collection | ||
* | ||
* | ||
* https://tools.ietf.org/html/rfc7946#section-3.3 | ||
@@ -235,0 +235,0 @@ * A GeoJSON object with the type "FeatureCollection" is a FeatureCollection object. |
{ | ||
"name": "@turf/helpers", | ||
"version": "5.1.5", | ||
"version": "6.0.0-beta.1", | ||
"description": "turf helpers module", | ||
"main": "main.js", | ||
"module": "main.es.js", | ||
"main": "index.js", | ||
"module": "index.mjs", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.mjs", | ||
"index.d.ts", | ||
"main.js", | ||
"lib", | ||
"main.es.js" | ||
"lib" | ||
], | ||
"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", | ||
"pretest": "rollup -f cjs -i index.mjs -o index.js", | ||
"test": "node test.js", | ||
"posttest": "node ../../scripts/validate-es5-dependencies.js", | ||
"bench": "node bench.js", | ||
"docs": "node ../../scripts/generate-readmes" | ||
@@ -21,0 +20,0 @@ }, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
99718
7
1817
1
1