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

turf-convex

Package Overview
Dependencies
Maintainers
2
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-convex - npm Package Compare versions

Comparing version 0.1.1 to 1.0.0

bench.js

32

index.js

@@ -5,29 +5,29 @@ // http://en.wikibooks.org/wiki/Algorithm_Implementation/Geometry/Convex_hull/Monotone_chain#JavaScript

var points = fc.features.map(function(point){
return point.geometry.coordinates
})
return point.geometry.coordinates;
});
points.sort(function(a, b) {
return a[0] == b[0] ? a[1] - b[1] : a[0] - b[0]
})
return a[0] == b[0] ? a[1] - b[1] : a[0] - b[0];
});
var lower = []
var lower = [];
for (var i = 0; i < points.length; i++) {
while (lower.length >= 2 && cross(lower[lower.length - 2], lower[lower.length - 1], points[i]) <= 0) {
lower.pop()
lower.pop();
}
lower.push(points[i])
lower.push(points[i]);
}
var upper = []
var upper = [];
for (var i = points.length - 1; i >= 0; i--) {
while (upper.length >= 2 && cross(upper[upper.length - 2], upper[upper.length - 1], points[i]) <= 0) {
upper.pop()
upper.pop();
}
upper.push(points[i])
upper.push(points[i]);
}
upper.pop()
lower.pop()
var coords = lower.concat(upper)
coords.push(coords[0])
upper.pop();
lower.pop();
var coords = lower.concat(upper);
coords.push(coords[0]);
return {

@@ -42,7 +42,7 @@ type:'Feature',

}
}
};
}
function cross(o, a, b) {
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0])
return (a[0] - o[0]) * (b[1] - o[1]) - (a[1] - o[1]) * (b[0] - o[0]);
}
{
"name": "turf-convex",
"version": "0.1.1",
"version": "1.0.0",
"description": "",

@@ -27,6 +27,7 @@ "main": "index.js",

"devDependencies": {
"glob": "~4.0.3",
"tape": "~2.13.3"
"benchmark": "^1.0.0",
"glob": "~4.3.1",
"tape": "~3.0.3"
},
"dependencies": {}
}
var convex = require('../'),
test = require('tape'),
glob = require('glob'),
fs = require('fs')
fs = require('fs');

@@ -6,0 +6,0 @@ var REGEN = true;

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