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

d3-array

Package Overview
Dependencies
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-array - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

78

dist/d3-array.js

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

// https://d3js.org/d3-array/ v2.6.0 Copyright 2020 Mike Bostock
// https://d3js.org/d3-array/ v2.7.0 Copyright 2020 Mike Bostock
(function (global, factory) {

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

if (hi == null) hi = a.length;
const i = left(a, x, lo, hi);
const i = left(a, x, lo, hi - 1);
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;

@@ -58,6 +58,28 @@ }

var ascendingBisect = bisector(ascending);
var bisectRight = ascendingBisect.right;
var bisectLeft = ascendingBisect.left;
function number(x) {
return x === null ? NaN : +x;
}
function* numbers(values, valueof) {
if (valueof === undefined) {
for (let value of values) {
if (value != null && (value = +value) >= value) {
yield value;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
yield value;
}
}
}
}
const ascendingBisect = bisector(ascending);
const bisectRight = ascendingBisect.right;
const bisectLeft = ascendingBisect.left;
const bisectCenter = bisector(number).center;
function count(values, valueof) {

@@ -536,23 +558,2 @@ let count = 0;

function number(x) {
return x === null ? NaN : +x;
}
function* numbers(values, valueof) {
if (valueof === undefined) {
for (let value of values) {
if (value != null && (value = +value) >= value) {
yield value;
}
}
} else {
let index = -1;
for (let value of values) {
if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
yield value;
}
}
}
}
function quantile(values, p, valueof) {

@@ -786,15 +787,14 @@ values = Float64Array.from(numbers(values, valueof));

function shuffle(array, i0 = 0, i1 = array.length) {
var m = i1 - (i0 = +i0),
t,
i;
var shuffle = shuffler(Math.random);
while (m) {
i = Math.random() * m-- | 0;
t = array[m + i0];
array[m + i0] = array[i + i0];
array[i + i0] = t;
}
return array;
function shuffler(random) {
return function shuffle(array, i0 = 0, i1 = array.length) {
let m = i1 - (i0 = +i0);
while (m) {
const i = random() * m-- | 0, t = array[m + i0];
array[m + i0] = array[i + i0];
array[i + i0] = t;
}
return array;
};
}

@@ -843,2 +843,3 @@

exports.bisect = bisectRight;
exports.bisectCenter = bisectCenter;
exports.bisectLeft = bisectLeft;

@@ -880,2 +881,3 @@ exports.bisectRight = bisectRight;

exports.shuffle = shuffle;
exports.shuffler = shuffler;
exports.sum = sum;

@@ -882,0 +884,0 @@ exports.thresholdFreedmanDiaconis = freedmanDiaconis;

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

// https://d3js.org/d3-array/ v2.6.0 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 u=o(t,n,e,f);return u>e&&r(t[u-1],n)>-r(t[u],n)?u-1:u},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}}}var e=r(n),o=e.right,f=e.left;function u(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 i(t){return 0|t.length}function l(t){return!(t>0)}function a(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function c(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 u=-1;for(let i of t)null!=(i=n(i,++u,t))&&(i=+i)>=i&&(r=i-o,o+=r/++e,f+=r*(i-o))}if(e>1)return f/(e-1)}function s(t,n){const r=c(t,n);return r?Math.sqrt(r):r}function h(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 d{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,u=Math.abs(t)<Math.abs(o)?t-(f-o):o-(f-t);u&&(n[r++]=u),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 p(t){return t}function v(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 u=new Map,i=e[f++];let l=-1;for(const t of o){const n=i(t,++l,o),r=u.get(n);r?r.push(t):u.set(n,[t])}for(const[n,r]of u)u.set(n,t(r,f));return n(u)}(t,0)}var g=Array.prototype.slice;function y(t){return function(){return t}}function m(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}var A=Math.sqrt(50),w=Math.sqrt(10),x=Math.sqrt(2);function b(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>=A?10:f>=w?5:f>=x?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=A?10:f>=w?5:f>=x?2:1)}function N(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>=A?o*=10:f>=w?o*=5:f>=x&&(o*=2),n<t?-o:o}function _(t){return Math.ceil(Math.log(u(t))/Math.LN2)+1}function q(){var t=p,n=h,r=_;function e(e){Array.isArray(e)||(e=Array.from(e));var f,u,i=e.length,l=new Array(i);for(f=0;f<i;++f)l[f]=t(e[f],f,e);var a=n(l),c=a[0],s=a[1],h=r(l,c,s);Array.isArray(h)||(h=N(c,s,h),h=m(Math.ceil(c/h)*h,s,h));for(var d=h.length;h[0]<=c;)h.shift(),--d;for(;h[d-1]>s;)h.pop(),--d;var p,v=new Array(d+1);for(f=0;f<=d;++f)(p=v[f]=[]).x0=f>0?h[f-1]:c,p.x1=f<d?h[f]:s;for(f=0;f<i;++f)c<=(u=l[f])&&u<=s&&v[o(h,u,0,d)].push(e[f]);return v}return e.value=function(n){return arguments.length?(t="function"==typeof n?n:y(n),e):t},e.domain=function(t){return arguments.length?(n="function"==typeof t?t:y([t[0],t[1]]),e):n},e.thresholds=function(t){return arguments.length?(r="function"==typeof t?t:Array.isArray(t)?y(g.call(t)):y(t),e):r},e}function k(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 I(t,r,e=0,o=t.length-1,f=n){for(;o>e;){if(o-e>600){const n=o-e+1,u=r-e+1,i=Math.log(n),l=.5*Math.exp(2*i/3),a=.5*Math.sqrt(i*l*(n-l)/n)*(u-n/2<0?-1:1);I(t,r,Math.max(e,Math.floor(r-u*l/n+a)),Math.min(o,Math.floor(r+(n-u)*l/n+a)),f)}const n=t[r];let u=e,i=o;for(L(t,e,r),f(t[o],n)>0&&L(t,e,o);u<i;){for(L(t,u,i),++u,--i;f(t[u],n)<0;)++u;for(;f(t[i],n)>0;)--i}0===f(t[e],n)?L(t,e,i):(++i,L(t,i,o)),i<=r&&(e=i+1),r<=i&&(o=i-1)}return t}function L(t,n,r){const e=t[n];t[n]=t[r],t[r]=e}function S(t){return null===t?NaN:+t}function j(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 k(t);var e,o=(e-1)*n,f=Math.floor(o),u=k(I(t,f).subarray(0,f+1));return u+(F(t.subarray(f+1))-u)*(o-f)}}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 T(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 D(t,r=n){if(1===r.length)return T(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}function E(t){if(!(o=t.length))return[];for(var n=-1,r=F(t,P),e=new Array(r);++n<r;)for(var o,f=-1,u=e[n]=new Array(o);++f<o;)u[f]=t[f][n];return e}function P(t){return t.length}t.Adder=d,t.ascending=n,t.bin=q,t.bisect=o,t.bisectLeft=f,t.bisectRight=o,t.bisector=r,t.count=u,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),r=(t=t.map(a)).map(i),e=t.length-1,o=new Array(e+1).fill(0),f=[];if(e<0||r.some(l))return f;for(;;){f.push(o.map((n,r)=>t[r][n]));let u=e;for(;++o[u]===r[u];){if(0===u)return n?f.map(n):f;o[u--]=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=s,t.extent=h,t.fsum=function(t,n){const r=new d;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 u of t){const t=r(u);(o?n(t,f)>0:0===n(t,t))&&(e=u,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 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},t.group=function(t,...n){return M(t,p,p,n)},t.groups=function(t,...n){return M(t,Array.from,p,n)},t.histogram=q,t.index=function(t,...n){return M(t,p,v,n)},t.indexes=function(t,...n){return M(t,Array.from,v,n)},t.least=function(t,r=n){let e,o=!1;if(1===r.length){let f;for(const u of t){const t=r(u);(o?n(t,f)<0:0===n(t,t))&&(e=u,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.max=k,t.maxIndex=O,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 j(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=T,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=function(t,n){return Array.from(n,n=>t[n])},t.quantile=j,t.quantileSorted=function(t,n,r=S){if(e=t.length){if((n=+n)<=0||e<2)return+r(t[0],0,t);if(n>=1)return+r(t[e-1],e-1,t);var e,o=(e-1)*n,f=Math.floor(o),u=+r(t[f],f,t);return u+(+r(t[f+1],f+1,t)-u)*(o-f)}},t.quickselect=I,t.range=m,t.rollup=function(t,n,...r){return M(t,p,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=function(t,n=0,r=t.length){for(var e,o,f=r-(n=+n);f;)o=Math.random()*f--|0,e=t[f+n],t[f+n]=t[o+n],t[o+n]=e;return 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.thresholdFreedmanDiaconis=function(t,n,r){return Math.ceil((r-n)/(2*(j(t,.75)-j(t,.25))*Math.pow(u(t),-1/3)))},t.thresholdScott=function(t,n,r){return Math.ceil((r-n)/(3.5*s(t)*Math.pow(u(t),-1/3)))},t.thresholdSturges=_,t.tickIncrement=b,t.tickStep=N,t.ticks=function(t,n,r){var e,o,f,u,i=-1;if(r=+r,(t=+t)===(n=+n)&&r>0)return[t];if((e=n<t)&&(o=t,t=n,n=o),0===(u=b(t,n,r))||!isFinite(u))return[];if(u>0)for(t=Math.ceil(t/u),n=Math.floor(n/u),f=new Array(o=Math.ceil(n-t+1));++i<o;)f[i]=(t+i)*u;else for(u=-u,t=Math.ceil(t*u),n=Math.floor(n*u),f=new Array(o=Math.ceil(n-t+1));++i<o;)f[i]=(t+i)/u;return e&&f.reverse(),f},t.transpose=E,t.variance=c,t.zip=function(){return E(arguments)},Object.defineProperty(t,"__esModule",{value:!0})}));
// https://d3js.org/d3-array/ v2.7.0 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 u=o(t,n,e,f-1);return u>e&&r(t[u-1],n)>-r(t[u],n)?u-1:u},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,u=o.left,i=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 u=-1;for(let i of t)null!=(i=n(i,++u,t))&&(i=+i)>=i&&(r=i-o,o+=r/++e,f+=r*(i-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 M{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,u=Math.abs(t)<Math.abs(o)?t-(f-o):o-(f-t);u&&(n[r++]=u),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 g(t){return t}function v(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function y(t,n,r,e){return function t(o,f){if(f>=e.length)return r(o);const u=new Map,i=e[f++];let l=-1;for(const t of o){const n=i(t,++l,o),r=u.get(n);r?r.push(t):u.set(n,[t])}for(const[n,r]of u)u.set(n,t(r,f));return n(u)}(t,0)}var m=Array.prototype.slice;function A(t){return function(){return t}}function w(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}var x=Math.sqrt(50),b=Math.sqrt(10),N=Math.sqrt(2);function _(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>=x?10:f>=b?5:f>=N?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=x?10:f>=b?5:f>=N?2:1)}function q(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>=x?o*=10:f>=b?o*=5:f>=N&&(o*=2),n<t?-o:o}function k(t){return Math.ceil(Math.log(l(t))/Math.LN2)+1}function F(){var t=g,n=p,r=k;function e(e){Array.isArray(e)||(e=Array.from(e));var o,u,i=e.length,l=new Array(i);for(o=0;o<i;++o)l[o]=t(e[o],o,e);var c=n(l),a=c[0],s=c[1],h=r(l,a,s);Array.isArray(h)||(h=q(a,s,h),h=w(Math.ceil(a/h)*h,s,h));for(var d=h.length;h[0]<=a;)h.shift(),--d;for(;h[d-1]>s;)h.pop(),--d;var p,M=new Array(d+1);for(o=0;o<=d;++o)(p=M[o]=[]).x0=o>0?h[o-1]:a,p.x1=o<d?h[o]:s;for(o=0;o<i;++o)a<=(u=l[o])&&u<=s&&M[f(h,u,0,d)].push(e[o]);return M}return e.value=function(n){return arguments.length?(t="function"==typeof n?n:A(n),e):t},e.domain=function(t){return arguments.length?(n="function"==typeof t?t:A([t[0],t[1]]),e):n},e.thresholds=function(t){return arguments.length?(r="function"==typeof t?t:Array.isArray(t)?A(m.call(t)):A(t),e):r},e}function I(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 L(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 S(t,r,e=0,o=t.length-1,f=n){for(;o>e;){if(o-e>600){const n=o-e+1,u=r-e+1,i=Math.log(n),l=.5*Math.exp(2*i/3),c=.5*Math.sqrt(i*l*(n-l)/n)*(u-n/2<0?-1:1);S(t,r,Math.max(e,Math.floor(r-u*l/n+c)),Math.min(o,Math.floor(r+(n-u)*l/n+c)),f)}const n=t[r];let u=e,i=o;for(j(t,e,r),f(t[o],n)>0&&j(t,e,o);u<i;){for(j(t,u,i),++u,--i;f(t[u],n)<0;)++u;for(;f(t[i],n)>0;)--i}0===f(t[e],n)?j(t,e,i):(++i,j(t,i,o)),i<=r&&(e=i+1),r<=i&&(o=i-1)}return t}function j(t,n,r){const e=t[n];t[n]=t[r],t[r]=e}function O(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 L(t);if(n>=1)return I(t);var e,o=(e-1)*n,f=Math.floor(o),u=I(S(t,f).subarray(0,f+1));return u+(L(t.subarray(f+1))-u)*(o-f)}}function T(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){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 C(t,n){return[t,n]}function D(t,r=n){if(1===r.length)return z(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 E=P(Math.random);function P(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 R(t){if(!(o=t.length))return[];for(var n=-1,r=L(t,B),e=new Array(r);++n<r;)for(var o,f=-1,u=e[n]=new Array(o);++f<o;)u[f]=t[f][n];return e}function B(t){return t.length}t.Adder=M,t.ascending=n,t.bin=F,t.bisect=f,t.bisectCenter=i,t.bisectLeft=u,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 u=e;for(;++o[u]===r[u];){if(0===u)return n?f.map(n):f;o[u--]=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.extent=p,t.fsum=function(t,n){const r=new M;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 u of t){const t=r(u);(o?n(t,f)>0:0===n(t,t))&&(e=u,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 T(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 y(t,g,g,n)},t.groups=function(t,...n){return y(t,Array.from,g,n)},t.histogram=F,t.index=function(t,...n){return y(t,g,v,n)},t.indexes=function(t,...n){return y(t,Array.from,v,n)},t.least=function(t,r=n){let e,o=!1;if(1===r.length){let f;for(const u of t){const t=r(u);(o?n(t,f)<0:0===n(t,t))&&(e=u,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.max=I,t.maxIndex=T,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 O(t,.5,n)},t.merge=function(t){return Array.from(function*(t){for(const n of t)yield*n}(t))},t.min=L,t.minIndex=z,t.pairs=function(t,n=C){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=function(t,n){return Array.from(n,n=>t[n])},t.quantile=O,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,u=Math.floor(f),i=+r(t[u],u,t);return i+(+r(t[u+1],u+1,t)-i)*(f-u)}},t.quickselect=S,t.range=w,t.rollup=function(t,n,...r){return y(t,g,n,r)},t.rollups=function(t,n,...r){return y(t,Array.from,n,r)},t.scan=function(t,n){const r=D(t,n);return r<0?void 0:r},t.shuffle=E,t.shuffler=P,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.thresholdFreedmanDiaconis=function(t,n,r){return Math.ceil((r-n)/(2*(O(t,.75)-O(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=k,t.tickIncrement=_,t.tickStep=q,t.ticks=function(t,n,r){var e,o,f,u,i=-1;if(r=+r,(t=+t)===(n=+n)&&r>0)return[t];if((e=n<t)&&(o=t,t=n,n=o),0===(u=_(t,n,r))||!isFinite(u))return[];if(u>0)for(t=Math.ceil(t/u),n=Math.floor(n/u),f=new Array(o=Math.ceil(n-t+1));++i<o;)f[i]=(t+i)*u;else for(u=-u,t=Math.ceil(t*u),n=Math.floor(n*u),f=new Array(o=Math.ceil(n-t+1));++i<o;)f[i]=(t+i)/u;return e&&f.reverse(),f},t.transpose=R,t.variance=h,t.zip=function(){return R(arguments)},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "d3-array",
"version": "2.6.0",
"version": "2.7.0",
"description": "Array manipulation, ordering, searching, summarizing, etc.",

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

@@ -121,3 +121,3 @@ # d3-array

<a name="quantileSorted" href="#quantileSorted">#</a> d3.<b>quantileSorted</b>(<i>array</i>, <i>p</i>[, <i>accessor</i>]) [Source](https://github.com/d3/d3-array/blob/master/src/quantile.js "Source")
<a name="quantileSorted" href="#quantileSorted">#</a> d3.<b>quantileSorted</b>(<i>array</i>, <i>p</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/master/src/quantile.js), [Examples](https://observablehq.com/@d3/d3-mean-d3-median-and-friends)

@@ -226,2 +226,8 @@ Similar to *quantile*, but expects the input to be a **sorted** *array* of values. In contrast with *quantile*, the accessor is only called on the elements needed to compute the quantile.

<a name="bisectCenter" href="#bisectCenter">#</a> d3.<b>bisectCenter</b>(<i>array</i>, <i>x</i>[, <i>lo</i>[, <i>hi</i>]]) · [Source](https://github.com/d3/d3-array/blob/master/src/bisect.js)
Returns the index of the value closest to *x* in the given *array* of numbers. The arguments *lo* (inclusive) and *hi* (exclusive) may be used to specify a subset of the array which should be considered; by default the entire array is used.
See [*bisector*.center](#bisector_center).
<a name="bisector" href="#bisector">#</a> d3.<b>bisector</b>(<i>accessor</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/bisector.js)

@@ -554,2 +560,13 @@ <br><a name="bisector" href="#bisector">#</a> d3.<b>bisector</b>(<i>comparator</i>)

<a name="shuffler" href="#shuffler">#</a> d3.<b>shuffler</b>(<i>random</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/shuffle.js)
Returns a [shuffle function](#shuffle) given the specified random source. For example, using [d3.randomLcg](https://github.com/d3/d3-random/blob/master/README.md#randomLcg):
```js
const random = d3.randomLcg(0.9051667019185816);
const shuffle = d3.shuffler(random);
shuffle([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]); // returns [7, 4, 5, 3, 9, 0, 6, 1, 2, 8]
```
<a name="ticks" href="#ticks">#</a> d3.<b>ticks</b>(<i>start</i>, <i>stop</i>, <i>count</i>) · [Source](https://github.com/d3/d3-array/blob/master/src/ticks.js), [Examples](https://observablehq.com/@d3/d3-ticks)

@@ -556,0 +573,0 @@

import ascending from "./ascending.js";
import bisector from "./bisector.js";
import number from "./number.js";
var ascendingBisect = bisector(ascending);
export var bisectRight = ascendingBisect.right;
export var bisectLeft = ascendingBisect.left;
const ascendingBisect = bisector(ascending);
export const bisectRight = ascendingBisect.right;
export const bisectLeft = ascendingBisect.left;
export const bisectCenter = bisector(number).center;
export default bisectRight;

@@ -37,3 +37,3 @@ import ascending from "./ascending.js";

if (hi == null) hi = a.length;
const i = left(a, x, lo, hi);
const i = left(a, x, lo, hi - 1);
return i > lo && delta(a[i - 1], x) > -delta(a[i], x) ? i - 1 : i;

@@ -40,0 +40,0 @@ }

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

export {default as bisect, bisectRight, bisectLeft} from "./bisect.js";
export {default as bisect, bisectRight, bisectLeft, bisectCenter} from "./bisect.js";
export {default as ascending} from "./ascending.js";

@@ -33,3 +33,3 @@ export {default as bisector} from "./bisector.js";

export {default as scan} from "./scan.js"; // Deprecated; use leastIndex.
export {default as shuffle} from "./shuffle.js";
export {default as shuffle, shuffler} from "./shuffle.js";
export {default as sum} from "./sum.js";

@@ -36,0 +36,0 @@ export {default as ticks, tickIncrement, tickStep} from "./ticks.js";

@@ -1,14 +0,13 @@

export default function shuffle(array, i0 = 0, i1 = array.length) {
var m = i1 - (i0 = +i0),
t,
i;
export default shuffler(Math.random);
while (m) {
i = Math.random() * m-- | 0;
t = array[m + i0];
array[m + i0] = array[i + i0];
array[i + i0] = t;
}
return array;
export function shuffler(random) {
return function shuffle(array, i0 = 0, i1 = array.length) {
let m = i1 - (i0 = +i0);
while (m) {
const i = random() * m-- | 0, t = array[m + i0];
array[m + i0] = array[i + i0];
array[i + i0] = t;
}
return array;
};
}
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