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

d3-polygon

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-polygon - npm Package Compare versions

Comparing version 0.2.1 to 0.3.0

8

build/d3-polygon.js

@@ -0,5 +1,6 @@

// https://d3js.org/d3-polygon/ Version 0.3.0. Copyright 2016 Mike Bostock.
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(factory((global.d3_polygon = {})));
(factory((global.d3 = global.d3 || {})));
}(this, function (exports) { 'use strict';

@@ -141,5 +142,2 @@

var version = "0.2.1";
exports.version = version;
exports.polygonArea = area;

@@ -151,2 +149,4 @@ exports.polygonCentroid = centroid;

Object.defineProperty(exports, '__esModule', { value: true });
}));

@@ -1,1 +0,2 @@

!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.d3_polygon={})}(this,function(n){"use strict";function r(n){for(var r,t=-1,o=n.length,e=n[o-1],f=0;++t<o;)r=e,e=n[t],f+=r[1]*e[0]-r[0]*e[1];return f/2}function t(n){for(var r,t,o=-1,e=n.length,f=0,u=0,i=n[e-1],l=0;++o<e;)r=i,i=n[o],l+=t=r[0]*i[1]-i[0]*r[1],f+=(r[0]+i[0])*t,u+=(r[1]+i[1])*t;return l*=3,[f/l,u/l]}function o(n,r,t){return(r[0]-n[0])*(t[1]-n[1])-(r[1]-n[1])*(t[0]-n[0])}function e(n,r){return n[0]-r[0]||n[1]-r[1]}function f(n){for(var r=n.length,t=[0,1],e=2,f=2;r>f;++f){for(;e>1&&o(n[t[e-2]],n[t[e-1]],n[f])<=0;)--e;t[e++]=f}return t.slice(0,e)}function u(n){if((t=n.length)<3)return null;var r,t,o=new Array(t),u=new Array(t);for(r=0;t>r;++r)o[r]=[+n[r][0],+n[r][1],r];for(o.sort(e),r=0;t>r;++r)u[r]=[o[r][0],-o[r][1]];var i=f(o),l=f(u),g=l[0]===i[0],h=l[l.length-1]===i[i.length-1],a=[];for(r=i.length-1;r>=0;--r)a.push(n[o[i[r]][2]]);for(r=+g;r<l.length-h;++r)a.push(n[o[l[r]][2]]);return a}function i(n,r){for(var t,o,e=n.length,f=n[e-1],u=r[0],i=r[1],l=f[0],g=f[1],h=!1,a=0;e>a;++a)f=n[a],t=f[0],o=f[1],o>i!=g>i&&(l-t)*(i-o)/(g-o)+t>u&&(h=!h),l=t,g=o;return h}function l(n){for(var r,t,o=-1,e=n.length,f=n[e-1],u=f[0],i=f[1],l=0;++o<e;)r=u,t=i,f=n[o],u=f[0],i=f[1],r-=u,t-=i,l+=Math.sqrt(r*r+t*t);return l}var g="0.2.1";n.version=g,n.polygonArea=r,n.polygonCentroid=t,n.polygonHull=u,n.polygonContains=i,n.polygonLength=l});
// https://d3js.org/d3-polygon/ Version 0.3.0. Copyright 2016 Mike Bostock.
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(n.d3=n.d3||{})}(this,function(n){"use strict";function e(n){for(var e,r=-1,t=n.length,o=n[t-1],f=0;++r<t;)e=o,o=n[r],f+=e[1]*o[0]-e[0]*o[1];return f/2}function r(n){for(var e,r,t=-1,o=n.length,f=0,u=0,l=n[o-1],i=0;++t<o;)e=l,l=n[t],i+=r=e[0]*l[1]-l[0]*e[1],f+=(e[0]+l[0])*r,u+=(e[1]+l[1])*r;return i*=3,[f/i,u/i]}function t(n,e,r){return(e[0]-n[0])*(r[1]-n[1])-(e[1]-n[1])*(r[0]-n[0])}function o(n,e){return n[0]-e[0]||n[1]-e[1]}function f(n){for(var e=n.length,r=[0,1],o=2,f=2;e>f;++f){for(;o>1&&t(n[r[o-2]],n[r[o-1]],n[f])<=0;)--o;r[o++]=f}return r.slice(0,o)}function u(n){if((r=n.length)<3)return null;var e,r,t=new Array(r),u=new Array(r);for(e=0;r>e;++e)t[e]=[+n[e][0],+n[e][1],e];for(t.sort(o),e=0;r>e;++e)u[e]=[t[e][0],-t[e][1]];var l=f(t),i=f(u),g=i[0]===l[0],c=i[i.length-1]===l[l.length-1],h=[];for(e=l.length-1;e>=0;--e)h.push(n[t[l[e]][2]]);for(e=+g;e<i.length-c;++e)h.push(n[t[i[e]][2]]);return h}function l(n,e){for(var r,t,o=n.length,f=n[o-1],u=e[0],l=e[1],i=f[0],g=f[1],c=!1,h=0;o>h;++h)f=n[h],r=f[0],t=f[1],t>l!=g>l&&(i-r)*(l-t)/(g-t)+r>u&&(c=!c),i=r,g=t;return c}function i(n){for(var e,r,t=-1,o=n.length,f=n[o-1],u=f[0],l=f[1],i=0;++t<o;)e=u,r=l,f=n[t],u=f[0],l=f[1],e-=u,r-=l,i+=Math.sqrt(e*e+r*r);return i}n.polygonArea=e,n.polygonCentroid=r,n.polygonHull=u,n.polygonContains=l,n.polygonLength=i,Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "d3-polygon",
"version": "0.2.1",
"version": "0.3.0",
"description": "Operations for two-dimensional polygons.",

@@ -12,3 +12,3 @@ "keywords": [

],
"homepage": "https://github.com/d3/d3-polygon",
"homepage": "https://d3js.org/d3-polygon/",
"license": "BSD-3-Clause",

@@ -26,10 +26,11 @@ "author": {

"scripts": {
"pretest": "mkdir -p build && node -e 'process.stdout.write(\"var version = \\\"\" + require(\"./package.json\").version + \"\\\"; export * from \\\"../index\\\"; export {version};\");' > build/bundle.js && rollup -f umd -n d3_polygon -o build/d3-polygon.js -- build/bundle.js",
"test": "faucet `find test -name '*-test.js'` && eslint index.js src",
"prepublish": "npm run test && uglifyjs build/d3-polygon.js -c -m -o build/d3-polygon.min.js && rm -f build/d3-polygon.zip && zip -j build/d3-polygon.zip -- LICENSE README.md build/d3-polygon.js build/d3-polygon.min.js",
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git tag -am \"Release $VERSION.\" v${VERSION} && git push --tags && cp build/d3-polygon.js ../d3.github.com/d3-polygon.v0.2.js && cp build/d3-polygon.min.js ../d3.github.com/d3-polygon.v0.2.min.js && cd ../d3.github.com && git add d3-polygon.v0.2.js d3-polygon.v0.2.min.js && git commit -m \"d3-polygon ${VERSION}\" && git push"
"pretest": "rm -rf build && mkdir build && rollup --banner \"$(preamble)\" -f umd -n d3 -o build/d3-polygon.js -- index.js",
"test": "tape 'test/**/*-test.js' && eslint index.js src",
"prepublish": "npm run test && uglifyjs --preamble \"$(preamble)\" build/d3-polygon.js -c -m -o build/d3-polygon.min.js",
"postpublish": "VERSION=`node -e 'console.log(require(\"./package.json\").version)'`; git push && git push --tags && cp build/d3-polygon.js ../d3.github.com/d3-polygon.v0.3.js && cp build/d3-polygon.min.js ../d3.github.com/d3-polygon.v0.3.min.js && cd ../d3.github.com && git add d3-polygon.v0.3.js d3-polygon.v0.3.min.js && git commit -m \"d3-polygon ${VERSION}\" && git push && cd - && zip -j build/d3-polygon.zip -- LICENSE README.md build/d3-polygon.js build/d3-polygon.min.js"
},
"devDependencies": {
"faucet": "0.0",
"rollup": "0.25",
"eslint": "2",
"package-preamble": "0.0",
"rollup": "0.27",
"tape": "4",

@@ -36,0 +37,0 @@ "uglify-js": "2"

@@ -7,9 +7,14 @@ # d3-polygon

If you use NPM, `npm install d3-polygon`. Otherwise, download the [latest release](https://github.com/d3/d3-polygon/releases/latest). The released bundle supports AMD, CommonJS, and vanilla environments. Create a custom build using [Rollup](https://github.com/rollup/rollup) or your preferred bundler. You can also load directly from [d3js.org](https://d3js.org):
If you use NPM, `npm install d3-polygon`. Otherwise, download the [latest release](https://github.com/d3/d3-polygon/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-polygon.v0.3.min.js) or as part of [D3 4.0](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
```html
<script src="https://d3js.org/d3-polygon.v0.2.min.js"></script>
<script src="https://d3js.org/d3-polygon.v0.3.min.js"></script>
<script>
var hull = d3.polygonHull(points);
</script>
```
In a vanilla environment, a `d3_polygon` global is exported. [Try d3-polygon in your browser.](https://tonicdev.com/npm/d3-polygon)
[Try d3-polygon in your browser.](https://tonicdev.com/npm/d3-polygon)

@@ -16,0 +21,0 @@ ## API Reference

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