Socket
Socket
Sign inDemoInstall

d3-quadtree

Package Overview
Dependencies
Maintainers
1
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.5 to 1.0.6

40

dist/d3-quadtree.js

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

// https://d3js.org/d3-quadtree/ v1.0.5 Copyright 2018 Mike Bostock
// https://d3js.org/d3-quadtree/ v1.0.6 Copyright 2019 Mike Bostock
(function (global, factory) {

@@ -79,5 +79,4 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

// If there were no (valid) points, inherit the existing extent.
if (x1 < x0) x0 = this._x0, x1 = this._x1;
if (y1 < y0) y0 = this._y0, y1 = this._y1;
// If there were no (valid) points, abort.
if (x0 > x1 || y0 > y1) return this;

@@ -112,3 +111,3 @@ // Expand the tree to cover the new points.

// Otherwise, double repeatedly to cover.
else if (x0 > x || x > x1 || y0 > y || y > y1) {
else {
var z = x1 - x0,

@@ -119,23 +118,11 @@ node = this._root,

switch (i = (y < (y0 + y1) / 2) << 1 | (x < (x0 + x1) / 2)) {
case 0: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x1 = x0 + z, y1 = y0 + z, x > x1 || y > y1);
break;
while (x0 > x || x >= x1 || y0 > y || y >= y1) {
i = (y < y0) << 1 | (x < x0);
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
switch (i) {
case 0: x1 = x0 + z, y1 = y0 + z; break;
case 1: x0 = x1 - z, y1 = y0 + z; break;
case 2: x1 = x0 + z, y0 = y1 - z; break;
case 3: x0 = x1 - z, y0 = y1 - z; break;
}
case 1: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x0 = x1 - z, y1 = y0 + z, x0 > x || y > y1);
break;
}
case 2: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x1 = x0 + z, y0 = y1 - z, x > x1 || y0 > y);
break;
}
case 3: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x0 = x1 - z, y0 = y1 - z, x0 > x || y0 > y);
break;
}
}

@@ -146,5 +133,2 @@

// If the quadtree covers the point already, just return.
else return this;
this._x0 = x0;

@@ -151,0 +135,0 @@ this._y0 = y0;

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

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

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

@@ -72,5 +72,4 @@ export default function(d) {

// If there were no (valid) points, inherit the existing extent.
if (x1 < x0) x0 = this._x0, x1 = this._x1;
if (y1 < y0) y0 = this._y0, y1 = this._y1;
// If there were no (valid) points, abort.
if (x0 > x1 || y0 > y1) return this;

@@ -77,0 +76,0 @@ // Expand the tree to cover the new points.

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

// Otherwise, double repeatedly to cover.
else if (x0 > x || x > x1 || y0 > y || y > y1) {
else {
var z = x1 - x0,

@@ -25,23 +25,11 @@ node = this._root,

switch (i = (y < (y0 + y1) / 2) << 1 | (x < (x0 + x1) / 2)) {
case 0: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x1 = x0 + z, y1 = y0 + z, x > x1 || y > y1);
break;
while (x0 > x || x >= x1 || y0 > y || y >= y1) {
i = (y < y0) << 1 | (x < x0);
parent = new Array(4), parent[i] = node, node = parent, z *= 2;
switch (i) {
case 0: x1 = x0 + z, y1 = y0 + z; break;
case 1: x0 = x1 - z, y1 = y0 + z; break;
case 2: x1 = x0 + z, y0 = y1 - z; break;
case 3: x0 = x1 - z, y0 = y1 - z; break;
}
case 1: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x0 = x1 - z, y1 = y0 + z, x0 > x || y > y1);
break;
}
case 2: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x1 = x0 + z, y0 = y1 - z, x > x1 || y0 > y);
break;
}
case 3: {
do parent = new Array(4), parent[i] = node, node = parent;
while (z *= 2, x0 = x1 - z, y0 = y1 - z, x0 > x || y0 > y);
break;
}
}

@@ -52,5 +40,2 @@

// If the quadtree covers the point already, just return.
else return this;
this._x0 = x0;

@@ -57,0 +42,0 @@ this._y0 = y0;

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