Socket
Socket
Sign inDemoInstall

d3-quadtree

Package Overview
Dependencies
Maintainers
2
Versions
28
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-quadtree - npm Package Compare versions

Comparing version 1.0.7 to 2.0.0-rc.1

6

dist/d3-quadtree.js

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

// https://d3js.org/d3-quadtree/ v1.0.7 Copyright 2019 Mike Bostock
// https://d3js.org/d3-quadtree/ v2.0.0-rc.1 Copyright 2020 Mike Bostock
(function (global, factory) {

@@ -9,3 +9,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

function tree_add(d) {
var x = +this._x.call(null, d),
const x = +this._x.call(null, d),
y = +this._y.call(null, d);

@@ -112,3 +112,3 @@ return add(this.cover(x, y), x, y, d);

else {
var z = x1 - x0,
var z = x1 - x0 || 1,
node = this._root,

@@ -115,0 +115,0 @@ parent,

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

// https://d3js.org/d3-quadtree/ v1.0.7 Copyright 2019 Mike Bostock
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";function i(t,i,r,e){if(isNaN(i)||isNaN(r))return t;var n,s,h,o,a,u,l,_,f,c=t._root,x={data:e},y=t._x0,d=t._y0,v=t._x1,p=t._y1;if(!c)return t._root=x,t;for(;c.length;)if((u=i>=(s=(y+v)/2))?y=s:v=s,(l=r>=(h=(d+p)/2))?d=h:p=h,n=c,!(c=c[_=l<<1|u]))return n[_]=x,t;if(o=+t._x.call(null,c.data),a=+t._y.call(null,c.data),i===o&&r===a)return x.next=c,n?n[_]=x:t._root=x,t;do{n=n?n[_]=new Array(4):t._root=new Array(4),(u=i>=(s=(y+v)/2))?y=s:v=s,(l=r>=(h=(d+p)/2))?d=h:p=h}while((_=l<<1|u)==(f=(a>=h)<<1|o>=s));return n[f]=c,n[_]=x,t}function r(t,i,r,e,n){this.node=t,this.x0=i,this.y0=r,this.x1=e,this.y1=n}function e(t){return t[0]}function n(t){return t[1]}function s(t,i,r){var s=new h(null==i?e:i,null==r?n:r,NaN,NaN,NaN,NaN);return null==t?s:s.addAll(t)}function h(t,i,r,e,n,s){this._x=t,this._y=i,this._x0=r,this._y0=e,this._x1=n,this._y1=s,this._root=void 0}function o(t){for(var i={data:t.data},r=i;t=t.next;)r=r.next={data:t.data};return i}var a=s.prototype=h.prototype;a.copy=function(){var t,i,r=new h(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root;if(!e)return r;if(!e.length)return r._root=o(e),r;for(t=[{source:e,target:r._root=new Array(4)}];e=t.pop();)for(var n=0;n<4;++n)(i=e.source[n])&&(i.length?t.push({source:i,target:e.target[n]=new Array(4)}):e.target[n]=o(i));return r},a.add=function(t){var r=+this._x.call(null,t),e=+this._y.call(null,t);return i(this.cover(r,e),r,e,t)},a.addAll=function(t){var r,e,n,s,h=t.length,o=new Array(h),a=new Array(h),u=1/0,l=1/0,_=-1/0,f=-1/0;for(e=0;e<h;++e)isNaN(n=+this._x.call(null,r=t[e]))||isNaN(s=+this._y.call(null,r))||(o[e]=n,a[e]=s,n<u&&(u=n),n>_&&(_=n),s<l&&(l=s),s>f&&(f=s));if(u>_||l>f)return this;for(this.cover(u,l).cover(_,f),e=0;e<h;++e)i(this,o[e],a[e],t[e]);return this},a.cover=function(t,i){if(isNaN(t=+t)||isNaN(i=+i))return this;var r=this._x0,e=this._y0,n=this._x1,s=this._y1;if(isNaN(r))n=(r=Math.floor(t))+1,s=(e=Math.floor(i))+1;else{for(var h,o,a=n-r,u=this._root;r>t||t>=n||e>i||i>=s;)switch(o=(i<e)<<1|t<r,(h=new Array(4))[o]=u,u=h,a*=2,o){case 0:n=r+a,s=e+a;break;case 1:r=n-a,s=e+a;break;case 2:n=r+a,e=s-a;break;case 3:r=n-a,e=s-a}this._root&&this._root.length&&(this._root=u)}return this._x0=r,this._y0=e,this._x1=n,this._y1=s,this},a.data=function(){var t=[];return this.visit(function(i){if(!i.length)do{t.push(i.data)}while(i=i.next)}),t},a.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},a.find=function(t,i,e){var n,s,h,o,a,u,l,_=this._x0,f=this._y0,c=this._x1,x=this._y1,y=[],d=this._root;for(d&&y.push(new r(d,_,f,c,x)),null==e?e=1/0:(_=t-e,f=i-e,c=t+e,x=i+e,e*=e);u=y.pop();)if(!(!(d=u.node)||(s=u.x0)>c||(h=u.y0)>x||(o=u.x1)<_||(a=u.y1)<f))if(d.length){var v=(s+o)/2,p=(h+a)/2;y.push(new r(d[3],v,p,o,a),new r(d[2],s,p,v,a),new r(d[1],v,h,o,p),new r(d[0],s,h,v,p)),(l=(i>=p)<<1|t>=v)&&(u=y[y.length-1],y[y.length-1]=y[y.length-1-l],y[y.length-1-l]=u)}else{var w=t-+this._x.call(null,d.data),N=i-+this._y.call(null,d.data),g=w*w+N*N;if(g<e){var A=Math.sqrt(e=g);_=t-A,f=i-A,c=t+A,x=i+A,n=d.data}}return n},a.remove=function(t){if(isNaN(s=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var i,r,e,n,s,h,o,a,u,l,_,f,c=this._root,x=this._x0,y=this._y0,d=this._x1,v=this._y1;if(!c)return this;if(c.length)for(;;){if((u=s>=(o=(x+d)/2))?x=o:d=o,(l=h>=(a=(y+v)/2))?y=a:v=a,i=c,!(c=c[_=l<<1|u]))return this;if(!c.length)break;(i[_+1&3]||i[_+2&3]||i[_+3&3])&&(r=i,f=_)}for(;c.data!==t;)if(e=c,!(c=c.next))return this;return(n=c.next)&&delete c.next,e?(n?e.next=n:delete e.next,this):i?(n?i[_]=n:delete i[_],(c=i[0]||i[1]||i[2]||i[3])&&c===(i[3]||i[2]||i[1]||i[0])&&!c.length&&(r?r[f]=c:this._root=c),this):(this._root=n,this)},a.removeAll=function(t){for(var i=0,r=t.length;i<r;++i)this.remove(t[i]);return this},a.root=function(){return this._root},a.size=function(){var t=0;return this.visit(function(i){if(!i.length)do{++t}while(i=i.next)}),t},a.visit=function(t){var i,e,n,s,h,o,a=[],u=this._root;for(u&&a.push(new r(u,this._x0,this._y0,this._x1,this._y1));i=a.pop();)if(!t(u=i.node,n=i.x0,s=i.y0,h=i.x1,o=i.y1)&&u.length){var l=(n+h)/2,_=(s+o)/2;(e=u[3])&&a.push(new r(e,l,_,h,o)),(e=u[2])&&a.push(new r(e,n,_,l,o)),(e=u[1])&&a.push(new r(e,l,s,h,_)),(e=u[0])&&a.push(new r(e,n,s,l,_))}return this},a.visitAfter=function(t){var i,e=[],n=[];for(this._root&&e.push(new r(this._root,this._x0,this._y0,this._x1,this._y1));i=e.pop();){var s=i.node;if(s.length){var h,o=i.x0,a=i.y0,u=i.x1,l=i.y1,_=(o+u)/2,f=(a+l)/2;(h=s[0])&&e.push(new r(h,o,a,_,f)),(h=s[1])&&e.push(new r(h,_,a,u,f)),(h=s[2])&&e.push(new r(h,o,f,_,l)),(h=s[3])&&e.push(new r(h,_,f,u,l))}n.push(i)}for(;i=n.pop();)t(i.node,i.x0,i.y0,i.x1,i.y1);return this},a.x=function(t){return arguments.length?(this._x=t,this):this._x},a.y=function(t){return arguments.length?(this._y=t,this):this._y},t.quadtree=s,Object.defineProperty(t,"__esModule",{value:!0})});
// https://d3js.org/d3-quadtree/ v2.0.0-rc.1 Copyright 2020 Mike Bostock
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t=t||self).d3=t.d3||{})}(this,function(t){"use strict";function i(t,i,n,e){if(isNaN(i)||isNaN(n))return t;var r,s,h,o,a,u,l,_,f,c=t._root,x={data:e},y=t._x0,d=t._y0,v=t._x1,p=t._y1;if(!c)return t._root=x,t;for(;c.length;)if((u=i>=(s=(y+v)/2))?y=s:v=s,(l=n>=(h=(d+p)/2))?d=h:p=h,r=c,!(c=c[_=l<<1|u]))return r[_]=x,t;if(o=+t._x.call(null,c.data),a=+t._y.call(null,c.data),i===o&&n===a)return x.next=c,r?r[_]=x:t._root=x,t;do{r=r?r[_]=new Array(4):t._root=new Array(4),(u=i>=(s=(y+v)/2))?y=s:v=s,(l=n>=(h=(d+p)/2))?d=h:p=h}while((_=l<<1|u)==(f=(a>=h)<<1|o>=s));return r[f]=c,r[_]=x,t}function n(t,i,n,e,r){this.node=t,this.x0=i,this.y0=n,this.x1=e,this.y1=r}function e(t){return t[0]}function r(t){return t[1]}function s(t,i,n){var s=new h(null==i?e:i,null==n?r:n,NaN,NaN,NaN,NaN);return null==t?s:s.addAll(t)}function h(t,i,n,e,r,s){this._x=t,this._y=i,this._x0=n,this._y0=e,this._x1=r,this._y1=s,this._root=void 0}function o(t){for(var i={data:t.data},n=i;t=t.next;)n=n.next={data:t.data};return i}var a=s.prototype=h.prototype;a.copy=function(){var t,i,n=new h(this._x,this._y,this._x0,this._y0,this._x1,this._y1),e=this._root;if(!e)return n;if(!e.length)return n._root=o(e),n;for(t=[{source:e,target:n._root=new Array(4)}];e=t.pop();)for(var r=0;r<4;++r)(i=e.source[r])&&(i.length?t.push({source:i,target:e.target[r]=new Array(4)}):e.target[r]=o(i));return n},a.add=function(t){const n=+this._x.call(null,t),e=+this._y.call(null,t);return i(this.cover(n,e),n,e,t)},a.addAll=function(t){var n,e,r,s,h=t.length,o=new Array(h),a=new Array(h),u=1/0,l=1/0,_=-1/0,f=-1/0;for(e=0;e<h;++e)isNaN(r=+this._x.call(null,n=t[e]))||isNaN(s=+this._y.call(null,n))||(o[e]=r,a[e]=s,r<u&&(u=r),r>_&&(_=r),s<l&&(l=s),s>f&&(f=s));if(u>_||l>f)return this;for(this.cover(u,l).cover(_,f),e=0;e<h;++e)i(this,o[e],a[e],t[e]);return this},a.cover=function(t,i){if(isNaN(t=+t)||isNaN(i=+i))return this;var n=this._x0,e=this._y0,r=this._x1,s=this._y1;if(isNaN(n))r=(n=Math.floor(t))+1,s=(e=Math.floor(i))+1;else{for(var h,o,a=r-n||1,u=this._root;n>t||t>=r||e>i||i>=s;)switch(o=(i<e)<<1|t<n,(h=new Array(4))[o]=u,u=h,a*=2,o){case 0:r=n+a,s=e+a;break;case 1:n=r-a,s=e+a;break;case 2:r=n+a,e=s-a;break;case 3:n=r-a,e=s-a}this._root&&this._root.length&&(this._root=u)}return this._x0=n,this._y0=e,this._x1=r,this._y1=s,this},a.data=function(){var t=[];return this.visit(function(i){if(!i.length)do{t.push(i.data)}while(i=i.next)}),t},a.extent=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},a.find=function(t,i,e){var r,s,h,o,a,u,l,_=this._x0,f=this._y0,c=this._x1,x=this._y1,y=[],d=this._root;for(d&&y.push(new n(d,_,f,c,x)),null==e?e=1/0:(_=t-e,f=i-e,c=t+e,x=i+e,e*=e);u=y.pop();)if(!(!(d=u.node)||(s=u.x0)>c||(h=u.y0)>x||(o=u.x1)<_||(a=u.y1)<f))if(d.length){var v=(s+o)/2,p=(h+a)/2;y.push(new n(d[3],v,p,o,a),new n(d[2],s,p,v,a),new n(d[1],v,h,o,p),new n(d[0],s,h,v,p)),(l=(i>=p)<<1|t>=v)&&(u=y[y.length-1],y[y.length-1]=y[y.length-1-l],y[y.length-1-l]=u)}else{var w=t-+this._x.call(null,d.data),N=i-+this._y.call(null,d.data),g=w*w+N*N;if(g<e){var A=Math.sqrt(e=g);_=t-A,f=i-A,c=t+A,x=i+A,r=d.data}}return r},a.remove=function(t){if(isNaN(s=+this._x.call(null,t))||isNaN(h=+this._y.call(null,t)))return this;var i,n,e,r,s,h,o,a,u,l,_,f,c=this._root,x=this._x0,y=this._y0,d=this._x1,v=this._y1;if(!c)return this;if(c.length)for(;;){if((u=s>=(o=(x+d)/2))?x=o:d=o,(l=h>=(a=(y+v)/2))?y=a:v=a,i=c,!(c=c[_=l<<1|u]))return this;if(!c.length)break;(i[_+1&3]||i[_+2&3]||i[_+3&3])&&(n=i,f=_)}for(;c.data!==t;)if(e=c,!(c=c.next))return this;return(r=c.next)&&delete c.next,e?(r?e.next=r:delete e.next,this):i?(r?i[_]=r:delete i[_],(c=i[0]||i[1]||i[2]||i[3])&&c===(i[3]||i[2]||i[1]||i[0])&&!c.length&&(n?n[f]=c:this._root=c),this):(this._root=r,this)},a.removeAll=function(t){for(var i=0,n=t.length;i<n;++i)this.remove(t[i]);return this},a.root=function(){return this._root},a.size=function(){var t=0;return this.visit(function(i){if(!i.length)do{++t}while(i=i.next)}),t},a.visit=function(t){var i,e,r,s,h,o,a=[],u=this._root;for(u&&a.push(new n(u,this._x0,this._y0,this._x1,this._y1));i=a.pop();)if(!t(u=i.node,r=i.x0,s=i.y0,h=i.x1,o=i.y1)&&u.length){var l=(r+h)/2,_=(s+o)/2;(e=u[3])&&a.push(new n(e,l,_,h,o)),(e=u[2])&&a.push(new n(e,r,_,l,o)),(e=u[1])&&a.push(new n(e,l,s,h,_)),(e=u[0])&&a.push(new n(e,r,s,l,_))}return this},a.visitAfter=function(t){var i,e=[],r=[];for(this._root&&e.push(new n(this._root,this._x0,this._y0,this._x1,this._y1));i=e.pop();){var s=i.node;if(s.length){var h,o=i.x0,a=i.y0,u=i.x1,l=i.y1,_=(o+u)/2,f=(a+l)/2;(h=s[0])&&e.push(new n(h,o,a,_,f)),(h=s[1])&&e.push(new n(h,_,a,u,f)),(h=s[2])&&e.push(new n(h,o,f,_,l)),(h=s[3])&&e.push(new n(h,_,f,u,l))}r.push(i)}for(;i=r.pop();)t(i.node,i.x0,i.y0,i.x1,i.y1);return this},a.x=function(t){return arguments.length?(this._x=t,this):this._x},a.y=function(t){return arguments.length?(this._y=t,this):this._y},t.quadtree=s,Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "d3-quadtree",
"version": "1.0.7",
"version": "2.0.0-rc.1",
"publishConfig": {
"tag": "next"
},
"description": "Two-dimensional recursive spatial subdivision.",

@@ -5,0 +8,0 @@ "keywords": [

@@ -10,3 +10,3 @@ # d3-quadtree

If you use NPM, `npm install d3-quadtree`. Otherwise, download the [latest release](https://github.com/d3/d3-quadtree/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-quadtree.v1.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:
If you use NPM, `npm install d3-quadtree`. Otherwise, download the [latest release](https://github.com/d3/d3-quadtree/releases/latest). You can also load directly from [d3js.org](https://d3js.org), either as a [standalone library](https://d3js.org/d3-quadtree.v2.min.js) or as part of [D3](https://github.com/d3/d3). AMD, CommonJS, and vanilla environments are supported. In vanilla, a `d3` global is exported:

@@ -13,0 +13,0 @@ ```html

export default function(d) {
var x = +this._x.call(null, d),
const x = +this._x.call(null, d),
y = +this._y.call(null, d);

@@ -4,0 +4,0 @@ return add(this.cover(x, y), x, y, d);

@@ -19,3 +19,3 @@ export default function(x, y) {

else {
var z = x1 - x0,
var z = x1 - x0 || 1,
node = this._root,

@@ -22,0 +22,0 @@ parent,

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