Socket
Socket
Sign inDemoInstall

d3-array

Package Overview
Dependencies
0
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.0.1

3

.eslintrc.json

@@ -13,4 +13,5 @@ {

"rules": {
"no-cond-assign": 0
"no-cond-assign": 0,
"no-constant-condition": 0
}
}

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

// https://d3js.org/d3-array/ v2.0.0 Copyright 2018 Mike Bostock
// https://d3js.org/d3-array/ v2.0.1 Copyright 2018 Mike Bostock
(function (global, factory) {

@@ -48,16 +48,10 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :

function* product(head, ...tail) {
if (tail.length) {
for (const h of head) {
for (const t of product(...tail)) {
yield [h, ...t];
}
}
} else {
for (const h of head) {
yield [h];
}
}
function length(array) {
return array.length;
}
function arrayify(values) {
return typeof values !== "object" || "length" in values ? values : Array.from(values);
}
function reducer(reduce) {

@@ -68,4 +62,16 @@ return values => reduce(...values);

function cross(...values) {
const reduce = typeof values[values.length - 1] === "function" ? reducer(values.pop()) : undefined;
return Array.from(product(...values), reduce);
const reduce = typeof values[values.length - 1] === "function" && reducer(values.pop());
values = values.map(arrayify);
const lengths = values.map(length);
const j = values.length - 1;
const index = new Array(j + 1).fill(0);
const product = [];
while (true) {
product.push(index.map((j, i) => values[i][j]));
let i = j;
while (++index[i] === lengths[i]) {
if (i === 0) return reduce ? product.map(reduce) : product;
index[i--] = 0;
}
}
}

@@ -554,3 +560,3 @@

if (!(n = matrix.length)) return [];
for (var i = -1, m = min(matrix, length), transpose = new Array(m); ++i < m;) {
for (var i = -1, m = min(matrix, length$1), transpose = new Array(m); ++i < m;) {
for (var j = -1, n, row = transpose[i] = new Array(n); ++j < n;) {

@@ -563,3 +569,3 @@ row[j] = matrix[j][i];

function length(d) {
function length$1(d) {
return d.length;

@@ -566,0 +572,0 @@ }

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

// https://d3js.org/d3-array/ v2.0.0 Copyright 2018 Mike Bostock
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.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){var r;return 1===t.length&&(r=t,t=function(t,e){return n(r(t),e)}),{left:function(n,r,e,o){for(null==e&&(e=0),null==o&&(o=n.length);e<o;){var f=e+o>>>1;t(n[f],r)<0?e=f+1:o=f}return e},right:function(n,r,e,o){for(null==e&&(e=0),null==o&&(o=n.length);e<o;){var f=e+o>>>1;t(n[f],r)>0?o=f:e=f+1}return e}}}var e=r(n),o=e.right,f=e.left;function i(t,n){let r,e=0,o=0,f=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(f+=(r=n-o)*(n-(o+=r/++e)));else{let i=-1;for(let u of t)null!=(u=n(u,++i,t))&&(u=+u)>=u&&(f+=(r=u-o)*(u-(o+=r/++e)))}if(e>1)return f/(e-1)}function u(t,n){const r=i(t,n);return r?Math.sqrt(r):r}function l(t,n){let r,e;if(void 0===n)for(let n of t)null!=n&&n>=n&&(void 0===r?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))&&f>=f&&(void 0===r?r=e=f:(r>f&&(r=f),e<f&&(e=f)))}return[r,e]}function a(t){return t}function c(t,n,...r){return function t(e,o){if(o>=r.length)return n(e);const f=function(t,n){const r=new Map;let e=-1;for(const o of t){const f=n(o,++e,t),i=r.get(f);i?i.push(o):r.set(f,[o])}return r}(e,r[o]);return new Map(Array.from(f,([n,r])=>[n,t(r,o+1)]))}(t,0)}var h=Array.prototype,s=h.slice,M=h.map;function d(t){return function(){return t}}function v(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 g=Math.sqrt(50),p=Math.sqrt(10),y=Math.sqrt(2);function m(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>=g?10:f>=p?5:f>=y?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=g?10:f>=p?5:f>=y?2:1)}function A(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>=g?o*=10:f>=p?o*=5:f>=y&&(o*=2),n<t?-o:o}function w(t){return Math.ceil(Math.log(t.length)/Math.LN2)+1}function x(t){return null===t?NaN:+t}function N(t,n,r=x){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),i=+r(t[f],f,t);return i+(+r(t[f+1],f+1,t)-i)*(o-f)}}function b(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),a=.5*Math.sqrt(u*l*(n-l)/n)*(i-n/2<0?-1:1);b(t,r,Math.max(e,Math.floor(r-i*l/n+a)),Math.min(o,Math.floor(r+(n-i)*l/n+a)),f)}const n=t[r];let i=e,u=o;for(q(t,e,r),f(t[o],n)>0&&q(t,e,o);i<u;){for(q(t,i,u),++i,--u;f(t[i],n)<0;)++i;for(;f(t[u],n)>0;)--u}0===f(t[e],n)?q(t,e,u):q(t,++u,o),u<=r&&(e=u+1),r<=u&&(o=u-1)}return t}function q(t,n,r){const e=t[n];t[n]=t[r],t[r]=e}function k(t,n){let r;if(void 0===n)for(let n of t)null!=n&&n>=n&&(void 0===r||r>n)&&(r=n);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&o>=o&&(void 0===r||r>o)&&(r=o)}return r}function L(t){if(!(o=t.length))return[];for(var n=-1,r=k(t,F),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 F(t){return t.length}t.bisect=o,t.bisectRight=o,t.bisectLeft=f,t.ascending=n,t.bisector=r,t.cross=function(...t){const n="function"==typeof t[t.length-1]?function(t){return n=>t(...n)}(t.pop()):void 0;return Array.from(function*t(n,...r){if(r.length)for(const e of n)for(const n of t(...r))yield[e,...n];else for(const t of n)yield[t]}(...t),n)},t.descending=function(t,n){return n<t?-1:n>t?1:n>=t?0:NaN},t.deviation=u,t.extent=l,t.group=function(t,...n){return c(t,a,...n)},t.histogram=function(){var t=a,n=l,r=w;function e(e){var f,i,u=e.length,l=Array.from(e,t),a=n(l),c=a[0],h=a[1],s=r(l,c,h);Array.isArray(s)||(s=A(c,h,s),s=v(Math.ceil(c/s)*s,h,s));for(var M=s.length;s[0]<=c;)s.shift(),--M;for(;s[M-1]>h;)s.pop(),--M;var d,g=new Array(M+1);for(f=0;f<=M;++f)(d=g[f]=[]).x0=f>0?s[f-1]:c,d.x1=f<M?s[f]:h;for(f=0;f<u;++f)c<=(i=l[f])&&i<=h&&g[o(s,i,0,M)].push(e[f]);return g}return e.value=function(n){return arguments.length?(t="function"==typeof n?n:d(n),e):t},e.domain=function(t){return arguments.length?(n="function"==typeof t?t:d([t[0],t[1]]),e):n},e.thresholds=function(t){return arguments.length?(r="function"==typeof t?t:Array.isArray(t)?d(s.call(t)):d(t),e):r},e},t.thresholdFreedmanDiaconis=function(t,r,e){return t=M.call(t,x).sort(n),Math.ceil((e-r)/(2*(N(t,.75)-N(t,.25))*Math.pow(t.length,-1/3)))},t.thresholdScott=function(t,n,r){return Math.ceil((r-n)/(3.5*u(t)*Math.pow(t.length,-1/3)))},t.thresholdSturges=w,t.max=function(t,n){let r;if(void 0===n)for(let n of t)null!=n&&n>=n&&(void 0===r||r<n)&&(r=n);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&o>=o&&(void 0===r||r<o)&&(r=o)}return r},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){if(!(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,n))).length)return;const r=t.length,e=r>>1;return b(t,e-1,0),0==(1&r)&&b(t,e,e),N(t,.5)},t.merge=function(t){return Array.from(function*(t){for(const n of t)yield*n}(t))},t.min=k,t.pairs=function(t,n=function(t,n){return[t,n]}){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){for(var r=n.length,e=new Array(r);r--;)e[r]=t[n[r]];return e},t.quantile=N,t.quickselect=b,t.range=v,t.rollup=c,t.scan=function(t,r=n){let e,o,f=-1;for(const n of t)++f,(void 0===o?0===r(n,n):r(n,e)<0)&&(e=n,o=f);return o},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.ticks=function(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=m(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(t=Math.floor(t*i),n=Math.ceil(n*i),f=new Array(o=Math.ceil(t-n+1));++u<o;)f[u]=(t-u)/i;return e&&f.reverse(),f},t.tickIncrement=m,t.tickStep=A,t.transpose=L,t.variance=i,t.zip=function(){return L(arguments)},Object.defineProperty(t,"__esModule",{value:!0})});
// https://d3js.org/d3-array/ v2.0.1 Copyright 2018 Mike Bostock
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.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){var r;return 1===t.length&&(r=t,t=function(t,e){return n(r(t),e)}),{left:function(n,r,e,o){for(null==e&&(e=0),null==o&&(o=n.length);e<o;){var f=e+o>>>1;t(n[f],r)<0?e=f+1:o=f}return e},right:function(n,r,e,o){for(null==e&&(e=0),null==o&&(o=n.length);e<o;){var f=e+o>>>1;t(n[f],r)>0?o=f:e=f+1}return e}}}var e=r(n),o=e.right,f=e.left;function u(t){return t.length}function i(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function l(t,n){let r,e=0,o=0,f=0;if(void 0===n)for(let n of t)null!=n&&(n=+n)>=n&&(f+=(r=n-o)*(n-(o+=r/++e)));else{let u=-1;for(let i of t)null!=(i=n(i,++u,t))&&(i=+i)>=i&&(f+=(r=i-o)*(i-(o+=r/++e)))}if(e>1)return f/(e-1)}function a(t,n){const r=l(t,n);return r?Math.sqrt(r):r}function c(t,n){let r,e;if(void 0===n)for(let n of t)null!=n&&n>=n&&(void 0===r?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))&&f>=f&&(void 0===r?r=e=f:(r>f&&(r=f),e<f&&(e=f)))}return[r,e]}function h(t){return t}function s(t,n,...r){return function t(e,o){if(o>=r.length)return n(e);const f=function(t,n){const r=new Map;let e=-1;for(const o of t){const f=n(o,++e,t),u=r.get(f);u?u.push(o):r.set(f,[o])}return r}(e,r[o]);return new Map(Array.from(f,([n,r])=>[n,t(r,o+1)]))}(t,0)}var M=Array.prototype,p=M.slice,d=M.map;function g(t){return function(){return t}}function v(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 y=Math.sqrt(50),m=Math.sqrt(10),A=Math.sqrt(2);function w(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>=y?10:f>=m?5:f>=A?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=y?10:f>=m?5:f>=A?2:1)}function x(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>=y?o*=10:f>=m?o*=5:f>=A&&(o*=2),n<t?-o:o}function N(t){return Math.ceil(Math.log(t.length)/Math.LN2)+1}function b(t){return null===t?NaN:+t}function q(t,n,r=b){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)}}function k(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);k(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):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 j(t,n){let r;if(void 0===n)for(let n of t)null!=n&&n>=n&&(void 0===r||r>n)&&(r=n);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&o>=o&&(void 0===r||r>o)&&(r=o)}return r}function F(t){if(!(o=t.length))return[];for(var n=-1,r=j(t,S),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 S(t){return t.length}t.bisect=o,t.bisectRight=o,t.bisectLeft=f,t.ascending=n,t.bisector=r,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),r=(t=t.map(i)).map(u),e=t.length-1,o=new Array(e+1).fill(0),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.descending=function(t,n){return n<t?-1:n>t?1:n>=t?0:NaN},t.deviation=a,t.extent=c,t.group=function(t,...n){return s(t,h,...n)},t.histogram=function(){var t=h,n=c,r=N;function e(e){var f,u,i=e.length,l=Array.from(e,t),a=n(l),c=a[0],h=a[1],s=r(l,c,h);Array.isArray(s)||(s=x(c,h,s),s=v(Math.ceil(c/s)*s,h,s));for(var M=s.length;s[0]<=c;)s.shift(),--M;for(;s[M-1]>h;)s.pop(),--M;var p,d=new Array(M+1);for(f=0;f<=M;++f)(p=d[f]=[]).x0=f>0?s[f-1]:c,p.x1=f<M?s[f]:h;for(f=0;f<i;++f)c<=(u=l[f])&&u<=h&&d[o(s,u,0,M)].push(e[f]);return d}return e.value=function(n){return arguments.length?(t="function"==typeof n?n:g(n),e):t},e.domain=function(t){return arguments.length?(n="function"==typeof t?t:g([t[0],t[1]]),e):n},e.thresholds=function(t){return arguments.length?(r="function"==typeof t?t:Array.isArray(t)?g(p.call(t)):g(t),e):r},e},t.thresholdFreedmanDiaconis=function(t,r,e){return t=d.call(t,b).sort(n),Math.ceil((e-r)/(2*(q(t,.75)-q(t,.25))*Math.pow(t.length,-1/3)))},t.thresholdScott=function(t,n,r){return Math.ceil((r-n)/(3.5*a(t)*Math.pow(t.length,-1/3)))},t.thresholdSturges=N,t.max=function(t,n){let r;if(void 0===n)for(let n of t)null!=n&&n>=n&&(void 0===r||r<n)&&(r=n);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&o>=o&&(void 0===r||r<o)&&(r=o)}return r},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){if(!(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,n))).length)return;const r=t.length,e=r>>1;return k(t,e-1,0),0==(1&r)&&k(t,e,e),q(t,.5)},t.merge=function(t){return Array.from(function*(t){for(const n of t)yield*n}(t))},t.min=j,t.pairs=function(t,n=function(t,n){return[t,n]}){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){for(var r=n.length,e=new Array(r);r--;)e[r]=t[n[r]];return e},t.quantile=q,t.quickselect=k,t.range=v,t.rollup=s,t.scan=function(t,r=n){let e,o,f=-1;for(const n of t)++f,(void 0===o?0===r(n,n):r(n,e)<0)&&(e=n,o=f);return o},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.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=w(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(t=Math.floor(t*u),n=Math.ceil(n*u),f=new Array(o=Math.ceil(t-n+1));++i<o;)f[i]=(t-i)/u;return e&&f.reverse(),f},t.tickIncrement=w,t.tickStep=x,t.transpose=F,t.variance=l,t.zip=function(){return F(arguments)},Object.defineProperty(t,"__esModule",{value:!0})});
{
"name": "d3-array",
"version": "2.0.0",
"version": "2.0.1",
"description": "Array manipulation, ordering, searching, summarizing, etc.",

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

@@ -1,15 +0,9 @@

function* product(head, ...tail) {
if (tail.length) {
for (const h of head) {
for (const t of product(...tail)) {
yield [h, ...t];
}
}
} else {
for (const h of head) {
yield [h];
}
}
function length(array) {
return array.length;
}
function arrayify(values) {
return typeof values !== "object" || "length" in values ? values : Array.from(values);
}
function reducer(reduce) {

@@ -20,4 +14,16 @@ return values => reduce(...values);

export default function cross(...values) {
const reduce = typeof values[values.length - 1] === "function" ? reducer(values.pop()) : undefined;
return Array.from(product(...values), reduce);
const reduce = typeof values[values.length - 1] === "function" && reducer(values.pop());
values = values.map(arrayify);
const lengths = values.map(length);
const j = values.length - 1;
const index = new Array(j + 1).fill(0);
const product = [];
while (true) {
product.push(index.map((j, i) => values[i][j]));
let i = j;
while (++index[i] === lengths[i]) {
if (i === 0) return reduce ? product.map(reduce) : product;
index[i--] = 0;
}
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc