Socket
Socket
Sign inDemoInstall

d3-array

Package Overview
Dependencies
1
Maintainers
2
Versions
61
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.1.0 to 3.1.1

50

dist/d3-array.js

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

// https://d3js.org/d3-array/ v3.1.0 Copyright 2010-2021 Mike Bostock
// https://d3js.org/d3-array/ v3.1.1 Copyright 2010-2021 Mike Bostock
(function (global, factory) {

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

if (f.length === 1) {
if (f.length !== 2) {
delta = (d, x) => f(d) - x;

@@ -419,3 +419,3 @@ compare1 = ascending;

let [f] = F;
if ((f && f.length === 1) || F.length > 1) {
if ((f && f.length !== 2) || F.length > 1) {
const index = Uint32Array.from(values, (d, i) => i);

@@ -436,6 +436,7 @@ if (F.length > 1) {

}
return values.sort(f === undefined ? ascendingDefined : compareDefined(f));
return values.sort(compareDefined(f));
}
function compareDefined(compare) {
function compareDefined(compare = ascending) {
if (compare === ascending) return ascendingDefined;
if (typeof compare !== "function") throw new TypeError("compare is not a function");

@@ -454,3 +455,3 @@ return (a, b) => {

function groupSort(values, reduce, key) {
return (reduce.length === 1
return (reduce.length !== 2
? sort(rollup(values, reduce, key), (([ak, av], [bk, bv]) => ascending(av, bv) || ascending(ak, bk)))

@@ -895,21 +896,22 @@ : sort(group(values, key), (([ak, av], [bk, bv]) => reduce(av, bv) || ascending(ak, bk))))

function rank(values, valueof) {
function rank(values, valueof = ascending) {
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
values = Array.from(values, valueof);
const n = values.length;
const r = new Float64Array(n);
let last, l;
sort(range(n), (i) => values[i]).forEach((j, i) => {
const value = values[j];
if (value == null || !(value <= value)) {
r[j] = NaN;
return;
}
if (last === undefined || !(value <= last)) {
last = value;
l = i;
}
r[j] = l;
});
return r;
let V = Array.from(values);
const R = new Float64Array(V.length);
if (valueof.length !== 2) V = V.map(valueof), valueof = ascending;
const compareIndex = (i, j) => valueof(V[i], V[j]);
let k, r;
Uint32Array
.from(V, (_, i) => i)
.sort(valueof === ascending ? (i, j) => ascendingDefined(V[i], V[j]) : compareDefined(compareIndex))
.forEach((j, i) => {
const c = compareIndex(j, k === undefined ? j : k);
if (c >= 0) {
if (k === undefined || c > 0) k = j, r = i;
R[j] = r;
} else {
R[j] = NaN;
}
});
return R;
}

@@ -916,0 +918,0 @@

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

// https://d3js.org/d3-array/ v3.1.0 Copyright 2010-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 null==t||null==n?NaN:t<n?-1:t>n?1:t>=n?0:NaN}function r(t){let r=t,e=t,o=t;function f(t,n,r=0,f=t.length){if(r<f){if(0!==e(n,n))return f;do{const e=r+f>>>1;o(t[e],n)<0?r=e+1:f=e}while(r<f)}return r}return 1===t.length&&(r=(n,r)=>t(n)-r,e=n,o=(r,e)=>n(t(r),e)),{left:f,center:function(t,n,e=0,o=t.length){const u=f(t,n,e,o-1);return u>e&&r(t[u-1],n)>-r(t[u],n)?u-1:u},right:function(t,n,r=0,f=t.length){if(r<f){if(0!==e(n,n))return f;do{const e=r+f>>>1;o(t[e],n)<=0?r=e+1:f=e}while(r<f)}return r}}}function e(t){return null===t?NaN:+t}const o=r(n),f=o.right,u=o.left,i=r(e).center;var l=f;function c(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 s(t){return 0|t.length}function a(t){return!(t>0)}function h(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function d(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 p(t,n){const r=d(t,n);return r?Math.sqrt(r):r}function y(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 v{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}}class InternMap extends Map{constructor(t,n=w){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const[n,r]of t)this.set(n,r)}get(t){return super.get(m(this,t))}has(t){return super.has(m(this,t))}set(t,n){return super.set(g(this,t),n)}delete(t){return super.delete(M(this,t))}}class InternSet extends Set{constructor(t,n=w){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const n of t)this.add(n)}has(t){return super.has(m(this,t))}add(t){return super.add(g(this,t))}delete(t){return super.delete(M(this,t))}}function m({_intern:t,_key:n},r){const e=n(r);return t.has(e)?t.get(e):r}function g({_intern:t,_key:n},r){const e=n(r);return t.has(e)?t.get(e):(t.set(e,r),r)}function M({_intern:t,_key:n},r){const e=n(r);return t.has(e)&&(r=t.get(e),t.delete(e)),r}function w(t){return null!==t&&"object"==typeof t?t.valueOf():t}function b(t){return t}function A(t,...n){return E(t,b,b,n)}function x(t,...n){return E(t,Array.from,b,n)}function _(t,n){for(let r=1,e=n.length;r<e;++r)t=t.flatMap((t=>t.pop().map((([n,r])=>[...t,n,r]))));return t}function N(t,n,...r){return E(t,b,n,r)}function S(t,n,...r){return E(t,Array.from,n,r)}function k(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function E(t,n,r,e){return function t(o,f){if(f>=e.length)return r(o);const u=new InternMap,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)}function T(t,n){return Array.from(n,(n=>t[n]))}function j(t,...n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");t=Array.from(t);let[r]=n;if(r&&1===r.length||n.length>1){const e=Uint32Array.from(t,((t,n)=>n));return n.length>1?(n=n.map((n=>t.map(n))),e.sort(((t,r)=>{for(const e of n){const n=q(e[t],e[r]);if(n)return n}}))):(r=t.map(r),e.sort(((t,n)=>q(r[t],r[n])))),T(t,e)}return t.sort(void 0===r?q:F(r))}function F(t){if("function"!=typeof t)throw new TypeError("compare is not a function");return(n,r)=>{const e=t(n,r);return e||0===e?e:(0===t(r,r))-(0===t(n,n))}}function q(t,n){return(null==t||!(t>=t))-(null==n||!(n>=n))||(t<n?-1:t>n?1:0)}var O=Array.prototype.slice;function I(t){return()=>t}var L=Math.sqrt(50),P=Math.sqrt(10),R=Math.sqrt(2);function z(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=C(t,n,r))||!isFinite(u))return[];if(u>0){let r=Math.round(t/u),e=Math.round(n/u);for(r*u<t&&++r,e*u>n&&--e,f=new Array(o=e-r+1);++i<o;)f[i]=(r+i)*u}else{u=-u;let r=Math.round(t*u),e=Math.round(n*u);for(r/u<t&&++r,e/u>n&&--e,f=new Array(o=e-r+1);++i<o;)f[i]=(r+i)/u}return e&&f.reverse(),f}function C(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>=L?10:f>=P?5:f>=R?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=L?10:f>=P?5:f>=R?2:1)}function D(t,n,r){let e;for(;;){const o=C(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 G(t){return Math.ceil(Math.log(c(t))/Math.LN2)+1}function U(){var t=b,n=y,r=G;function e(e){Array.isArray(e)||(e=Array.from(e));var o,f,u=e.length,i=new Array(u);for(o=0;o<u;++o)i[o]=t(e[o],o,e);var c=n(i),s=c[0],a=c[1],h=r(i,s,a);if(!Array.isArray(h)){const t=a,r=+h;if(n===y&&([s,a]=D(s,a,r)),(h=z(s,a,r))[h.length-1]>=a)if(t>=a&&n===y){const t=C(s,a,r);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]<=s;)h.shift(),--d;for(;h[d-1]>a;)h.pop(),--d;var p,v=new Array(d+1);for(o=0;o<=d;++o)(p=v[o]=[]).x0=o>0?h[o-1]:s,p.x1=o<d?h[o]:a;for(o=0;o<u;++o)null!=(f=i[o])&&s<=f&&f<=a&&v[l(h,f,0,d)].push(e[o]);return v}return e.value=function(n){return arguments.length?(t="function"==typeof n?n:I(n),e):t},e.domain=function(t){return arguments.length?(n="function"==typeof t?t:I([t[0],t[1]]),e):n},e.thresholds=function(t){return arguments.length?(r="function"==typeof t?t:Array.isArray(t)?I(O.call(t)):I(t),e):r},e}function B(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 H(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,n,r=0,e=t.length-1,o){for(o=void 0===o?q:F(o);e>r;){if(e-r>600){const f=e-r+1,u=n-r+1,i=Math.log(f),l=.5*Math.exp(2*i/3),c=.5*Math.sqrt(i*l*(f-l)/f)*(u-f/2<0?-1:1);J(t,n,Math.max(r,Math.floor(n-u*l/f+c)),Math.min(e,Math.floor(n+(f-u)*l/f+c)),o)}const f=t[n];let u=r,i=e;for(K(t,r,n),o(t[e],f)>0&&K(t,r,e);u<i;){for(K(t,u,i),++u,--i;o(t[u],f)<0;)++u;for(;o(t[i],f)>0;)--i}0===o(t[r],f)?K(t,r,i):(++i,K(t,i,e)),i<=n&&(r=i+1),n<=i&&(e=i-1)}return t}function K(t,n,r){const e=t[n];t[n]=t[r],t[r]=e}function Q(t,n,r){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,r)),e=t.length){if((n=+n)<=0||e<2)return H(t);if(n>=1)return B(t);var e,o=(e-1)*n,f=Math.floor(o),u=B(J(t,f).subarray(0,f+1));return u+(H(t.subarray(f+1))-u)*(o-f)}}function V(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 W(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 X(t,n){return[t,n]}function Y(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}function Z(t,r=n){if(1===r.length)return W(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 $=tt(Math.random);function tt(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 nt(t){if(!(o=t.length))return[];for(var n=-1,r=H(t,rt),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 rt(t){return t.length}function et(t){return t instanceof InternSet?t:new InternSet(t)}function ot(t,n){const r=t[Symbol.iterator](),e=new Set;for(const t of n){const n=ft(t);if(e.has(n))continue;let o,f;for(;({value:o,done:f}=r.next());){if(f)return!1;const t=ft(o);if(e.add(t),Object.is(n,t))break}}return!0}function ft(t){return null!==t&&"object"==typeof t?t.valueOf():t}t.Adder=v,t.InternMap=InternMap,t.InternSet=InternSet,t.ascending=n,t.bin=U,t.bisect=l,t.bisectCenter=i,t.bisectLeft=u,t.bisectRight=f,t.bisector=r,t.count=c,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),r=(t=t.map(h)).map(s),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 null==t||null==n?NaN:n<t?-1:n>t?1:n>=t?0:NaN},t.deviation=p,t.difference=function(t,...n){t=new InternSet(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 InternSet;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=y,t.fcumsum=function(t,n){const r=new v;let e=-1;return Float64Array.from(t,void 0===n?t=>r.add(+t||0):o=>r.add(+n(o,++e,t)||0))},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.flatGroup=function(t,...n){return _(x(t,...n),n)},t.flatRollup=function(t,n,...r){return _(S(t,n,...r),r)},t.fsum=function(t,n){const r=new v;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 V(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=A,t.groupSort=function(t,r,e){return(1===r.length?j(N(t,r,e),(([t,r],[e,o])=>n(r,o)||n(t,e))):j(A(t,e),(([t,e],[o,f])=>r(e,f)||n(t,o)))).map((([t])=>t))},t.groups=x,t.histogram=U,t.index=function(t,...n){return E(t,b,k,n)},t.indexes=function(t,...n){return E(t,Array.from,k,n)},t.intersection=function(t,...n){t=new InternSet(t),n=n.map(et);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 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=Z,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=B,t.maxIndex=V,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 Q(t,.5,n)},t.merge=function(t){return Array.from(function*(t){for(const n of t)yield*n}(t))},t.min=H,t.minIndex=W,t.mode=function(t,n){const r=new InternMap;if(void 0===n)for(let n of t)null!=n&&n>=n&&r.set(n,(r.get(n)||0)+1);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&o>=o&&r.set(o,(r.get(o)||0)+1)}let e,o=0;for(const[t,n]of r)n>o&&(o=n,e=t);return e},t.nice=D,t.pairs=function(t,n=X){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=T,t.quantile=Q,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=J,t.range=Y,t.rank=function(t,n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");const r=(t=Array.from(t,n)).length,e=new Float64Array(r);let o,f;return j(Y(r),(n=>t[n])).forEach(((n,r)=>{const u=t[n];null!=u&&u<=u?(void 0!==o&&u<=o||(o=u,f=r),e[n]=f):e[n]=NaN})),e},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,u=-1;if(arguments.length<3){if(({done:o,value:r}=e.next()),o)return;++u}for(;({done:o,value:f}=e.next()),!o;)r=n(r,f,++u,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=N,t.rollups=S,t.scan=function(t,n){const r=Z(t,n);return r<0?void 0:r},t.shuffle=$,t.shuffler=tt,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=j,t.subset=function(t,n){return ot(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=ot,t.thresholdFreedmanDiaconis=function(t,n,r){return Math.ceil((r-n)/(2*(Q(t,.75)-Q(t,.25))*Math.pow(c(t),-1/3)))},t.thresholdScott=function(t,n,r){return Math.ceil((r-n)/(3.5*p(t)*Math.pow(c(t),-1/3)))},t.thresholdSturges=G,t.tickIncrement=C,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>=L?o*=10:f>=P?o*=5:f>=R&&(o*=2),n<t?-o:o},t.ticks=z,t.transpose=nt,t.union=function(...t){const n=new InternSet;for(const r of t)for(const t of r)n.add(t);return n},t.variance=d,t.zip=function(){return nt(arguments)},Object.defineProperty(t,"__esModule",{value:!0})}));
// https://d3js.org/d3-array/ v3.1.1 Copyright 2010-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 null==t||null==n?NaN:t<n?-1:t>n?1:t>=n?0:NaN}function r(t){let r=t,e=t,o=t;function f(t,n,r=0,f=t.length){if(r<f){if(0!==e(n,n))return f;do{const e=r+f>>>1;o(t[e],n)<0?r=e+1:f=e}while(r<f)}return r}return 2!==t.length&&(r=(n,r)=>t(n)-r,e=n,o=(r,e)=>n(t(r),e)),{left:f,center:function(t,n,e=0,o=t.length){const i=f(t,n,e,o-1);return i>e&&r(t[i-1],n)>-r(t[i],n)?i-1:i},right:function(t,n,r=0,f=t.length){if(r<f){if(0!==e(n,n))return f;do{const e=r+f>>>1;o(t[e],n)<=0?r=e+1:f=e}while(r<f)}return r}}}function e(t){return null===t?NaN:+t}const o=r(n),f=o.right,i=o.left,u=r(e).center;var l=f;function s(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 h(t){return"object"!=typeof t||"length"in t?t:Array.from(t)}function d(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 p(t,n){const r=d(t,n);return r?Math.sqrt(r):r}function y(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 v{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}}class InternMap extends Map{constructor(t,n=w){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const[n,r]of t)this.set(n,r)}get(t){return super.get(m(this,t))}has(t){return super.has(m(this,t))}set(t,n){return super.set(g(this,t),n)}delete(t){return super.delete(M(this,t))}}class InternSet extends Set{constructor(t,n=w){if(super(),Object.defineProperties(this,{_intern:{value:new Map},_key:{value:n}}),null!=t)for(const n of t)this.add(n)}has(t){return super.has(m(this,t))}add(t){return super.add(g(this,t))}delete(t){return super.delete(M(this,t))}}function m({_intern:t,_key:n},r){const e=n(r);return t.has(e)?t.get(e):r}function g({_intern:t,_key:n},r){const e=n(r);return t.has(e)?t.get(e):(t.set(e,r),r)}function M({_intern:t,_key:n},r){const e=n(r);return t.has(e)&&(r=t.get(e),t.delete(e)),r}function w(t){return null!==t&&"object"==typeof t?t.valueOf():t}function b(t){return t}function A(t,...n){return E(t,b,b,n)}function x(t,...n){return E(t,Array.from,b,n)}function _(t,n){for(let r=1,e=n.length;r<e;++r)t=t.flatMap((t=>t.pop().map((([n,r])=>[...t,n,r]))));return t}function N(t,n,...r){return E(t,b,n,r)}function S(t,n,...r){return E(t,Array.from,n,r)}function k(t){if(1!==t.length)throw new Error("duplicate key");return t[0]}function E(t,n,r,e){return function t(o,f){if(f>=e.length)return r(o);const i=new InternMap,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)}function T(t,n){return Array.from(n,(n=>t[n]))}function j(t,...n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");t=Array.from(t);let[r]=n;if(r&&2!==r.length||n.length>1){const e=Uint32Array.from(t,((t,n)=>n));return n.length>1?(n=n.map((n=>t.map(n))),e.sort(((t,r)=>{for(const e of n){const n=q(e[t],e[r]);if(n)return n}}))):(r=t.map(r),e.sort(((t,n)=>q(r[t],r[n])))),T(t,e)}return t.sort(F(r))}function F(t=n){if(t===n)return q;if("function"!=typeof t)throw new TypeError("compare is not a function");return(n,r)=>{const e=t(n,r);return e||0===e?e:(0===t(r,r))-(0===t(n,n))}}function q(t,n){return(null==t||!(t>=t))-(null==n||!(n>=n))||(t<n?-1:t>n?1:0)}var O=Array.prototype.slice;function I(t){return()=>t}var L=Math.sqrt(50),P=Math.sqrt(10),R=Math.sqrt(2);function U(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=z(t,n,r))||!isFinite(i))return[];if(i>0){let r=Math.round(t/i),e=Math.round(n/i);for(r*i<t&&++r,e*i>n&&--e,f=new Array(o=e-r+1);++u<o;)f[u]=(r+u)*i}else{i=-i;let r=Math.round(t*i),e=Math.round(n*i);for(r/i<t&&++r,e/i>n&&--e,f=new Array(o=e-r+1);++u<o;)f[u]=(r+u)/i}return e&&f.reverse(),f}function z(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>=L?10:f>=P?5:f>=R?2:1)*Math.pow(10,o):-Math.pow(10,-o)/(f>=L?10:f>=P?5:f>=R?2:1)}function C(t,n,r){let e;for(;;){const o=z(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 D(t){return Math.ceil(Math.log(s(t))/Math.LN2)+1}function G(){var t=b,n=y,r=D;function e(e){Array.isArray(e)||(e=Array.from(e));var o,f,i=e.length,u=new Array(i);for(o=0;o<i;++o)u[o]=t(e[o],o,e);var s=n(u),c=s[0],a=s[1],h=r(u,c,a);if(!Array.isArray(h)){const t=a,r=+h;if(n===y&&([c,a]=C(c,a,r)),(h=U(c,a,r))[h.length-1]>=a)if(t>=a&&n===y){const t=z(c,a,r);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 p,v=new Array(d+1);for(o=0;o<=d;++o)(p=v[o]=[]).x0=o>0?h[o-1]:c,p.x1=o<d?h[o]:a;for(o=0;o<i;++o)null!=(f=u[o])&&c<=f&&f<=a&&v[l(h,f,0,d)].push(e[o]);return v}return e.value=function(n){return arguments.length?(t="function"==typeof n?n:I(n),e):t},e.domain=function(t){return arguments.length?(n="function"==typeof t?t:I([t[0],t[1]]),e):n},e.thresholds=function(t){return arguments.length?(r="function"==typeof t?t:Array.isArray(t)?I(O.call(t)):I(t),e):r},e}function B(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 H(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,n,r=0,e=t.length-1,o){for(o=void 0===o?q:F(o);e>r;){if(e-r>600){const f=e-r+1,i=n-r+1,u=Math.log(f),l=.5*Math.exp(2*u/3),s=.5*Math.sqrt(u*l*(f-l)/f)*(i-f/2<0?-1:1);J(t,n,Math.max(r,Math.floor(n-i*l/f+s)),Math.min(e,Math.floor(n+(f-i)*l/f+s)),o)}const f=t[n];let i=r,u=e;for(K(t,r,n),o(t[e],f)>0&&K(t,r,e);i<u;){for(K(t,i,u),++i,--u;o(t[i],f)<0;)++i;for(;o(t[u],f)>0;)--u}0===o(t[r],f)?K(t,r,u):(++u,K(t,u,e)),u<=n&&(r=u+1),n<=u&&(e=u-1)}return t}function K(t,n,r){const e=t[n];t[n]=t[r],t[r]=e}function Q(t,n,r){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,r)),e=t.length){if((n=+n)<=0||e<2)return H(t);if(n>=1)return B(t);var e,o=(e-1)*n,f=Math.floor(o),i=B(J(t,f).subarray(0,f+1));return i+(H(t.subarray(f+1))-i)*(o-f)}}function V(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 W(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 X(t,n){return[t,n]}function Y(t,r=n){if(1===r.length)return W(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 Z=$(Math.random);function $(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 tt(t){if(!(o=t.length))return[];for(var n=-1,r=H(t,nt),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 nt(t){return t.length}function rt(t){return t instanceof InternSet?t:new InternSet(t)}function et(t,n){const r=t[Symbol.iterator](),e=new Set;for(const t of n){const n=ot(t);if(e.has(n))continue;let o,f;for(;({value:o,done:f}=r.next());){if(f)return!1;const t=ot(o);if(e.add(t),Object.is(n,t))break}}return!0}function ot(t){return null!==t&&"object"==typeof t?t.valueOf():t}t.Adder=v,t.InternMap=InternMap,t.InternSet=InternSet,t.ascending=n,t.bin=G,t.bisect=l,t.bisectCenter=u,t.bisectLeft=i,t.bisectRight=f,t.bisector=r,t.count=s,t.cross=function(...t){const n="function"==typeof t[t.length-1]&&function(t){return n=>t(...n)}(t.pop()),r=(t=t.map(h)).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 null==t||null==n?NaN:n<t?-1:n>t?1:n>=t?0:NaN},t.deviation=p,t.difference=function(t,...n){t=new InternSet(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 InternSet;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=y,t.fcumsum=function(t,n){const r=new v;let e=-1;return Float64Array.from(t,void 0===n?t=>r.add(+t||0):o=>r.add(+n(o,++e,t)||0))},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.flatGroup=function(t,...n){return _(x(t,...n),n)},t.flatRollup=function(t,n,...r){return _(S(t,n,...r),r)},t.fsum=function(t,n){const r=new v;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 V(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=A,t.groupSort=function(t,r,e){return(2!==r.length?j(N(t,r,e),(([t,r],[e,o])=>n(r,o)||n(t,e))):j(A(t,e),(([t,e],[o,f])=>r(e,f)||n(t,o)))).map((([t])=>t))},t.groups=x,t.histogram=G,t.index=function(t,...n){return E(t,b,k,n)},t.indexes=function(t,...n){return E(t,Array.from,k,n)},t.intersection=function(t,...n){t=new InternSet(t),n=n.map(rt);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=Y,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=B,t.maxIndex=V,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 Q(t,.5,n)},t.merge=function(t){return Array.from(function*(t){for(const n of t)yield*n}(t))},t.min=H,t.minIndex=W,t.mode=function(t,n){const r=new InternMap;if(void 0===n)for(let n of t)null!=n&&n>=n&&r.set(n,(r.get(n)||0)+1);else{let e=-1;for(let o of t)null!=(o=n(o,++e,t))&&o>=o&&r.set(o,(r.get(o)||0)+1)}let e,o=0;for(const[t,n]of r)n>o&&(o=n,e=t);return e},t.nice=C,t.pairs=function(t,n=X){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=T,t.quantile=Q,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.rank=function(t,r=n){if("function"!=typeof t[Symbol.iterator])throw new TypeError("values is not iterable");let e=Array.from(t);const o=new Float64Array(e.length);2!==r.length&&(e=e.map(r),r=n);const f=(t,n)=>r(e[t],e[n]);let i,u;return Uint32Array.from(e,((t,n)=>n)).sort(r===n?(t,n)=>q(e[t],e[n]):F(f)).forEach(((t,n)=>{const r=f(t,void 0===i?t:i);r>=0?((void 0===i||r>0)&&(i=t,u=n),o[t]=u):o[t]=NaN})),o},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=N,t.rollups=S,t.scan=function(t,n){const r=Y(t,n);return r<0?void 0:r},t.shuffle=Z,t.shuffler=$,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=j,t.subset=function(t,n){return et(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=et,t.thresholdFreedmanDiaconis=function(t,n,r){return Math.ceil((r-n)/(2*(Q(t,.75)-Q(t,.25))*Math.pow(s(t),-1/3)))},t.thresholdScott=function(t,n,r){return Math.ceil((r-n)/(3.5*p(t)*Math.pow(s(t),-1/3)))},t.thresholdSturges=D,t.tickIncrement=z,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>=L?o*=10:f>=P?o*=5:f>=R&&(o*=2),n<t?-o:o},t.ticks=U,t.transpose=tt,t.union=function(...t){const n=new InternSet;for(const r of t)for(const t of r)n.add(t);return n},t.variance=d,t.zip=function(){return tt(arguments)},Object.defineProperty(t,"__esModule",{value:!0})}));
{
"name": "d3-array",
"version": "3.1.0",
"version": "3.1.1",
"description": "Array manipulation, ordering, searching, summarizing, etc.",

@@ -5,0 +5,0 @@ "homepage": "https://d3js.org/d3-array/",

@@ -144,6 +144,6 @@ # d3-array

<a name="rank" href="#rank">#</a> d3.<b>rank</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/main/src/rank.js), [Examp
les](https://observablehq.com/@d3/rank)
<a name="rank" href="#rank">#</a> d3.<b>rank</b>(<i>iterable</i>[, <i>comparator</i>]) · [Source](https://github.com/d3/d3-array/blob/main/src/rank.js), [Examples](https://observablehq.com/@d3/rank)
<br><a name="rank" href="#rank">#</a> d3.<b>rank</b>(<i>iterable</i>[, <i>accessor</i>])
Returns an array with the rank of each value in the *iterable*, *i.e.* the index of the value when the iterable is sorted. Nullish values are sorted to the end and ranked NaN. An optional *accessor* function may be specified, which is equivalent to calling *array*.map(*accessor*) before computing the ranks. Ties (equivalent values) all get the same rank, defined as the first time the value is found.
Returns an array with the rank of each value in the *iterable*, *i.e.* the zero-based index of the value when the iterable is sorted. Nullish values are sorted to the end and ranked NaN. An optional *comparator* or *accessor* function may be specified; the latter is equivalent to calling *array*.map(*accessor*) before computing the ranks. If *comparator* is not specified, it defaults to [ascending](#ascending). Ties (equivalent values) all get the same rank, defined as the first time the value is found.

@@ -153,2 +153,3 @@ ```js

d3.rank(["b", "c", "b", "a"]); // [1, 3, 1, 0]
d3.rank([1, 2, 3], d3.descending); // [2, 1, 0]
```

@@ -547,3 +548,3 @@

If a *comparator* is passed instead of an *accessor* (i.e., if the second argument is a function that takes two arguments), it will be asked to compare two groups *a* and *b* and should return a negative value if *a* should be before *b*, a positive value if *a* should be after *b*, or zero for a partial ordering.
If a *comparator* is passed instead of an *accessor* (i.e., if the second argument is a function that takes exactly two arguments), it will be asked to compare two groups *a* and *b* and should return a negative value if *a* should be before *b*, a positive value if *a* should be after *b*, or zero for a partial ordering.

@@ -749,3 +750,3 @@ <a name="count" href="#count">#</a> d3.<b>count</b>(<i>iterable</i>[, <i>accessor</i>]) · [Source](https://github.com/d3/d3-array/blob/main/src/count.js), [Examples](https://observablehq.com/@d3/d3-count)

If an *accessor* (a function that takes a single argument) is specified,
If an *accessor* (a function that does not take exactly two arguments) is specified,

@@ -752,0 +753,0 @@ ```js

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

if (f.length === 1) {
if (f.length !== 2) {
delta = (d, x) => f(d) - x;

@@ -11,0 +11,0 @@ compare1 = ascending;

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

export default function groupSort(values, reduce, key) {
return (reduce.length === 1
return (reduce.length !== 2
? sort(rollup(values, reduce, key), (([ak, av], [bk, bv]) => ascending(av, bv) || ascending(ak, bk)))

@@ -9,0 +9,0 @@ : sort(group(values, key), (([ak, av], [bk, bv]) => reduce(av, bv) || ascending(ak, bk))))

@@ -1,23 +0,24 @@

import range from "./range.js";
import sort from "./sort.js";
import ascending from "./ascending.js";
import {ascendingDefined, compareDefined} from "./sort.js";
export default function rank(values, valueof) {
export default function rank(values, valueof = ascending) {
if (typeof values[Symbol.iterator] !== "function") throw new TypeError("values is not iterable");
values = Array.from(values, valueof);
const n = values.length;
const r = new Float64Array(n);
let last, l;
sort(range(n), (i) => values[i]).forEach((j, i) => {
const value = values[j];
if (value == null || !(value <= value)) {
r[j] = NaN;
return;
}
if (last === undefined || !(value <= last)) {
last = value;
l = i;
}
r[j] = l;
});
return r;
let V = Array.from(values);
const R = new Float64Array(V.length);
if (valueof.length !== 2) V = V.map(valueof), valueof = ascending;
const compareIndex = (i, j) => valueof(V[i], V[j]);
let k, r;
Uint32Array
.from(V, (_, i) => i)
.sort(valueof === ascending ? (i, j) => ascendingDefined(V[i], V[j]) : compareDefined(compareIndex))
.forEach((j, i) => {
const c = compareIndex(j, k === undefined ? j : k);
if (c >= 0) {
if (k === undefined || c > 0) k = j, r = i;
R[j] = r;
} else {
R[j] = NaN;
}
});
return R;
}

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

import ascending from "./ascending.js";
import permute from "./permute.js";

@@ -7,3 +8,3 @@

let [f] = F;
if ((f && f.length === 1) || F.length > 1) {
if ((f && f.length !== 2) || F.length > 1) {
const index = Uint32Array.from(values, (d, i) => i);

@@ -24,6 +25,7 @@ if (F.length > 1) {

}
return values.sort(f === undefined ? ascendingDefined : compareDefined(f));
return values.sort(compareDefined(f));
}
export function compareDefined(compare) {
export function compareDefined(compare = ascending) {
if (compare === ascending) return ascendingDefined;
if (typeof compare !== "function") throw new TypeError("compare is not a function");

@@ -30,0 +32,0 @@ return (a, b) => {

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