@turf/helpers
Advanced tools
Comparing version 3.10.5 to 3.13.0
66
index.js
@@ -22,2 +22,4 @@ /** | ||
function feature(geometry, properties) { | ||
if (!geometry) throw new Error('No geometry passed'); | ||
return { | ||
@@ -29,3 +31,2 @@ type: 'Feature', | ||
} | ||
module.exports.feature = feature; | ||
@@ -47,7 +48,10 @@ | ||
module.exports.point = function (coordinates, properties) { | ||
if (!Array.isArray(coordinates)) throw new Error('Coordinates must be an array'); | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
if (coordinates.length === undefined) throw new Error('Coordinates must be an array'); | ||
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'); | ||
return feature({ | ||
type: 'Point', | ||
coordinates: coordinates.slice() | ||
coordinates: coordinates | ||
}, properties); | ||
@@ -78,3 +82,2 @@ }; | ||
module.exports.polygon = function (coordinates, properties) { | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
@@ -111,12 +114,12 @@ | ||
* var linestring1 = turf.lineString([ | ||
* [-21.964416, 64.148203], | ||
* [-21.956176, 64.141316], | ||
* [-21.93901, 64.135924], | ||
* [-21.927337, 64.136673] | ||
* [-21.964416, 64.148203], | ||
* [-21.956176, 64.141316], | ||
* [-21.93901, 64.135924], | ||
* [-21.927337, 64.136673] | ||
* ]); | ||
* var linestring2 = turf.lineString([ | ||
* [-21.929054, 64.127985], | ||
* [-21.912918, 64.134726], | ||
* [-21.916007, 64.141016], | ||
* [-21.930084, 64.14446] | ||
* [-21.929054, 64.127985], | ||
* [-21.912918, 64.134726], | ||
* [-21.916007, 64.141016], | ||
* [-21.930084, 64.14446] | ||
* ], {name: 'line 1', distance: 145}); | ||
@@ -129,5 +132,4 @@ * | ||
module.exports.lineString = function (coordinates, properties) { | ||
if (!coordinates) { | ||
throw new Error('No coordinates passed'); | ||
} | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
return feature({ | ||
@@ -157,2 +159,4 @@ type: 'LineString', | ||
module.exports.featureCollection = function (features) { | ||
if (!features) throw new Error('No features passed'); | ||
return { | ||
@@ -180,5 +184,4 @@ type: 'FeatureCollection', | ||
module.exports.multiLineString = function (coordinates, properties) { | ||
if (!coordinates) { | ||
throw new Error('No coordinates passed'); | ||
} | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
return feature({ | ||
@@ -206,5 +209,4 @@ type: 'MultiLineString', | ||
module.exports.multiPoint = function (coordinates, properties) { | ||
if (!coordinates) { | ||
throw new Error('No coordinates passed'); | ||
} | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
return feature({ | ||
@@ -233,5 +235,4 @@ type: 'MultiPoint', | ||
module.exports.multiPolygon = function (coordinates, properties) { | ||
if (!coordinates) { | ||
throw new Error('No coordinates passed'); | ||
} | ||
if (!coordinates) throw new Error('No coordinates passed'); | ||
return feature({ | ||
@@ -265,2 +266,4 @@ type: 'MultiPolygon', | ||
module.exports.geometryCollection = function (geometries, properties) { | ||
if (!geometries) throw new Error('No geometries passed'); | ||
return feature({ | ||
@@ -297,5 +300,4 @@ type: 'GeometryCollection', | ||
var factor = factors[units || 'kilometers']; | ||
if (factor === undefined) { | ||
throw new Error('Invalid unit'); | ||
} | ||
if (factor === undefined) throw new Error('Invalid unit'); | ||
return radians * factor; | ||
@@ -315,5 +317,4 @@ }; | ||
var factor = factors[units || 'kilometers']; | ||
if (factor === undefined) { | ||
throw new Error('Invalid unit'); | ||
} | ||
if (factor === undefined) throw new Error('Invalid unit'); | ||
return distance / factor; | ||
@@ -333,6 +334,5 @@ }; | ||
var factor = factors[units || 'kilometers']; | ||
if (factor === undefined) { | ||
throw new Error('Invalid unit'); | ||
} | ||
if (factor === undefined) throw new Error('Invalid unit'); | ||
return (distance / factor) * 57.2958; | ||
}; |
{ | ||
"name": "@turf/helpers", | ||
"version": "3.10.5", | ||
"description": "turf geometries", | ||
"version": "3.13.0", | ||
"description": "turf helpers module", | ||
"main": "index.js", | ||
"types": "index.d.ts", | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"scripts": { | ||
"test": "node test.js" | ||
"test": "node test.js", | ||
"bench": "node bench.js" | ||
}, | ||
@@ -26,7 +32,6 @@ "repository": { | ||
"devDependencies": { | ||
"benchmark": "^1.0.0", | ||
"benchmark": "^2.1.3", | ||
"tape": "^3.5.0" | ||
}, | ||
"dependencies": {}, | ||
"types": "index.d.ts" | ||
"dependencies": {} | ||
} |
@@ -93,12 +93,12 @@ # @turf/helpers | ||
var linestring1 = turf.lineString([ | ||
[-21.964416, 64.148203], | ||
[-21.956176, 64.141316], | ||
[-21.93901, 64.135924], | ||
[-21.927337, 64.136673] | ||
[-21.964416, 64.148203], | ||
[-21.956176, 64.141316], | ||
[-21.93901, 64.135924], | ||
[-21.927337, 64.136673] | ||
]); | ||
var linestring2 = turf.lineString([ | ||
[-21.929054, 64.127985], | ||
[-21.912918, 64.134726], | ||
[-21.916007, 64.141016], | ||
[-21.930084, 64.14446] | ||
[-21.929054, 64.127985], | ||
[-21.912918, 64.134726], | ||
[-21.916007, 64.141016], | ||
[-21.930084, 64.14446] | ||
], {name: 'line 1', distance: 145}); | ||
@@ -105,0 +105,0 @@ |
Sorry, the diff of this file is not supported yet
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
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
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
0
25517
6
374