Comparing version 2.9.1 to 2.10.0
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-array/ v2.9.1 Copyright 2020 Mike Bostock | ||
// https://d3js.org/d3-array/ v2.10.0 Copyright 2021 Mike Bostock | ||
(function (global, factory) { | ||
@@ -269,2 +269,64 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : | ||
class InternMap extends Map { | ||
constructor(entries = [], key = keyof) { | ||
super(); | ||
Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}}); | ||
for (const [key, value] of entries) this.set(key, value); | ||
} | ||
get(key) { | ||
return super.get(intern_get(this, key)); | ||
} | ||
has(key) { | ||
return super.has(intern_get(this, key)); | ||
} | ||
set(key, value) { | ||
return super.set(intern_set(this, key), value); | ||
} | ||
delete(key) { | ||
return super.delete(intern_delete(this, key)); | ||
} | ||
} | ||
class InternSet extends Set { | ||
constructor(values = [], key = keyof) { | ||
super(); | ||
Object.defineProperties(this, {_intern: {value: new Map()}, _key: {value: key}}); | ||
for (const value of values) this.add(value); | ||
} | ||
has(value) { | ||
return super.has(intern_get(this, value)); | ||
} | ||
add(value) { | ||
return super.add(intern_set(this, value)); | ||
} | ||
delete(value) { | ||
return super.delete(intern_delete(this, value)); | ||
} | ||
} | ||
function intern_get({_intern, _key}, value) { | ||
const key = _key(value); | ||
return _intern.has(key) ? _intern.get(key) : value; | ||
} | ||
function intern_set({_intern, _key}, value) { | ||
const key = _key(value); | ||
if (_intern.has(key)) return _intern.get(key); | ||
_intern.set(key, value); | ||
return value; | ||
} | ||
function intern_delete({_intern, _key}, value) { | ||
const key = _key(value); | ||
if (_intern.has(key)) { | ||
value = _intern.get(value); | ||
_intern.delete(key); | ||
} | ||
return value; | ||
} | ||
function keyof(value) { | ||
return value !== null && typeof value === "object" ? value.valueOf() : value; | ||
} | ||
function identity(x) { | ||
@@ -306,3 +368,3 @@ return x; | ||
if (i >= keys.length) return reduce(values); | ||
const groups = new Map(); | ||
const groups = new InternMap(); | ||
const keyof = keys[i++]; | ||
@@ -1019,2 +1081,4 @@ let index = -1; | ||
exports.Adder = Adder; | ||
exports.InternMap = InternMap; | ||
exports.InternSet = InternSet; | ||
exports.ascending = ascending; | ||
@@ -1021,0 +1085,0 @@ exports.bin = bin; |
@@ -1,2 +0,2 @@ | ||
// https://d3js.org/d3-array/ v2.9.1 Copyright 2020 Mike Bostock | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";function n(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function r(t){let r=t,e=t;function o(t,n,r,o){for(null==r&&(r=0),null==o&&(o=t.length);r<o;){const f=r+o>>>1;e(t[f],n)<0?r=f+1:o=f}return r}return 1===t.length&&(r=(n,r)=>t(n)-r,e=function(t){return(r,e)=>n(t(r),e)}(t)),{left:o,center:function(t,n,e,f){null==e&&(e=0),null==f&&(f=t.length);const i=o(t,n,e,f-1);return i>e&&r(t[i-1],n)>-r(t[i],n)?i-1:i},right:function(t,n,r,o){for(null==r&&(r=0),null==o&&(o=t.length);r<o;){const f=r+o>>>1;e(t[f],n)>0?o=f:r=f+1}return r}}}function e(t){return null===t?NaN:+t}const o=r(n),f=o.right,i=o.left,u=r(e).center;function l(t,n){let r=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&++r;else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&(o=+o)>=o&&++r}return r}function c(t){return 0|t.length}function a(t){return!(t>0)}function s(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function h(t,n){let r,e=0,o=0,f=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(r=n-o,o+=r/++e,f+=r*(n-o));else{let i=-1;for(let u of t)null!=(u=n(u,++i,t))&&(u=+u)>=u&&(r=u-o,o+=r/++e,f+=r*(u-o))}if(e>1)return f/(e-1)}function d(t,n){const r=h(t,n);return r?Math.sqrt(r):r}function p(t,n){let r,e;if(void 0===n)for(const n of t)null!=n&&(void 0===r?n>=n&&(r=e=n):(r>n&&(r=n),e<n&&(e=n)));else{let o=-1;for(let f of t)null!=(f=n(f,++o,t))&&(void 0===r?f>=f&&(r=e=f):(r>f&&(r=f),e<f&&(e=f)))}return[r,e]}class y{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const n=this._partials;let r=0;for(let e=0;e<this._n&&e<32;e++){const o=n[e],f=t+o,i=Math.abs(t)<Math.abs(o)?t-(f-o):o-(f-t);i&&(n[r++]=i),t=f}return n[r]=t,this._n=r+1,this}valueOf(){const t=this._partials;let n,r,e,o=this._n,f=0;if(o>0){for(f=t[--o];o>0&&(n=f,r=t[--o],f=n+r,e=r-(f-n),!e););o>0&&(e<0&&t[o-1]<0||e>0&&t[o-1]>0)&&(r=2*e,n=f+r,r==n-f&&(f=n))}return f}}function v(t){return t}function m(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function M(t,n,r,e){return function t(o,f){if(f>=e.length)return r(o);const i=new Map,u=e[f++];let l=-1;for(const t of o){const n=u(t,++l,o),r=i.get(n);r?r.push(t):i.set(n,[t])}for(const[n,r]of i)i.set(n,t(r,f));return n(i)}(t,0)}var g=Array.prototype.slice;function w(t){return function(){return t}}var b=Math.sqrt(50),A=Math.sqrt(10),x=Math.sqrt(2);function S(t,n,r){var e,o,f,i,u=-1;if(r=+r,(t=+t)===(n=+n)&&r>0)return[t];if((e=n<t)&&(o=t,t=n,n=o),0===(i=T(t,n,r))||!isFinite(i))return[];if(i>0)for(t=Math.ceil(t/i),n=Math.floor(n/i),f=new Array(o=Math.ceil(n-t+1));++u<o;)f[u]=(t+u)*i;else for(i=-i,t=Math.ceil(t*i),n=Math.floor(n*i),f=new Array(o=Math.ceil(n-t+1));++u<o;)f[u]=(t+u)/i;return e&&f.reverse(),f}function T(t,n,r){var e=(n-t)/Math.max(0,r),o=Math.floor(Math.log(e)/Math.LN10),f=e/Math.pow(10,o);return o>=0?(f>=b?10:f>=A?5:f>=x?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=b?10:f>=A?5:f>=x?2:1)}function E(t,n,r){let e;for(;;){const o=T(t,n,r);if(o===e||0===o||!isFinite(o))return[t,n];o>0?(t=Math.floor(t/o)*o,n=Math.ceil(n/o)*o):o<0&&(t=Math.ceil(t*o)/o,n=Math.floor(n*o)/o),e=o}}function N(t){return Math.ceil(Math.log(l(t))/Math.LN2)+1}function _(){var t=v,n=p,r=N;function e(e){Array.isArray(e)||(e=Array.from(e));var o,i,u=e.length,l=new Array(u);for(o=0;o<u;++o)l[o]=t(e[o],o,e);var c=n(l),a=c[0],s=c[1],h=r(l,a,s);if(!Array.isArray(h)){const t=s,r=+h;if(n===p&&([a,s]=E(a,s,r)),(h=S(a,s,r))[h.length-1]>=s)if(t>=s&&n===p){const t=T(a,s,r);isFinite(t)&&(t>0?s=(Math.floor(s/t)+1)*t:t<0&&(s=(Math.ceil(s*-t)+1)/-t))}else h.pop()}for(var d=h.length;h[0]<=a;)h.shift(),--d;for(;h[d-1]>s;)h.pop(),--d;var y,v=new Array(d+1);for(o=0;o<=d;++o)(y=v[o]=[]).x0=o>0?h[o-1]:a,y.x1=o<d?h[o]:s;for(o=0;o<u;++o)a<=(i=l[o])&&i<=s&&v[f(h,i,0,d)].push(e[o]);return v}return e.value=function(n){return arguments.length?(t="function"==typeof n?n:w(n),e):t},e.domain=function(t){return arguments.length?(n="function"==typeof t?t:w([t[0],t[1]]),e):n},e.thresholds=function(t){return arguments.length?(r="function"==typeof t?t:Array.isArray(t)?w(g.call(t)):w(t),e):r},e}function q(t,n){let r;if(void 0===n)for(const n of t)null!=n&&(r<n||void 0===r&&n>=n)&&(r=n);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&(r<o||void 0===r&&o>=o)&&(r=o)}return r}function F(t,n){let r;if(void 0===n)for(const n of t)null!=n&&(r>n||void 0===r&&n>=n)&&(r=n);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&(r>o||void 0===r&&o>=o)&&(r=o)}return r}function j(t,r,e=0,o=t.length-1,f=n){for(;o>e;){if(o-e>600){const n=o-e+1,i=r-e+1,u=Math.log(n),l=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*l*(n-l)/n)*(i-n/2<0?-1:1);j(t,r,Math.max(e,Math.floor(r-i*l/n+c)),Math.min(o,Math.floor(r+(n-i)*l/n+c)),f)}const n=t[r];let i=e,u=o;for(k(t,e,r),f(t[o],n)>0&&k(t,e,o);i<u;){for(k(t,i,u),++i,--u;f(t[i],n)<0;)++i;for(;f(t[u],n)>0;)--u}0===f(t[e],n)?k(t,e,u):(++u,k(t,u,o)),u<=r&&(e=u+1),r<=u&&(o=u-1)}return t}function k(t,n,r){const e=t[n];t[n]=t[r],t[r]=e}function I(t,n,r){if(e=(t=Float64Array.from(function*(t,n){if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(yield n);else{let r=-1;for(let e of t)null!=(e=n(e,++r,t))&&(e=+e)>=e&&(yield e)}}(t,r))).length){if((n=+n)<=0||e<2)return F(t);if(n>=1)return q(t);var e,o=(e-1)*n,f=Math.floor(o),i=q(j(t,f).subarray(0,f+1));return i+(F(t.subarray(f+1))-i)*(o-f)}}function L(t,n){let r,e=-1,o=-1;if(void 0===n)for(const n of t)++o,null!=n&&(r<n||void 0===r&&n>=n)&&(r=n,e=o);else for(let f of t)null!=(f=n(f,++o,t))&&(r<f||void 0===r&&f>=f)&&(r=f,e=o);return e}function O(t,n){let r,e=-1,o=-1;if(void 0===n)for(const n of t)++o,null!=n&&(r>n||void 0===r&&n>=n)&&(r=n,e=o);else for(let f of t)null!=(f=n(f,++o,t))&&(r>f||void 0===r&&f>=f)&&(r=f,e=o);return e}function z(t,n){return[t,n]}function C(t,n){return Array.from(n,n=>t[n])}function D(t,r=n){if(1===r.length)return O(t,r);let e,o=-1,f=-1;for(const n of t)++f,(o<0?0===r(n,n):r(n,e)<0)&&(e=n,o=f);return o}var P=R(Math.random);function R(t){return function(n,r=0,e=n.length){let o=e-(r=+r);for(;o;){const e=t()*o--|0,f=n[o+r];n[o+r]=n[e+r],n[e+r]=f}return n}}function B(t){if(!(o=t.length))return[];for(var n=-1,r=F(t,G),e=new Array(r);++n<r;)for(var o,f=-1,i=e[n]=new Array(o);++f<o;)i[f]=t[f][n];return e}function G(t){return t.length}function H(t){return t instanceof Set?t:new Set(t)}function J(t,n){const r=t[Symbol.iterator](),e=new Set;for(const t of n){if(e.has(t))continue;let n,o;for(;({value:n,done:o}=r.next());){if(o)return!1;if(e.add(n),Object.is(t,n))break}}return!0}t.Adder=y,t.ascending=n,t.bin=_,t.bisect=f,t.bisectCenter=u,t.bisectLeft=i,t.bisectRight=f,t.bisector=r,t.count=l,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),r=(t=t.map(s)).map(c),e=t.length-1,o=new Array(e+1).fill(0),f=[];if(e<0||r.some(a))return f;for(;;){f.push(o.map((n,r)=>t[r][n]));let i=e;for(;++o[i]===r[i];){if(0===i)return n?f.map(n):f;o[i--]=0}}},t.cumsum=function(t,n){var r=0,e=0;return Float64Array.from(t,void 0===n?t=>r+=+t||0:o=>r+=+n(o,e++,t)||0)},t.descending=function(t,n){return n<t?-1:n>t?1:n>=t?0:NaN},t.deviation=d,t.difference=function(t,...n){t=new Set(t);for(const r of n)for(const n of r)t.delete(n);return t},t.disjoint=function(t,n){const r=n[Symbol.iterator](),e=new Set;for(const n of t){if(e.has(n))return!1;let t,o;for(;({value:t,done:o}=r.next())&&!o;){if(Object.is(n,t))return!1;e.add(t)}}return!0},t.every=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let r=-1;for(const e of t)if(!n(e,++r,t))return!1;return!0},t.extent=p,t.filter=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");const r=[];let e=-1;for(const o of t)n(o,++e,t)&&r.push(o);return r},t.fsum=function(t,n){const r=new y;if(void 0===n)for(let n of t)(n=+n)&&r.add(n);else{let e=-1;for(let o of t)(o=+n(o,++e,t))&&r.add(o)}return+r},t.greatest=function(t,r=n){let e,o=!1;if(1===r.length){let f;for(const i of t){const t=r(i);(o?n(t,f)>0:0===n(t,t))&&(e=i,f=t,o=!0)}}else for(const n of t)(o?r(n,e)>0:0===r(n,n))&&(e=n,o=!0);return e},t.greatestIndex=function(t,r=n){if(1===r.length)return L(t,r);let e,o=-1,f=-1;for(const n of t)++f,(o<0?0===r(n,n):r(n,e)>0)&&(e=n,o=f);return o},t.group=function(t,...n){return M(t,v,v,n)},t.groups=function(t,...n){return M(t,Array.from,v,n)},t.histogram=_,t.index=function(t,...n){return M(t,v,m,n)},t.indexes=function(t,...n){return M(t,Array.from,m,n)},t.intersection=function(t,...n){t=new Set(t),n=n.map(H);t:for(const r of t)for(const e of n)if(!e.has(r)){t.delete(r);continue t}return t},t.least=function(t,r=n){let e,o=!1;if(1===r.length){let f;for(const i of t){const t=r(i);(o?n(t,f)<0:0===n(t,t))&&(e=i,f=t,o=!0)}}else for(const n of t)(o?r(n,e)<0:0===r(n,n))&&(e=n,o=!0);return e},t.leastIndex=D,t.map=function(t,n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof n)throw new TypeError("mapper is not a function");return Array.from(t,(r,e)=>n(r,e,t))},t.max=q,t.maxIndex=L,t.mean=function(t,n){let r=0,e=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(++r,e+=n);else{let o=-1;for(let f of t)null!=(f=n(f,++o,t))&&(f=+f)>=f&&(++r,e+=f)}if(r)return e/r},t.median=function(t,n){return I(t,.5,n)},t.merge=function(t){return Array.from(function*(t){for(const n of t)yield*n}(t))},t.min=F,t.minIndex=O,t.nice=E,t.pairs=function(t,n=z){const r=[];let e,o=!1;for(const f of t)o&&r.push(n(e,f)),e=f,o=!0;return r},t.permute=C,t.quantile=I,t.quantileSorted=function(t,n,r=e){if(o=t.length){if((n=+n)<=0||o<2)return+r(t[0],0,t);if(n>=1)return+r(t[o-1],o-1,t);var o,f=(o-1)*n,i=Math.floor(f),u=+r(t[i],i,t);return u+(+r(t[i+1],i+1,t)-u)*(f-i)}},t.quickselect=j,t.range=function(t,n,r){t=+t,n=+n,r=(o=arguments.length)<2?(n=t,t=0,1):o<3?1:+r;for(var e=-1,o=0|Math.max(0,Math.ceil((n-t)/r)),f=new Array(o);++e<o;)f[e]=t+e*r;return f},t.reduce=function(t,n,r){if("function"!=typeof n)throw new TypeError("reducer is not a function");const e=t[Symbol.iterator]();let o,f,i=-1;if(arguments.length<3){if(({done:o,value:r}=e.next()),o)return;++i}for(;({done:o,value:f}=e.next()),!o;)r=n(r,f,++i,t);return r},t.reverse=function(t){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(t).reverse()},t.rollup=function(t,n,...r){return M(t,v,n,r)},t.rollups=function(t,n,...r){return M(t,Array.from,n,r)},t.scan=function(t,n){const r=D(t,n);return r<0?void 0:r},t.shuffle=P,t.shuffler=R,t.some=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let r=-1;for(const e of t)if(n(e,++r,t))return!0;return!1},t.sort=function(t,r=n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return t=Array.from(t),1===r.length?(r=t.map(r),C(t,t.map((t,n)=>n).sort((t,e)=>n(r[t],r[e])))):t.sort(r)},t.subset=function(t,n){return J(n,t)},t.sum=function(t,n){let r=0;if(void 0===n)for(let n of t)(n=+n)&&(r+=n);else{let e=-1;for(let o of t)(o=+n(o,++e,t))&&(r+=o)}return r},t.superset=J,t.thresholdFreedmanDiaconis=function(t,n,r){return Math.ceil((r-n)/(2*(I(t,.75)-I(t,.25))*Math.pow(l(t),-1/3)))},t.thresholdScott=function(t,n,r){return Math.ceil((r-n)/(3.5*d(t)*Math.pow(l(t),-1/3)))},t.thresholdSturges=N,t.tickIncrement=T,t.tickStep=function(t,n,r){var e=Math.abs(n-t)/Math.max(0,r),o=Math.pow(10,Math.floor(Math.log(e)/Math.LN10)),f=e/o;return f>=b?o*=10:f>=A?o*=5:f>=x&&(o*=2),n<t?-o:o},t.ticks=S,t.transpose=B,t.union=function(...t){const n=new Set;for(const r of t)for(const t of r)n.add(t);return n},t.variance=h,t.zip=function(){return B(arguments)},Object.defineProperty(t,"__esModule",{value:!0})})); | ||
// https://d3js.org/d3-array/ v2.10.0 Copyright 2021 Mike Bostock | ||
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t="undefined"!=typeof globalThis?globalThis:t||self).d3=t.d3||{})}(this,(function(t){"use strict";function n(t,n){return t<n?-1:t>n?1:t>=n?0:NaN}function e(t){let e=t,r=t;function o(t,n,e,o){for(null==e&&(e=0),null==o&&(o=t.length);e<o;){const f=e+o>>>1;r(t[f],n)<0?e=f+1:o=f}return e}return 1===t.length&&(e=(n,e)=>t(n)-e,r=function(t){return(e,r)=>n(t(e),r)}(t)),{left:o,center:function(t,n,r,f){null==r&&(r=0),null==f&&(f=t.length);const i=o(t,n,r,f-1);return i>r&&e(t[i-1],n)>-e(t[i],n)?i-1:i},right:function(t,n,e,o){for(null==e&&(e=0),null==o&&(o=t.length);e<o;){const f=e+o>>>1;r(t[f],n)>0?o=f:e=f+1}return e}}}function r(t){return null===t?NaN:+t}const o=e(n),f=o.right,i=o.left,u=e(r).center;function l(t,n){let e=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&++e;else{let r=-1;for(let o of t)null!=(o=n(o,++r,t))&&(o=+o)>=o&&++e}return e}function s(t){return 0|t.length}function c(t){return!(t>0)}function a(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function h(t,n){let e,r=0,o=0,f=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(e=n-o,o+=e/++r,f+=e*(n-o));else{let i=-1;for(let u of t)null!=(u=n(u,++i,t))&&(u=+u)>=u&&(e=u-o,o+=e/++r,f+=e*(u-o))}if(r>1)return f/(r-1)}function d(t,n){const e=h(t,n);return e?Math.sqrt(e):e}function p(t,n){let e,r;if(void 0===n)for(const n of t)null!=n&&(void 0===e?n>=n&&(e=r=n):(e>n&&(e=n),r<n&&(r=n)));else{let o=-1;for(let f of t)null!=(f=n(f,++o,t))&&(void 0===e?f>=f&&(e=r=f):(e>f&&(e=f),r<f&&(r=f)))}return[e,r]}class y{constructor(){this._partials=new Float64Array(32),this._n=0}add(t){const n=this._partials;let e=0;for(let r=0;r<this._n&&r<32;r++){const o=n[r],f=t+o,i=Math.abs(t)<Math.abs(o)?t-(f-o):o-(f-t);i&&(n[e++]=i),t=f}return n[e]=t,this._n=e+1,this}valueOf(){const t=this._partials;let n,e,r,o=this._n,f=0;if(o>0){for(f=t[--o];o>0&&(n=f,e=t[--o],f=n+e,r=e-(f-n),!r););o>0&&(r<0&&t[o-1]<0||r>0&&t[o-1]>0)&&(e=2*r,n=f+e,e==n-f&&(f=n))}return f}}class v extends Map{constructor(t=[],n=b){super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}});for(const[n,e]of t)this.set(n,e)}get(t){return super.get(g(this,t))}has(t){return super.has(g(this,t))}set(t,n){return super.set(m(this,t),n)}delete(t){return super.delete(w(this,t))}}class M extends Set{constructor(t=[],n=b){super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}});for(const n of t)this.add(n)}has(t){return super.has(g(this,t))}add(t){return super.add(m(this,t))}delete(t){return super.delete(w(this,t))}}function g({_intern:t,_key:n},e){const r=n(e);return t.has(r)?t.get(r):e}function m({_intern:t,_key:n},e){const r=n(e);return t.has(r)?t.get(r):(t.set(r,e),e)}function w({_intern:t,_key:n},e){const r=n(e);return t.has(r)&&(e=t.get(e),t.delete(r)),e}function b(t){return null!==t&&"object"==typeof t?t.valueOf():t}function A(t){return t}function x(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function S(t,n,e,r){return function t(o,f){if(f>=r.length)return e(o);const i=new v,u=r[f++];let l=-1;for(const t of o){const n=u(t,++l,o),e=i.get(n);e?e.push(t):i.set(n,[t])}for(const[n,e]of i)i.set(n,t(e,f));return n(i)}(t,0)}var _=Array.prototype.slice;function k(t){return function(){return t}}var T=Math.sqrt(50),j=Math.sqrt(10),E=Math.sqrt(2);function N(t,n,e){var r,o,f,i,u=-1;if(e=+e,(t=+t)===(n=+n)&&e>0)return[t];if((r=n<t)&&(o=t,t=n,n=o),0===(i=q(t,n,e))||!isFinite(i))return[];if(i>0)for(t=Math.ceil(t/i),n=Math.floor(n/i),f=new Array(o=Math.ceil(n-t+1));++u<o;)f[u]=(t+u)*i;else for(i=-i,t=Math.ceil(t*i),n=Math.floor(n*i),f=new Array(o=Math.ceil(n-t+1));++u<o;)f[u]=(t+u)/i;return r&&f.reverse(),f}function q(t,n,e){var r=(n-t)/Math.max(0,e),o=Math.floor(Math.log(r)/Math.LN10),f=r/Math.pow(10,o);return o>=0?(f>=T?10:f>=j?5:f>=E?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=T?10:f>=j?5:f>=E?2:1)}function F(t,n,e){let r;for(;;){const o=q(t,n,e);if(o===r||0===o||!isFinite(o))return[t,n];o>0?(t=Math.floor(t/o)*o,n=Math.ceil(n/o)*o):o<0&&(t=Math.ceil(t*o)/o,n=Math.floor(n*o)/o),r=o}}function I(t){return Math.ceil(Math.log(l(t))/Math.LN2)+1}function O(){var t=A,n=p,e=I;function r(r){Array.isArray(r)||(r=Array.from(r));var o,i,u=r.length,l=new Array(u);for(o=0;o<u;++o)l[o]=t(r[o],o,r);var s=n(l),c=s[0],a=s[1],h=e(l,c,a);if(!Array.isArray(h)){const t=a,e=+h;if(n===p&&([c,a]=F(c,a,e)),(h=N(c,a,e))[h.length-1]>=a)if(t>=a&&n===p){const t=q(c,a,e);isFinite(t)&&(t>0?a=(Math.floor(a/t)+1)*t:t<0&&(a=(Math.ceil(a*-t)+1)/-t))}else h.pop()}for(var d=h.length;h[0]<=c;)h.shift(),--d;for(;h[d-1]>a;)h.pop(),--d;var y,v=new Array(d+1);for(o=0;o<=d;++o)(y=v[o]=[]).x0=o>0?h[o-1]:c,y.x1=o<d?h[o]:a;for(o=0;o<u;++o)c<=(i=l[o])&&i<=a&&v[f(h,i,0,d)].push(r[o]);return v}return r.value=function(n){return arguments.length?(t="function"==typeof n?n:k(n),r):t},r.domain=function(t){return arguments.length?(n="function"==typeof t?t:k([t[0],t[1]]),r):n},r.thresholds=function(t){return arguments.length?(e="function"==typeof t?t:Array.isArray(t)?k(_.call(t)):k(t),r):e},r}function L(t,n){let e;if(void 0===n)for(const n of t)null!=n&&(e<n||void 0===e&&n>=n)&&(e=n);else{let r=-1;for(let o of t)null!=(o=n(o,++r,t))&&(e<o||void 0===e&&o>=o)&&(e=o)}return e}function P(t,n){let e;if(void 0===n)for(const n of t)null!=n&&(e>n||void 0===e&&n>=n)&&(e=n);else{let r=-1;for(let o of t)null!=(o=n(o,++r,t))&&(e>o||void 0===e&&o>=o)&&(e=o)}return e}function z(t,e,r=0,o=t.length-1,f=n){for(;o>r;){if(o-r>600){const n=o-r+1,i=e-r+1,u=Math.log(n),l=.5*Math.exp(2*u/3),s=.5*Math.sqrt(u*l*(n-l)/n)*(i-n/2<0?-1:1);z(t,e,Math.max(r,Math.floor(e-i*l/n+s)),Math.min(o,Math.floor(e+(n-i)*l/n+s)),f)}const n=t[e];let i=r,u=o;for(C(t,r,e),f(t[o],n)>0&&C(t,r,o);i<u;){for(C(t,i,u),++i,--u;f(t[i],n)<0;)++i;for(;f(t[u],n)>0;)--u}0===f(t[r],n)?C(t,r,u):(++u,C(t,u,o)),u<=e&&(r=u+1),e<=u&&(o=u-1)}return t}function C(t,n,e){const r=t[n];t[n]=t[e],t[e]=r}function D(t,n,e){if(r=(t=Float64Array.from(function*(t,n){if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(yield n);else{let e=-1;for(let r of t)null!=(r=n(r,++e,t))&&(r=+r)>=r&&(yield r)}}(t,e))).length){if((n=+n)<=0||r<2)return P(t);if(n>=1)return L(t);var r,o=(r-1)*n,f=Math.floor(o),i=L(z(t,f).subarray(0,f+1));return i+(P(t.subarray(f+1))-i)*(o-f)}}function R(t,n){let e,r=-1,o=-1;if(void 0===n)for(const n of t)++o,null!=n&&(e<n||void 0===e&&n>=n)&&(e=n,r=o);else for(let f of t)null!=(f=n(f,++o,t))&&(e<f||void 0===e&&f>=f)&&(e=f,r=o);return r}function B(t,n){let e,r=-1,o=-1;if(void 0===n)for(const n of t)++o,null!=n&&(e>n||void 0===e&&n>=n)&&(e=n,r=o);else for(let f of t)null!=(f=n(f,++o,t))&&(e>f||void 0===e&&f>=f)&&(e=f,r=o);return r}function G(t,n){return[t,n]}function H(t,n){return Array.from(n,n=>t[n])}function J(t,e=n){if(1===e.length)return B(t,e);let r,o=-1,f=-1;for(const n of t)++f,(o<0?0===e(n,n):e(n,r)<0)&&(r=n,o=f);return o}var K=Q(Math.random);function Q(t){return function(n,e=0,r=n.length){let o=r-(e=+e);for(;o;){const r=t()*o--|0,f=n[o+e];n[o+e]=n[r+e],n[r+e]=f}return n}}function U(t){if(!(o=t.length))return[];for(var n=-1,e=P(t,V),r=new Array(e);++n<e;)for(var o,f=-1,i=r[n]=new Array(o);++f<o;)i[f]=t[f][n];return r}function V(t){return t.length}function W(t){return t instanceof Set?t:new Set(t)}function X(t,n){const e=t[Symbol.iterator](),r=new Set;for(const t of n){if(r.has(t))continue;let n,o;for(;({value:n,done:o}=e.next());){if(o)return!1;if(r.add(n),Object.is(t,n))break}}return!0}t.Adder=y,t.InternMap=v,t.InternSet=M,t.ascending=n,t.bin=O,t.bisect=f,t.bisectCenter=u,t.bisectLeft=i,t.bisectRight=f,t.bisector=e,t.count=l,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),e=(t=t.map(a)).map(s),r=t.length-1,o=new Array(r+1).fill(0),f=[];if(r<0||e.some(c))return f;for(;;){f.push(o.map((n,e)=>t[e][n]));let i=r;for(;++o[i]===e[i];){if(0===i)return n?f.map(n):f;o[i--]=0}}},t.cumsum=function(t,n){var e=0,r=0;return Float64Array.from(t,void 0===n?t=>e+=+t||0:o=>e+=+n(o,r++,t)||0)},t.descending=function(t,n){return n<t?-1:n>t?1:n>=t?0:NaN},t.deviation=d,t.difference=function(t,...n){t=new Set(t);for(const e of n)for(const n of e)t.delete(n);return t},t.disjoint=function(t,n){const e=n[Symbol.iterator](),r=new Set;for(const n of t){if(r.has(n))return!1;let t,o;for(;({value:t,done:o}=e.next())&&!o;){if(Object.is(n,t))return!1;r.add(t)}}return!0},t.every=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let e=-1;for(const r of t)if(!n(r,++e,t))return!1;return!0},t.extent=p,t.filter=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");const e=[];let r=-1;for(const o of t)n(o,++r,t)&&e.push(o);return e},t.fsum=function(t,n){const e=new y;if(void 0===n)for(let n of t)(n=+n)&&e.add(n);else{let r=-1;for(let o of t)(o=+n(o,++r,t))&&e.add(o)}return+e},t.greatest=function(t,e=n){let r,o=!1;if(1===e.length){let f;for(const i of t){const t=e(i);(o?n(t,f)>0:0===n(t,t))&&(r=i,f=t,o=!0)}}else for(const n of t)(o?e(n,r)>0:0===e(n,n))&&(r=n,o=!0);return r},t.greatestIndex=function(t,e=n){if(1===e.length)return R(t,e);let r,o=-1,f=-1;for(const n of t)++f,(o<0?0===e(n,n):e(n,r)>0)&&(r=n,o=f);return o},t.group=function(t,...n){return S(t,A,A,n)},t.groups=function(t,...n){return S(t,Array.from,A,n)},t.histogram=O,t.index=function(t,...n){return S(t,A,x,n)},t.indexes=function(t,...n){return S(t,Array.from,x,n)},t.intersection=function(t,...n){t=new Set(t),n=n.map(W);t:for(const e of t)for(const r of n)if(!r.has(e)){t.delete(e);continue t}return t},t.least=function(t,e=n){let r,o=!1;if(1===e.length){let f;for(const i of t){const t=e(i);(o?n(t,f)<0:0===n(t,t))&&(r=i,f=t,o=!0)}}else for(const n of t)(o?e(n,r)<0:0===e(n,n))&&(r=n,o=!0);return r},t.leastIndex=J,t.map=function(t,n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");if("function"!=typeof n)throw new TypeError("mapper is not a function");return Array.from(t,(e,r)=>n(e,r,t))},t.max=L,t.maxIndex=R,t.mean=function(t,n){let e=0,r=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(++e,r+=n);else{let o=-1;for(let f of t)null!=(f=n(f,++o,t))&&(f=+f)>=f&&(++e,r+=f)}if(e)return r/e},t.median=function(t,n){return D(t,.5,n)},t.merge=function(t){return Array.from(function*(t){for(const n of t)yield*n}(t))},t.min=P,t.minIndex=B,t.nice=F,t.pairs=function(t,n=G){const e=[];let r,o=!1;for(const f of t)o&&e.push(n(r,f)),r=f,o=!0;return e},t.permute=H,t.quantile=D,t.quantileSorted=function(t,n,e=r){if(o=t.length){if((n=+n)<=0||o<2)return+e(t[0],0,t);if(n>=1)return+e(t[o-1],o-1,t);var o,f=(o-1)*n,i=Math.floor(f),u=+e(t[i],i,t);return u+(+e(t[i+1],i+1,t)-u)*(f-i)}},t.quickselect=z,t.range=function(t,n,e){t=+t,n=+n,e=(o=arguments.length)<2?(n=t,t=0,1):o<3?1:+e;for(var r=-1,o=0|Math.max(0,Math.ceil((n-t)/e)),f=new Array(o);++r<o;)f[r]=t+r*e;return f},t.reduce=function(t,n,e){if("function"!=typeof n)throw new TypeError("reducer is not a function");const r=t[Symbol.iterator]();let o,f,i=-1;if(arguments.length<3){if(({done:o,value:e}=r.next()),o)return;++i}for(;({done:o,value:f}=r.next()),!o;)e=n(e,f,++i,t);return e},t.reverse=function(t){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return Array.from(t).reverse()},t.rollup=function(t,n,...e){return S(t,A,n,e)},t.rollups=function(t,n,...e){return S(t,Array.from,n,e)},t.scan=function(t,n){const e=J(t,n);return e<0?void 0:e},t.shuffle=K,t.shuffler=Q,t.some=function(t,n){if("function"!=typeof n)throw new TypeError("test is not a function");let e=-1;for(const r of t)if(n(r,++e,t))return!0;return!1},t.sort=function(t,e=n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");return t=Array.from(t),1===e.length?(e=t.map(e),H(t,t.map((t,n)=>n).sort((t,r)=>n(e[t],e[r])))):t.sort(e)},t.subset=function(t,n){return X(n,t)},t.sum=function(t,n){let e=0;if(void 0===n)for(let n of t)(n=+n)&&(e+=n);else{let r=-1;for(let o of t)(o=+n(o,++r,t))&&(e+=o)}return e},t.superset=X,t.thresholdFreedmanDiaconis=function(t,n,e){return Math.ceil((e-n)/(2*(D(t,.75)-D(t,.25))*Math.pow(l(t),-1/3)))},t.thresholdScott=function(t,n,e){return Math.ceil((e-n)/(3.5*d(t)*Math.pow(l(t),-1/3)))},t.thresholdSturges=I,t.tickIncrement=q,t.tickStep=function(t,n,e){var r=Math.abs(n-t)/Math.max(0,e),o=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),f=r/o;return f>=T?o*=10:f>=j?o*=5:f>=E&&(o*=2),n<t?-o:o},t.ticks=N,t.transpose=U,t.union=function(...t){const n=new Set;for(const e of t)for(const t of e)n.add(t);return n},t.variance=h,t.zip=function(){return U(arguments)},Object.defineProperty(t,"__esModule",{value:!0})})); |
{ | ||
"name": "d3-array", | ||
"version": "2.9.1", | ||
"version": "2.10.0", | ||
"description": "Array manipulation, ordering, searching, summarizing, etc.", | ||
@@ -41,2 +41,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^11.1.0", | ||
"d3-random": "2", | ||
@@ -49,3 +50,6 @@ "eslint": "7", | ||
"tape-await": "0.1" | ||
}, | ||
"dependencies": { | ||
"internmap": "^1.0.0" | ||
} | ||
} |
@@ -54,2 +54,3 @@ # d3-array | ||
* [Bins](#bins) | ||
* [Interning](#interning) | ||
@@ -60,3 +61,3 @@ ### Statistics | ||
<a name="min" href="#min">#</a> d3.<b>min</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/min.js), [Examples](https://observablehq.com/@d3/d3-min-d3-max-d3-extent) | ||
<a name="min" href="#min">#</a> d3.<b>min</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/min.js), [Examples](https://observablehq.com/@d3/d3-extent) | ||
@@ -69,3 +70,3 @@ Returns the minimum value in the given *iterable* using natural order. If the iterable contains no comparable values, returns undefined. An optional *accessor* function may be specified, which is equivalent to calling Array.from before computing the minimum value. | ||
<a name="minIndex" href="#minIndex">#</a> d3.<b>minIndex</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/minIndex.js), [Examples](https://observablehq.com/@d3/d3-min-d3-max-d3-extent) | ||
<a name="minIndex" href="#minIndex">#</a> d3.<b>minIndex</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/minIndex.js), [Examples](https://observablehq.com/@d3/d3-extent) | ||
@@ -76,3 +77,3 @@ Returns the index of the minimum value in the given *iterable* using natural order. If the iterable contains no comparable values, returns -1. An optional *accessor* function may be specified, which is equivalent to calling Array.from before computing the minimum value. | ||
<a name="max" href="#max">#</a> d3.<b>max</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/max.js), [Examples](https://observablehq.com/@d3/d3-min-d3-max-d3-extent) | ||
<a name="max" href="#max">#</a> d3.<b>max</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/max.js), [Examples](https://observablehq.com/@d3/d3-extent) | ||
@@ -85,3 +86,3 @@ Returns the maximum value in the given *iterable* using natural order. If the iterable contains no comparable values, returns undefined. An optional *accessor* function may be specified, which is equivalent to calling Array.from before computing the maximum value. | ||
<a name="maxIndex" href="#maxIndex">#</a> d3.<b>maxIndex</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/maxIndex.js), [Examples](https://observablehq.com/@d3/d3-min-d3-max-d3-extent) | ||
<a name="maxIndex" href="#maxIndex">#</a> d3.<b>maxIndex</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/maxIndex.js), [Examples](https://observablehq.com/@d3/d3-extent) | ||
@@ -92,3 +93,3 @@ Returns the index of the maximum value in the given *iterable* using natural order. If the iterable contains no comparable values, returns -1. An optional *accessor* function may be specified, which is equivalent to calling Array.from before computing the maximum value. | ||
<a name="extent" href="#extent">#</a> d3.<b>extent</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/extent.js), [Examples](https://observablehq.com/@d3/d3-min-d3-max-d3-extent) | ||
<a name="extent" href="#extent">#</a> d3.<b>extent</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/extent.js), [Examples](https://observablehq.com/@d3/d3-extent) | ||
@@ -313,3 +314,3 @@ Returns the [minimum](#min) and [maximum](#max) value in the given *iterable* using natural order. If the iterable contains no comparable values, returns [undefined, undefined]. An optional *accessor* function may be specified, which is equivalent to calling Array.from before computing the extent. | ||
Groups the specified *iterable* of values into a Map from *key* to array of value. For example, given some data: | ||
Groups the specified *iterable* of values into an [InternMap](#InternMap) from *key* to array of value. For example, given some data: | ||
@@ -341,3 +342,3 @@ ```js | ||
If more than one *key* is specified, a nested Map is returned. For example: | ||
If more than one *key* is specified, a nested InternMap is returned. For example: | ||
@@ -396,3 +397,3 @@ ```js | ||
In the near future, [*selection*.data](https://github.com/d3/d3-selection/blob/master/README.md#selection_data) will accept iterables directly, meaning that you can use a Map (or Set or other iterable) to perform a data join without first needing to convert to an array. | ||
[*selection*.data](https://github.com/d3/d3-selection/blob/master/README.md#selection_data) accepts iterables directly, meaning that you can use a Map (or Set or other iterable) to perform a data join without first needing to convert to an array. | ||
@@ -403,3 +404,3 @@ <a name="groups" href="#groups">#</a> d3.<b>groups</b>(<i>iterable</i>, <i>...keys</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/group.js), [Examples](https://observablehq.com/@d3/d3-group-d3-rollup) | ||
<a name="index" href="#index">#</a> d3.<b>index</b>(<i>iterable</i>, <i>...keys</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/group.js)<!-- , [Examples](https://observablehq.com/@d3/d3-index) --> | ||
<a name="index" href="#index">#</a> d3.<b>index</b>(<i>iterable</i>, <i>...keys</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/group.js), [Examples](https://observablehq.com/@d3/d3-group) | ||
@@ -433,3 +434,3 @@ Equivalent to [group](#group) but returns a unique value per compound key instead of an array, throwing if the key is not unique. | ||
<a name="indexes" href="#indexes">#</a> d3.<b>indexes</b>(<i>iterable</i>, <i>...keys</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/group.js)<!-- , [Examples](https://observablehq.com/@d3/d3-index) --> | ||
<a name="indexes" href="#indexes">#</a> d3.<b>indexes</b>(<i>iterable</i>, <i>...keys</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/group.js), [Examples](https://observablehq.com/@d3/d3-group) | ||
@@ -440,3 +441,3 @@ Equivalent to [index](#index), but returns nested arrays instead of nested maps. | ||
[Groups](#group) and reduces the specified *iterable* of values into a Map from *key* to value. For example, given some data: | ||
[Groups](#group) and reduces the specified *iterable* of values into an InternMap from *key* to value. For example, given some data: | ||
@@ -836,1 +837,8 @@ ```js | ||
For instance, when binning date values, you might want to use the ticks from a time scale ([Example](https://observablehq.com/@d3/d3-bin-time-thresholds)). | ||
### Interning | ||
<a name="InternMap" href="#InternMap">#</a> new d3.<b>InternMap</b>([<i>iterable</i>][, <i>key</i>]) · [Source](https://github.com/mbostock/internmap/blob/main/src/index.js), [Examples](https://observablehq.com/d/d4c5f6ad343866b9) | ||
<br><a name="InternSet" href="#InternSet">#</a> new d3.<b>InternSet</b>([<i>iterable</i>][, <i>key</i>]) · [Source](https://github.com/mbostock/internmap/blob/main/src/index.js), [Examples](https://observablehq.com/d/d4c5f6ad343866b9) | ||
The [InternMap and InternSet](https://github.com/mbostock/internmap) classes extend the native JavaScript Map and Set classes, respectively, allowing Dates and other non-primitive keys by bypassing the [SameValueZero algorithm](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness) when determining key equality. d3.group, d3.rollup and d3.index use an InternMap rather than a native Map. These two classes are exported for convenience. |
@@ -0,1 +1,2 @@ | ||
import {InternMap} from "internmap"; | ||
import identity from "./identity.js"; | ||
@@ -35,3 +36,3 @@ | ||
if (i >= keys.length) return reduce(values); | ||
const groups = new Map(); | ||
const groups = new InternMap(); | ||
const keyof = keys[i++]; | ||
@@ -38,0 +39,0 @@ let index = -1; |
@@ -53,1 +53,2 @@ export {default as bisect, bisectRight, bisectLeft, bisectCenter} from "./bisect.js"; | ||
export {default as union} from "./union.js"; | ||
export {InternMap, InternSet} from "internmap"; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
131194
2065
832
1
8
+ Addedinternmap@^1.0.0
+ Addedinternmap@1.0.1(transitive)