New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

geojsonjs

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

geojsonjs - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

2

package.json
{
"name": "geojsonjs",
"version": "0.1.1",
"version": "0.1.2",
"description": "Build and validate GeoJSON",

@@ -5,0 +5,0 @@ "main": "./src/index.js",

@@ -17,2 +17,20 @@ "use strict";

}
function validatePointsCount(coordinates, count, validateClosing = false) {
if (!Array.isArray(coordinates))
return false;
const everyItemIsPoint = coordinates.every((item) => {
if (!Array.isArray(item))
return false;
return item.every((c) => (0, lodash_1.isNumber)(c));
});
if (everyItemIsPoint) {
const start = coordinates === null || coordinates === void 0 ? void 0 : coordinates[0];
const end = coordinates === null || coordinates === void 0 ? void 0 : coordinates[coordinates.length - 1];
if (validateClosing && !(0, lodash_1.isEqual)(start, end)) {
return false;
}
return coordinates.length >= count;
}
return coordinates.every((c) => validatePointsCount(c, count, validateClosing));
}
function validate(geom) {

@@ -80,3 +98,3 @@ const featureCollection = (0, functions_1.getFeatureCollection)(geom);

else if (type === types_1.GeometryType.LINE_STRING) {
if ((coordinates === null || coordinates === void 0 ? void 0 : coordinates.length) < 2) {
if (!validatePointsCount(coordinates, 2)) {
return transformResponse(types_1.ValidationError.INVALID_COORDINATES, {

@@ -89,3 +107,3 @@ coordinates,

else if (type === types_1.GeometryType.POLYGON) {
if ((coordinates === null || coordinates === void 0 ? void 0 : coordinates.length) < 3) {
if (!validatePointsCount(coordinates, 3, true)) {
return transformResponse(types_1.ValidationError.INVALID_COORDINATES, {

@@ -95,9 +113,2 @@ coordinates,

}
const start = coordinates[0];
const end = coordinates[coordinates.length - 1];
if (!(0, lodash_1.isEqual)(start, end)) {
return transformResponse(types_1.ValidationError.INVALID_COORDINATES, {
coordinates,
});
}
return validateCoordinatesByDepth(coordinates, 2);

@@ -104,0 +115,0 @@ }

Sorry, the diff of this file is not supported yet

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