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

@tidyjs/tidy

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tidyjs/tidy - npm Package Compare versions

Comparing version 2.3.1 to 2.4.0

6

dist/es/arrange.js

@@ -19,9 +19,11 @@ import { ascending } from 'd3-array';

function asc(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return function _asc(a, b) {
return emptyAwareComparator(a[key], b[key], false);
return emptyAwareComparator(keyFn(a), keyFn(b), false);
};
}
function desc(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return function _desc(a, b) {
return emptyAwareComparator(a[key], b[key], true);
return emptyAwareComparator(keyFn(a), keyFn(b), true);
};

@@ -28,0 +30,0 @@ }

@@ -9,2 +9,7 @@ import { group } from 'd3-array';

function groupBy(groupKeys, fns, options) {
if (typeof fns === "function") {
fns = [fns];
} else if (arguments.length === 2 && fns != null && !Array.isArray(fns)) {
options = fns;
}
const _groupBy = (items) => {

@@ -17,9 +22,4 @@ const grouped = makeGrouped(items, groupKeys);

return results;
case "entries":
return exportLevels(results, {
...options,
export: "levels",
levels: ["entries"]
});
case "entries-object":
case "levels":
return exportLevels(results, options);
case "entries-obj":

@@ -32,28 +32,8 @@ case "entriesObject":

});
case "object":
default:
return exportLevels(results, {
...options,
export: "levels",
levels: ["object"]
levels: [options.export]
});
case "map":
return exportLevels(results, {
...options,
export: "levels",
levels: ["map"]
});
case "keys":
return exportLevels(results, {
...options,
export: "levels",
levels: ["keys"]
});
case "values":
return exportLevels(results, {
...options,
export: "levels",
levels: ["values"]
});
case "levels":
return exportLevels(results, options);
}

@@ -79,2 +59,4 @@ }

for (const fn of fns) {
if (!fn)
continue;
result = groupMap(result, (items2, keys) => {

@@ -93,8 +75,2 @@ const context = {groupKeys: keys};

const groupKeyFns = singleOrArray(groupKeys).map((key, i) => {
let keyName;
if (typeof key === "function") {
keyName = key.name ? key.name : `group_${i}`;
} else {
keyName = key.toString();
}
const keyFn = typeof key === "function" ? key : (d) => d[key];

@@ -107,3 +83,3 @@ const keyCache = new Map();

}
const keyWithName = [keyName, keyValue];
const keyWithName = [key, keyValue];
keyCache.set(keyValue, keyWithName);

@@ -246,3 +222,3 @@ return keyWithName;

export { groupBy, makeGrouped, processFromGroupsOptions };
export { groupBy };
//# sourceMappingURL=groupBy.js.map
function assignGroupKeys(d, keys) {
return {
...d,
...keys.reduce((accum, key) => (accum[key[0]] = key[1], accum), {})
};
if (d == null || typeof d !== "object" || Array.isArray(d))
return d;
const keysObj = Object.fromEntries(keys.filter((key) => typeof key[0] !== "function"));
return Object.assign(keysObj, d);
}

@@ -7,0 +7,0 @@

@@ -23,9 +23,11 @@ 'use strict';

function asc(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return function _asc(a, b) {
return emptyAwareComparator(a[key], b[key], false);
return emptyAwareComparator(keyFn(a), keyFn(b), false);
};
}
function desc(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return function _desc(a, b) {
return emptyAwareComparator(a[key], b[key], true);
return emptyAwareComparator(keyFn(a), keyFn(b), true);
};

@@ -32,0 +34,0 @@ }

@@ -13,2 +13,7 @@ 'use strict';

function groupBy(groupKeys, fns, options) {
if (typeof fns === "function") {
fns = [fns];
} else if (arguments.length === 2 && fns != null && !Array.isArray(fns)) {
options = fns;
}
const _groupBy = (items) => {

@@ -21,9 +26,4 @@ const grouped = makeGrouped(items, groupKeys);

return results;
case "entries":
return exportLevels(results, {
...options,
export: "levels",
levels: ["entries"]
});
case "entries-object":
case "levels":
return exportLevels(results, options);
case "entries-obj":

@@ -36,28 +36,8 @@ case "entriesObject":

});
case "object":
default:
return exportLevels(results, {
...options,
export: "levels",
levels: ["object"]
levels: [options.export]
});
case "map":
return exportLevels(results, {
...options,
export: "levels",
levels: ["map"]
});
case "keys":
return exportLevels(results, {
...options,
export: "levels",
levels: ["keys"]
});
case "values":
return exportLevels(results, {
...options,
export: "levels",
levels: ["values"]
});
case "levels":
return exportLevels(results, options);
}

@@ -83,2 +63,4 @@ }

for (const fn of fns) {
if (!fn)
continue;
result = groupMap.groupMap(result, (items2, keys) => {

@@ -97,8 +79,2 @@ const context = {groupKeys: keys};

const groupKeyFns = singleOrArray.singleOrArray(groupKeys).map((key, i) => {
let keyName;
if (typeof key === "function") {
keyName = key.name ? key.name : `group_${i}`;
} else {
keyName = key.toString();
}
const keyFn = typeof key === "function" ? key : (d) => d[key];

@@ -111,3 +87,3 @@ const keyCache = new Map();

}
const keyWithName = [keyName, keyValue];
const keyWithName = [key, keyValue];
keyCache.set(keyValue, keyWithName);

@@ -251,4 +227,2 @@ return keyWithName;

exports.groupBy = groupBy;
exports.makeGrouped = makeGrouped;
exports.processFromGroupsOptions = processFromGroupsOptions;
//# sourceMappingURL=groupBy.js.map

@@ -6,6 +6,6 @@ 'use strict';

function assignGroupKeys(d, keys) {
return {
...d,
...keys.reduce((accum, key) => (accum[key[0]] = key[1], accum), {})
};
if (d == null || typeof d !== "object" || Array.isArray(d))
return d;
const keysObj = Object.fromEntries(keys.filter((key) => typeof key[0] !== "function"));
return Object.assign(keysObj, d);
}

@@ -12,0 +12,0 @@

@@ -100,9 +100,11 @@ (function (global, factory) {

function asc(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return function _asc(a, b) {
return emptyAwareComparator(a[key], b[key], false);
return emptyAwareComparator(keyFn(a), keyFn(b), false);
};
}
function desc(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
return function _desc(a, b) {
return emptyAwareComparator(a[key], b[key], true);
return emptyAwareComparator(keyFn(a), keyFn(b), true);
};

@@ -268,6 +270,6 @@ }

function assignGroupKeys(d, keys) {
return {
...d,
...keys.reduce((accum, key) => (accum[key[0]] = key[1], accum), {})
};
if (d == null || typeof d !== "object" || Array.isArray(d))
return d;
const keysObj = Object.fromEntries(keys.filter((key) => typeof key[0] !== "function"));
return Object.assign(keysObj, d);
}

@@ -305,2 +307,7 @@

function groupBy(groupKeys, fns, options) {
if (typeof fns === "function") {
fns = [fns];
} else if (arguments.length === 2 && fns != null && !Array.isArray(fns)) {
options = fns;
}
const _groupBy = (items) => {

@@ -313,9 +320,4 @@ const grouped = makeGrouped(items, groupKeys);

return results;
case "entries":
return exportLevels(results, {
...options,
export: "levels",
levels: ["entries"]
});
case "entries-object":
case "levels":
return exportLevels(results, options);
case "entries-obj":

@@ -328,28 +330,8 @@ case "entriesObject":

});
case "object":
default:
return exportLevels(results, {
...options,
export: "levels",
levels: ["object"]
levels: [options.export]
});
case "map":
return exportLevels(results, {
...options,
export: "levels",
levels: ["map"]
});
case "keys":
return exportLevels(results, {
...options,
export: "levels",
levels: ["keys"]
});
case "values":
return exportLevels(results, {
...options,
export: "levels",
levels: ["values"]
});
case "levels":
return exportLevels(results, options);
}

@@ -375,2 +357,4 @@ }

for (const fn of fns) {
if (!fn)
continue;
result = groupMap(result, (items2, keys) => {

@@ -389,8 +373,2 @@ const context = {groupKeys: keys};

const groupKeyFns = singleOrArray(groupKeys).map((key, i) => {
let keyName;
if (typeof key === "function") {
keyName = key.name ? key.name : `group_${i}`;
} else {
keyName = key.toString();
}
const keyFn = typeof key === "function" ? key : (d) => d[key];

@@ -403,3 +381,3 @@ const keyCache = new Map();

}
const keyWithName = [keyName, keyValue];
const keyWithName = [key, keyValue];
keyCache.set(keyValue, keyWithName);

@@ -406,0 +384,0 @@ return keyWithName;

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

(function(l,h){typeof exports=="object"&&typeof module!="undefined"?h(exports,require("d3-array")):typeof define=="function"&&define.amd?define(["exports","d3-array"],h):(l=typeof globalThis!="undefined"?globalThis:l||self,h(l.Tidy={},l.d3))})(this,function(l,h){"use strict";function z(n,...t){if(typeof n=="function")throw new Error("You must supply the data as the first argument to tidy()");let e=n;for(const u of t)u&&(e=u(e));return e}function sn(n){return e=>e.filter(n)}function ln(n,t){return u=>{if(typeof n=="function"){if(!n(u))return u}else if(!n)return u;return z(u,...t)}}function fn(n){return e=>e.map(n)}function S(n){return n==null?[]:Array.isArray(n)?n:[n]}function an(n){return e=>{if(n=S(n),!n.length){const r=new Set;for(const s of e)r.add(s);return Array.from(r)}const u=new Map,o=[],c=n[n.length-1];for(const r of e){let s=u,f=!1;for(const a of n){const i=typeof a=="function"?a(r):r[a];if(a===c){f=s.has(i),f||(o.push(r),s.set(i,!0));break}s.has(i)||s.set(i,new Map),s=s.get(i)}}return o}}function w(n){return e=>{const u=S(n).map(o=>typeof o=="function"?o:G(o));return e.slice().sort((o,c)=>{for(const r of u){const s=r(o,c);if(s)return s}return 0})}}function G(n){return function(e,u){return H(e[n],u[n],!1)}}function L(n){return function(e,u){return H(e[n],u[n],!0)}}function mn(n,t,e){let{position:u="start"}=e!=null?e:{};const o=u==="end"?-1:1,c=new Map;for(let s=0;s<t.length;++s)c.set(t[s],s);const r=typeof n=="function"?n:s=>s[n];return function(f,a){var i,m;const d=(i=c.get(r(f)))!=null?i:-1,y=(m=c.get(r(a)))!=null?m:-1;return d>=0&&y>=0?d-y:d>=0?o*-1:y>=0?o*1:0}}function H(n,t,e){let u=e?t:n,o=e?n:t;if($(u)&&$(o)){const s=(u!==u?0:u===null?1:2)-(o!==o?0:o===null?1:2);return e?-s:s}return $(u)?e?-1:1:$(o)?e?1:-1:h.ascending(u,o)}function $(n){return n==null||n!==n}function E(n,t){return u=>{t=t!=null?t:{};const o={},c=Object.keys(n);for(const r of c)o[r]=n[r](u);if(t.rest&&u.length){const r=Object.keys(u[0]);for(const s of r)c.includes(s)||(o[s]=t.rest(s)(u))}return[o]}}function R(n,t,e,u){if(!n.length)return[];const o={};let c;if(u==null)c=Object.keys(n[0]);else{c=[];for(const r of S(u))typeof r=="function"?c.push(...r(n)):c.push(r)}for(const r of c){if(e){const s=n.map(f=>f[r]);if(!e(s))continue}o[r]=t(r)(n)}return[o]}function P(n){return e=>R(e,n)}function Y(n,t){return u=>R(u,t,n)}function Z(n,t){return u=>R(u,t,void 0,n)}function k(n){return e=>{const u=[];for(const o of e){const c={...o};for(const r in n){const s=n[r],f=typeof s=="function"?s(c):s;c[r]=f}u.push(c)}return u}}function dn(n,t){return u=>{const o=E(n)(u),c=k(t)(o);return[...u,...c]}}function yn(n,t){return u=>{const o=P(n)(u),c=k(t)(o);return[...u,...c]}}function pn(n,t,e){return o=>{const c=Y(n,t)(o),r=k(e)(c);return[...o,...r]}}function hn(n,t,e){return o=>{const c=Z(n,t)(o),r=k(e)(c);return[...o,...r]}}function T(n,t){return{...n,...t.reduce((e,u)=>(e[u[0]]=u[1],e),{})}}function D(n,t,e,u,o,c=0){for(const[r,s]of n.entries()){const f=[...e,r];if(s instanceof Map){const a=u(t,f,c);D(s,a,f,u,o,c+1)}else o(t,f,s,c)}return t}function gn(n,t,e=u=>u[u.length-1]){function u(r,s){const f=new Map;return r.set(e(s),f),f}function o(r,s,f){r.set(e(s),t(f,s))}const c=new Map;return D(n,c,[],u,o),c}const O=n=>n;function _(n,t,e){return o=>{const c=_n(o,n),r=vn(c,t,e==null?void 0:e.addGroupKeys);if(e==null?void 0:e.export)switch(e.export){case"grouped":return r;case"entries":return j(r,{...e,export:"levels",levels:["entries"]});case"entries-object":case"entries-obj":case"entriesObject":return j(r,{...e,export:"levels",levels:["entries-object"]});case"object":return j(r,{...e,export:"levels",levels:["object"]});case"map":return j(r,{...e,export:"levels",levels:["map"]});case"keys":return j(r,{...e,export:"levels",levels:["keys"]});case"values":return j(r,{...e,export:"levels",levels:["values"]});case"levels":return j(r,e)}return bn(r,e==null?void 0:e.addGroupKeys)}}_.grouped=n=>({...n,export:"grouped"}),_.entries=n=>({...n,export:"entries"}),_.entriesObject=n=>({...n,export:"entries-object"}),_.object=n=>({...n,export:"object"}),_.map=n=>({...n,export:"map"}),_.keys=n=>({...n,export:"keys"}),_.values=n=>({...n,export:"values"}),_.levels=n=>({...n,export:"levels"});function vn(n,t,e){let u=n;if(!(t==null?void 0:t.length))return u;for(const o of t)u=gn(u,(c,r)=>{let f=o(c,{groupKeys:r});return e!==!1&&(f=f.map(a=>T(a,r))),f});return u}function _n(n,t){const e=S(t).map((o,c)=>{let r;typeof o=="function"?r=o.name?o.name:`group_${c}`:r=o.toString();const s=typeof o=="function"?o:a=>a[o],f=new Map;return a=>{const i=s(a);if(f.has(i))return f.get(i);const m=[r,i];return f.set(i,m),m}});return h.group(n,...e)}function bn(n,t){const e=[];return D(n,e,[],O,(u,o,c)=>{let r=c;t!==!1&&(r=c.map(s=>T(s,o))),u.push(...r)}),e}const Sn=n=>n.join("/");function Mn(n){var t;const{flat:e,single:u,mapLeaf:o=O,mapLeaves:c=O,addGroupKeys:r}=n;let s;return n.flat&&(s=(t=n.compositeKey)!=null?t:Sn),{groupFn:(i,m)=>u?o(r===!1?i[0]:T(i[0],m)):c(i.map(d=>o(r===!1?d:T(d,m)))),keyFn:e?i=>s(i.map(m=>m[1])):i=>i[i.length-1][1]}}function j(n,t){const{groupFn:e,keyFn:u}=Mn(t);let{mapEntry:o=O}=t;const{levels:c=["entries"]}=t,r=[];for(const i of c)switch(i){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const m=(i==="entries-object"||i==="entries-obj"||i==="entriesObject")&&t.mapEntry==null?([d,y])=>({key:d,values:y}):o;r.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(d,y,g,b)=>{d.push(m([g,y],b))},addLeaf:(d,y,g,b)=>{d.push(m([y,g],b))}});break}case"map":r.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(m,d,y)=>{m.set(y,d)},addLeaf:(m,d,y)=>{m.set(d,y)}});break;case"object":r.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(m,d,y)=>{m[y]=d},addLeaf:(m,d,y)=>{m[d]=y}});break;case"keys":r.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(m,d,y)=>{m.push([y,d])},addLeaf:(m,d)=>{m.push(d)}});break;case"values":r.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(m,d)=>{m.push(d)},addLeaf:(m,d,y)=>{m.push(y)}});break;default:typeof i=="object"&&r.push(i)}const s=(i,m,d)=>{var y,g;if(t.flat)return i;const b=(y=r[d])!=null?y:r[r.length-1],A=((g=r[d+1])!=null?g:b).createEmptySubgroup();return b.addSubgroup(i,A,u(m),d),A},f=(i,m,d,y)=>{var g;((g=r[y])!=null?g:r[r.length-1]).addLeaf(i,u(m),e(d,m),y)},a=r[0].createEmptySubgroup();return D(n,a,[],s,f)}function Q(){return n=>n.length}function X(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.fsum(e,t)}function x(n){return e=>{const{name:u="n",wt:o}=n!=null?n:{};return E({[u]:o==null?Q():X(o)})(e)}}function jn(n,t){return u=>{t=t!=null?t:{};const{name:o="n",sort:c}=t;return z(u,_(n,[x(t)]),c?w(L(o)):O)}}function wn(n){return e=>e.map(u=>{var o;const c={},r=Object.keys(u);for(const s of r){const f=(o=n[s])!=null?o:s;c[f]=u[s]}return c})}function W(n,t){return u=>u.slice(n,t)}const kn=n=>W(0,n),Kn=n=>W(-n);function Fn(n,t){return u=>w(t)(u).slice(0,n)}function In(n,t){return u=>typeof t=="function"?w(t)(u).slice(-n).reverse():w(L(t))(u).slice(0,n)}function On(n,t){t=t!=null?t:{};const{replace:e}=t;return o=>{if(!o.length)return o.slice();if(e){const c=[];for(let r=0;r<n;++r)c.push(o[Math.floor(Math.random()*o.length)]);return c}return h.shuffle(o.slice()).slice(0,n)}}function U(n,t){if(n.length===0||t.length===0)return{};const e=Object.keys(n[0]),u=Object.keys(t[0]),o={};for(const c of e)u.includes(c)&&(o[c]=c);return o}function V(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function J(n,t,e){for(const u in e){const o=e[u];if(n[o]!==t[u])return!1}return!0}function An(n,t){return u=>{const o=(t==null?void 0:t.by)==null?U(u,n):V(t.by);return u.flatMap(r=>n.filter(f=>J(r,f,o)).map(f=>({...r,...f})))}}function nn(n,t){return u=>{const o=(t==null?void 0:t.by)==null?U(u,n):V(t.by);return u.flatMap(r=>{const s=n.filter(f=>J(r,f,o));return s.length?s.map(f=>({...r,...f})):r})}}function zn(n,t){return u=>{const o=(t==null?void 0:t.by)==null?U(u,n):V(t.by),c=new Map,r=u.flatMap(s=>{const f=n.filter(a=>{const i=J(s,a,o);return i&&c.set(a,!0),i});return f.length?f.map(a=>({...s,...a})):s});for(const s of n)c.has(s)||r.push(s);return r}}function $n(n){return e=>{const u=e.map(o=>({...o}));for(const o in n){const c=n[o],r=typeof c=="function"?c(u):c,s=(r==null?void 0:r[Symbol.iterator])&&typeof r!="string"?r:e.map(()=>r);let f=-1;for(const a of u)a[o]=s[++f]}return u}}function K(n){return n.length<1?[]:Object.keys(n[0])}function en(){return n=>K(n)}function tn(n,t){let e=[];for(const c of S(t))typeof c=="function"?e.push(...c(n)):e.push(c);e.length&&e[0][0]==="-"&&(e=[...en()(n),...e]);const u={},o=[];for(let c=e.length-1;c>=0;c--){const r=e[c];if(r[0]==="-"){u[r.substring(1)]=!0;continue}if(u[r]){u[r]=!1;continue}o.unshift(r)}return e=Array.from(new Set(o)),e}function N(n){return e=>{let u=tn(e,n);return u.length?e.map(o=>{const c={};for(const r of u)c[r]=o[r];return c}):e}}function Tn(n){return e=>{const u=k(n)(e);return N(Object.keys(n))(u)}}function un(n){return e=>typeof n=="function"?[...e,...S(n(e))]:[...e,...S(n)]}function Dn(n){return e=>{const{namesFrom:u,valuesFrom:o,valuesFill:c,valuesFillMap:r,namesSep:s="_"}=n,f=Array.isArray(u)?u:[u],a=Array.isArray(o)?o:[o],i=[];if(!e.length)return i;const m=Object.keys(e[0]).filter(p=>!f.includes(p)&&!a.includes(p)),d={};for(const p of e)for(const v of f)d[v]==null&&(d[v]={}),d[v][p[v]]=!0;const y=[];for(const p in d)y.push(Object.keys(d[p]));const g={},b=qn(s,y);for(const p of b){if(a.length===1){g[p]=r!=null?r[a[0]]:c;continue}for(const v of a)g[`${v}${s}${p}`]=r!=null?r[v]:c}function F(p){if(!p.length)return[];const v={...g};for(const M of m)v[M]=p[0][M];for(const M of p){const C=f.map(I=>M[I]).join(s);if(a.length===1){v[C]=M[a[0]];continue}for(const I of a)v[`${I}${s}${C}`]=M[I]}return[v]}return m.length?z(e,_(m,[F])):F(e)}}function qn(n="_",t){function e(o,c,r){if(!r.length&&c!=null){o.push(c);return}const s=r[0],f=r.slice(1);for(const a of s)e(o,c==null?a:`${c}${n}${a}`,f)}const u=[];return e(u,null,t),u}function Cn(n){return e=>{var u;const{namesTo:o,valuesTo:c,namesSep:r="_"}=n,s=(u=n.cols)!=null?u:[],f=tn(e,s),a=Array.isArray(o)?o:[o],i=Array.isArray(c)?c:[c],m=a.length>1,d=i.length>1,y=[];for(const g of e){const b=Object.keys(g).filter(p=>!f.includes(p)),F={};for(const p of b)F[p]=g[p];const A=d?Array.from(new Set(f.map(p=>p.substring(p.indexOf(r)+1)))):f;for(const p of A){const v={...F};for(const M of i){const C=d?`${M}${r}${p}`:p,I=m?p.split(r):[p];let ge=0;for(const ve of a){const _e=I[ge++];v[ve]=_e,v[M]=g[C]}}y.push(v)}}return y}}function rn(n){return e=>{const u=En(n),o=[];for(const c in u){const r=u[c];let s;typeof r=="function"?s=r(e):Array.isArray(r)?s=r:s=Array.from(new Set(e.map(f=>f[c]))),o.push(s.map(f=>({[c]:f})))}return Ln(o)}}function Ln(n){function t(u,o,c){if(!c.length&&o!=null){u.push(o);return}const r=c[0],s=c.slice(1);for(const f of r)t(u,{...o,...f},s)}const e=[];return t(e,null,n),e}function En(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function on(n,t=1){let[e,u]=h.extent(n);const o=[];let c=e;for(;c<=u;)o.push(c),c+=t;return o}function B(n,t="day",e=1){let[u,o]=h.extent(n);const c=[];let r=new Date(u);for(;r<=o;)if(c.push(new Date(r)),t==="second"||t==="s"||t==="seconds")r.setUTCSeconds(r.getUTCSeconds()+1*e);else if(t==="minute"||t==="min"||t==="minutes")r.setUTCMinutes(r.getUTCMinutes()+1*e);else if(t==="day"||t==="d"||t==="days")r.setUTCDate(r.getUTCDate()+1*e);else if(t==="week"||t==="w"||t==="weeks")r.setUTCDate(r.getUTCDate()+7*e);else if(t==="month"||t==="m"||t==="months")r.setUTCMonth(r.getUTCMonth()+1*e);else if(t==="year"||t==="y"||t==="years")r.setUTCFullYear(r.getUTCFullYear()+1*e);else throw new Error("Invalid granularity for date sequence: "+t);return c}function Rn(n,t){return function(u){t=t!=null?t:1;const o=typeof n=="function"?n:c=>c[n];return on(u.map(o),t)}}function Wn(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:r=>r[n];return B(o.map(c),t,e)}}function Un(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:r=>r[n];return B(o.map(r=>new Date(c(r))),t,e).map(r=>r.toISOString())}}function cn(n){return e=>{const u=[];for(const o of e){const c={...o};for(const r in n)c[r]==null&&(c[r]=n[r]);u.push(c)}return u}}function Vn(n,t){return u=>{const o=rn(n)(u),c=nn(u)(o);return t?cn(t)(c):c}}function Jn(n){return e=>{const u=S(n),o={};return e.map(c=>{const r={...c};for(const s of u)r[s]!=null?o[s]=r[s]:o[s]!=null&&(r[s]=o[s]);return r})}}function Nn(n,t){return(u,o)=>{var c;let r="[tidy.debug";if((c=o==null?void 0:o.groupKeys)==null?void 0:c.length){const y=o.groupKeys.map(g=>g.join(": ")).join(", ");y.length&&(r+="|"+y)}t=t!=null?t:{};const{limit:s=10,output:f="table"}=t,a="--------------------------------------------------------------------------------";let i=a.length;const m=r+"]"+(n==null?"":" "+n);return i=Math.max(0,i-(m.length+2)),console.log(`${m} ${a.substring(0,i)}`),console[f](s==null||s>=u.length?u:u.slice(0,s)),u}}function q(n,t,e){return n==null||t==null?void 0:t===0&&n===0?0:!e&&t===0?void 0:n/t}function Bn(n,t,e){return n==null||t==null?e?(n!=null?n:0)-(t!=null?t:0):void 0:n-t}function Gn(n,t,e){return n==null||t==null?e?(n!=null?n:0)+(t!=null?t:0):void 0:n+t}var Hn=Object.freeze({__proto__:null,rate:q,subtract:Bn,add:Gn});function Pn(n,t,e){const u=typeof n=="function"?n:s=>s[n],o=typeof t=="function"?t:s=>s[t],{predicate:c,allowDivideByZero:r}=e!=null?e:{};return c==null?s=>{const f=o(s),a=u(s);return q(a,f,r)}:s=>{if(!c(s))return;const f=o(s),a=u(s);return q(a,f,r)}}function Yn(n,t){let e=new h.Adder,u=0;return Float64Array.from(n,o=>e.add(+(t(o,u++,n)||0)))}function Zn(n,t){let e=0;for(let u=0;u<n.length;++u){const o=t(n[u],u,n);+o===o&&(e+=1)}return e?h.fsum(n,t)/e:void 0}function Qn(n){const t=typeof n=="function"?n:e=>e[n];return e=>Yn(e,t)}function Xn(n,t,e){const{partial:u=!1}=e!=null?e:{};return o=>o.map((c,r)=>{const s=r;if(!u&&s-n+1<0)return;const f=Math.max(0,s-n+1),a=o.slice(f,s+1);return t(a,s)})}function xn(n,t){const e=typeof n=="function"?n:c=>c[n],{n:u=1,default:o}=t!=null?t:{};return c=>c.map((r,s)=>{const f=c[s-u];return f==null?o:e(f)})}function ne(n,t){const e=typeof n=="function"?n:c=>c[n],{n:u=1,default:o}=t!=null?t:{};return c=>c.map((r,s)=>{const f=c[s+u];return f==null?o:e(f)})}function ee(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.min(e,t)}function te(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.max(e,t)}function ue(n){const t=typeof n=="function"?n:e=>e[n];return e=>Zn(e,t)}function re(n,t){const e=typeof n=="function"?n:o=>o[n],u=typeof t=="function"?t:o=>o[t];return o=>{const c=h.fsum(o,e),r=h.fsum(o,u);return q(c,r)}}function oe(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.median(e,t)}function ce(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.deviation(e,t)}function se(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.variance(e,t)}function le(n,t={}){const e=typeof n=="function"?n:u=>u[n];return u=>{const o=new Map;let c=0;for(const r of u){const s=e(r);if(!o.has(s)){if(!t.includeUndefined&&s===void 0||t.includeNull===!1&&s===null)continue;c+=1,o.set(s,!0)}}return c}}function fe(n){const t=typeof n=="function"?n:e=>e[n];return e=>e.length?t(e[0]):void 0}function ae(n){const t=typeof n=="function"?n:e=>e[n];return e=>e.length?t(e[e.length-1]):void 0}function ie(n,t=!0){return e=>{const u=new RegExp(`^${n}`,t?"i":void 0);return K(e).filter(c=>u.test(c))}}function me(n,t=!0){return e=>{const u=new RegExp(`${n}$`,t?"i":void 0);return K(e).filter(c=>u.test(c))}}function de(n,t=!0){return e=>{const u=new RegExp(n,t?"i":void 0);return K(e).filter(c=>u.test(c))}}function ye(n){return t=>K(t).filter(u=>n.test(u))}function pe(n,t,e){return u=>{const o=K(u),c=[];for(let r=t[0];r<=t[1];++r){const s=e==null?r:new String("00000000"+r).slice(-e);c.push(`${n}${s}`)}return o.filter(r=>c.includes(r))}}function he(n){return t=>{let e=new Set;for(const o of S(n))if(typeof o=="function"){const c=o(t);for(const r of c)e.add(r)}else e.add(o);return Array.from(e).map(o=>`-${o}`)}}l.TMath=Hn,l.addItems=un,l.addRows=un,l.arrange=w,l.asc=G,l.complete=Vn,l.contains=de,l.count=jn,l.cumsum=Qn,l.debug=Nn,l.desc=L,l.deviation=ce,l.distinct=an,l.endsWith=me,l.everything=en,l.expand=rn,l.fill=Jn,l.filter=sn,l.first=fe,l.fixedOrder=mn,l.fullJoin=zn,l.fullSeq=Rn,l.fullSeqDate=Wn,l.fullSeqDateISOString=Un,l.groupBy=_,l.innerJoin=An,l.lag=xn,l.last=ae,l.lead=ne,l.leftJoin=nn,l.map=fn,l.matches=ye,l.max=te,l.mean=ue,l.meanRate=re,l.median=oe,l.min=ee,l.mutate=k,l.mutateWithSummary=$n,l.n=Q,l.nDistinct=le,l.negate=he,l.numRange=pe,l.pick=N,l.pivotLonger=Cn,l.pivotWider=Dn,l.rate=Pn,l.rename=wn,l.replaceNully=cn,l.roll=Xn,l.select=N,l.slice=W,l.sliceHead=kn,l.sliceMax=In,l.sliceMin=Fn,l.sliceSample=On,l.sliceTail=Kn,l.sort=w,l.startsWith=ie,l.sum=X,l.summarize=E,l.summarizeAll=P,l.summarizeAt=Z,l.summarizeIf=Y,l.tally=x,l.tidy=z,l.total=dn,l.totalAll=yn,l.totalAt=hn,l.totalIf=pn,l.transmute=Tn,l.variance=se,l.vectorSeq=on,l.vectorSeqDate=B,l.when=ln,Object.defineProperty(l,"__esModule",{value:!0})});
(function(l,h){typeof exports=="object"&&typeof module!="undefined"?h(exports,require("d3-array")):typeof define=="function"&&define.amd?define(["exports","d3-array"],h):(l=typeof globalThis!="undefined"?globalThis:l||self,h(l.Tidy={},l.d3))})(this,function(l,h){"use strict";function O(n,...t){if(typeof n=="function")throw new Error("You must supply the data as the first argument to tidy()");let e=n;for(const u of t)u&&(e=u(e));return e}function sn(n){return e=>e.filter(n)}function ln(n,t){return u=>{if(typeof n=="function"){if(!n(u))return u}else if(!n)return u;return O(u,...t)}}function fn(n){return e=>e.map(n)}function S(n){return n==null?[]:Array.isArray(n)?n:[n]}function an(n){return e=>{if(n=S(n),!n.length){const r=new Set;for(const s of e)r.add(s);return Array.from(r)}const u=new Map,o=[],c=n[n.length-1];for(const r of e){let s=u,f=!1;for(const i of n){const a=typeof i=="function"?i(r):r[i];if(i===c){f=s.has(a),f||(o.push(r),s.set(a,!0));break}s.has(a)||s.set(a,new Map),s=s.get(a)}}return o}}function j(n){return e=>{const u=S(n).map(o=>typeof o=="function"?o:G(o));return e.slice().sort((o,c)=>{for(const r of u){const s=r(o,c);if(s)return s}return 0})}}function G(n){const t=typeof n=="function"?n:e=>e[n];return function(u,o){return H(t(u),t(o),!1)}}function C(n){const t=typeof n=="function"?n:e=>e[n];return function(u,o){return H(t(u),t(o),!0)}}function mn(n,t,e){let{position:u="start"}=e!=null?e:{};const o=u==="end"?-1:1,c=new Map;for(let s=0;s<t.length;++s)c.set(t[s],s);const r=typeof n=="function"?n:s=>s[n];return function(f,i){var a,d;const m=(a=c.get(r(f)))!=null?a:-1,y=(d=c.get(r(i)))!=null?d:-1;return m>=0&&y>=0?m-y:m>=0?o*-1:y>=0?o*1:0}}function H(n,t,e){let u=e?t:n,o=e?n:t;if(z(u)&&z(o)){const s=(u!==u?0:u===null?1:2)-(o!==o?0:o===null?1:2);return e?-s:s}return z(u)?e?-1:1:z(o)?e?1:-1:h.ascending(u,o)}function z(n){return n==null||n!==n}function L(n,t){return u=>{t=t!=null?t:{};const o={},c=Object.keys(n);for(const r of c)o[r]=n[r](u);if(t.rest&&u.length){const r=Object.keys(u[0]);for(const s of r)c.includes(s)||(o[s]=t.rest(s)(u))}return[o]}}function E(n,t,e,u){if(!n.length)return[];const o={};let c;if(u==null)c=Object.keys(n[0]);else{c=[];for(const r of S(u))typeof r=="function"?c.push(...r(n)):c.push(r)}for(const r of c){if(e){const s=n.map(f=>f[r]);if(!e(s))continue}o[r]=t(r)(n)}return[o]}function P(n){return e=>E(e,n)}function Y(n,t){return u=>E(u,t,n)}function Z(n,t){return u=>E(u,t,void 0,n)}function k(n){return e=>{const u=[];for(const o of e){const c={...o};for(const r in n){const s=n[r],f=typeof s=="function"?s(c):s;c[r]=f}u.push(c)}return u}}function dn(n,t){return u=>{const o=L(n)(u),c=k(t)(o);return[...u,...c]}}function yn(n,t){return u=>{const o=P(n)(u),c=k(t)(o);return[...u,...c]}}function pn(n,t,e){return o=>{const c=Y(n,t)(o),r=k(e)(c);return[...o,...r]}}function hn(n,t,e){return o=>{const c=Z(n,t)(o),r=k(e)(c);return[...o,...r]}}function $(n,t){if(n==null||typeof n!="object"||Array.isArray(n))return n;const e=Object.fromEntries(t.filter(u=>typeof u[0]!="function"));return Object.assign(e,n)}function T(n,t,e,u,o,c=0){for(const[r,s]of n.entries()){const f=[...e,r];if(s instanceof Map){const i=u(t,f,c);T(s,i,f,u,o,c+1)}else o(t,f,s,c)}return t}function gn(n,t,e=u=>u[u.length-1]){function u(r,s){const f=new Map;return r.set(e(s),f),f}function o(r,s,f){r.set(e(s),t(f,s))}const c=new Map;return T(n,c,[],u,o),c}const I=n=>n;function v(n,t,e){return typeof t=="function"?t=[t]:arguments.length===2&&t!=null&&!Array.isArray(t)&&(e=t),o=>{const c=vn(o,n),r=_n(c,t,e==null?void 0:e.addGroupKeys);if(e==null?void 0:e.export)switch(e.export){case"grouped":return r;case"levels":return R(r,e);case"entries-obj":case"entriesObject":return R(r,{...e,export:"levels",levels:["entries-object"]});default:return R(r,{...e,export:"levels",levels:[e.export]})}return bn(r,e==null?void 0:e.addGroupKeys)}}v.grouped=n=>({...n,export:"grouped"}),v.entries=n=>({...n,export:"entries"}),v.entriesObject=n=>({...n,export:"entries-object"}),v.object=n=>({...n,export:"object"}),v.map=n=>({...n,export:"map"}),v.keys=n=>({...n,export:"keys"}),v.values=n=>({...n,export:"values"}),v.levels=n=>({...n,export:"levels"});function _n(n,t,e){let u=n;if(!(t==null?void 0:t.length))return u;for(const o of t)!o||(u=gn(u,(c,r)=>{let f=o(c,{groupKeys:r});return e!==!1&&(f=f.map(i=>$(i,r))),f}));return u}function vn(n,t){const e=S(t).map((o,c)=>{const r=typeof o=="function"?o:f=>f[o],s=new Map;return f=>{const i=r(f);if(s.has(i))return s.get(i);const a=[o,i];return s.set(i,a),a}});return h.group(n,...e)}function bn(n,t){const e=[];return T(n,e,[],I,(u,o,c)=>{let r=c;t!==!1&&(r=c.map(s=>$(s,o))),u.push(...r)}),e}const Sn=n=>n.join("/");function Mn(n){var t;const{flat:e,single:u,mapLeaf:o=I,mapLeaves:c=I,addGroupKeys:r}=n;let s;return n.flat&&(s=(t=n.compositeKey)!=null?t:Sn),{groupFn:(a,d)=>u?o(r===!1?a[0]:$(a[0],d)):c(a.map(m=>o(r===!1?m:$(m,d)))),keyFn:e?a=>s(a.map(d=>d[1])):a=>a[a.length-1][1]}}function R(n,t){const{groupFn:e,keyFn:u}=Mn(t);let{mapEntry:o=I}=t;const{levels:c=["entries"]}=t,r=[];for(const a of c)switch(a){case"entries":case"entries-object":case"entries-obj":case"entriesObject":{const d=(a==="entries-object"||a==="entries-obj"||a==="entriesObject")&&t.mapEntry==null?([m,y])=>({key:m,values:y}):o;r.push({id:"entries",createEmptySubgroup:()=>[],addSubgroup:(m,y,g,b)=>{m.push(d([g,y],b))},addLeaf:(m,y,g,b)=>{m.push(d([y,g],b))}});break}case"map":r.push({id:"map",createEmptySubgroup:()=>new Map,addSubgroup:(d,m,y)=>{d.set(y,m)},addLeaf:(d,m,y)=>{d.set(m,y)}});break;case"object":r.push({id:"object",createEmptySubgroup:()=>({}),addSubgroup:(d,m,y)=>{d[y]=m},addLeaf:(d,m,y)=>{d[m]=y}});break;case"keys":r.push({id:"keys",createEmptySubgroup:()=>[],addSubgroup:(d,m,y)=>{d.push([y,m])},addLeaf:(d,m)=>{d.push(m)}});break;case"values":r.push({id:"values",createEmptySubgroup:()=>[],addSubgroup:(d,m)=>{d.push(m)},addLeaf:(d,m,y)=>{d.push(y)}});break;default:typeof a=="object"&&r.push(a)}const s=(a,d,m)=>{var y,g;if(t.flat)return a;const b=(y=r[m])!=null?y:r[r.length-1],A=((g=r[m+1])!=null?g:b).createEmptySubgroup();return b.addSubgroup(a,A,u(d),m),A},f=(a,d,m,y)=>{var g;((g=r[y])!=null?g:r[r.length-1]).addLeaf(a,u(d),e(m,d),y)},i=r[0].createEmptySubgroup();return T(n,i,[],s,f)}function Q(){return n=>n.length}function X(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.fsum(e,t)}function x(n){return e=>{const{name:u="n",wt:o}=n!=null?n:{};return L({[u]:o==null?Q():X(o)})(e)}}function jn(n,t){return u=>{t=t!=null?t:{};const{name:o="n",sort:c}=t;return O(u,v(n,[x(t)]),c?j(C(o)):I)}}function kn(n){return e=>e.map(u=>{var o;const c={},r=Object.keys(u);for(const s of r){const f=(o=n[s])!=null?o:s;c[f]=u[s]}return c})}function W(n,t){return u=>u.slice(n,t)}const wn=n=>W(0,n),Fn=n=>W(-n);function Kn(n,t){return u=>j(t)(u).slice(0,n)}function In(n,t){return u=>typeof t=="function"?j(t)(u).slice(-n).reverse():j(C(t))(u).slice(0,n)}function An(n,t){t=t!=null?t:{};const{replace:e}=t;return o=>{if(!o.length)return o.slice();if(e){const c=[];for(let r=0;r<n;++r)c.push(o[Math.floor(Math.random()*o.length)]);return c}return h.shuffle(o.slice()).slice(0,n)}}function U(n,t){if(n.length===0||t.length===0)return{};const e=Object.keys(n[0]),u=Object.keys(t[0]),o={};for(const c of e)u.includes(c)&&(o[c]=c);return o}function V(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function J(n,t,e){for(const u in e){const o=e[u];if(n[o]!==t[u])return!1}return!0}function On(n,t){return u=>{const o=(t==null?void 0:t.by)==null?U(u,n):V(t.by);return u.flatMap(r=>n.filter(f=>J(r,f,o)).map(f=>({...r,...f})))}}function nn(n,t){return u=>{const o=(t==null?void 0:t.by)==null?U(u,n):V(t.by);return u.flatMap(r=>{const s=n.filter(f=>J(r,f,o));return s.length?s.map(f=>({...r,...f})):r})}}function zn(n,t){return u=>{const o=(t==null?void 0:t.by)==null?U(u,n):V(t.by),c=new Map,r=u.flatMap(s=>{const f=n.filter(i=>{const a=J(s,i,o);return a&&c.set(i,!0),a});return f.length?f.map(i=>({...s,...i})):s});for(const s of n)c.has(s)||r.push(s);return r}}function $n(n){return e=>{const u=e.map(o=>({...o}));for(const o in n){const c=n[o],r=typeof c=="function"?c(u):c,s=(r==null?void 0:r[Symbol.iterator])&&typeof r!="string"?r:e.map(()=>r);let f=-1;for(const i of u)i[o]=s[++f]}return u}}function w(n){return n.length<1?[]:Object.keys(n[0])}function tn(){return n=>w(n)}function en(n,t){let e=[];for(const c of S(t))typeof c=="function"?e.push(...c(n)):e.push(c);e.length&&e[0][0]==="-"&&(e=[...tn()(n),...e]);const u={},o=[];for(let c=e.length-1;c>=0;c--){const r=e[c];if(r[0]==="-"){u[r.substring(1)]=!0;continue}if(u[r]){u[r]=!1;continue}o.unshift(r)}return e=Array.from(new Set(o)),e}function B(n){return e=>{let u=en(e,n);return u.length?e.map(o=>{const c={};for(const r of u)c[r]=o[r];return c}):e}}function Tn(n){return e=>{const u=k(n)(e);return B(Object.keys(n))(u)}}function un(n){return e=>typeof n=="function"?[...e,...S(n(e))]:[...e,...S(n)]}function Dn(n){return e=>{const{namesFrom:u,valuesFrom:o,valuesFill:c,valuesFillMap:r,namesSep:s="_"}=n,f=Array.isArray(u)?u:[u],i=Array.isArray(o)?o:[o],a=[];if(!e.length)return a;const d=Object.keys(e[0]).filter(p=>!f.includes(p)&&!i.includes(p)),m={};for(const p of e)for(const _ of f)m[_]==null&&(m[_]={}),m[_][p[_]]=!0;const y=[];for(const p in m)y.push(Object.keys(m[p]));const g={},b=qn(s,y);for(const p of b){if(i.length===1){g[p]=r!=null?r[i[0]]:c;continue}for(const _ of i)g[`${_}${s}${p}`]=r!=null?r[_]:c}function F(p){if(!p.length)return[];const _={...g};for(const M of d)_[M]=p[0][M];for(const M of p){const q=f.map(K=>M[K]).join(s);if(i.length===1){_[q]=M[i[0]];continue}for(const K of i)_[`${K}${s}${q}`]=M[K]}return[_]}return d.length?O(e,v(d,[F])):F(e)}}function qn(n="_",t){function e(o,c,r){if(!r.length&&c!=null){o.push(c);return}const s=r[0],f=r.slice(1);for(const i of s)e(o,c==null?i:`${c}${n}${i}`,f)}const u=[];return e(u,null,t),u}function Cn(n){return e=>{var u;const{namesTo:o,valuesTo:c,namesSep:r="_"}=n,s=(u=n.cols)!=null?u:[],f=en(e,s),i=Array.isArray(o)?o:[o],a=Array.isArray(c)?c:[c],d=i.length>1,m=a.length>1,y=[];for(const g of e){const b=Object.keys(g).filter(p=>!f.includes(p)),F={};for(const p of b)F[p]=g[p];const A=m?Array.from(new Set(f.map(p=>p.substring(p.indexOf(r)+1)))):f;for(const p of A){const _={...F};for(const M of a){const q=m?`${M}${r}${p}`:p,K=d?p.split(r):[p];let gt=0;for(const _t of i){const vt=K[gt++];_[_t]=vt,_[M]=g[q]}}y.push(_)}}return y}}function on(n){return e=>{const u=En(n),o=[];for(const c in u){const r=u[c];let s;typeof r=="function"?s=r(e):Array.isArray(r)?s=r:s=Array.from(new Set(e.map(f=>f[c]))),o.push(s.map(f=>({[c]:f})))}return Ln(o)}}function Ln(n){function t(u,o,c){if(!c.length&&o!=null){u.push(o);return}const r=c[0],s=c.slice(1);for(const f of r)t(u,{...o,...f},s)}const e=[];return t(e,null,n),e}function En(n){if(Array.isArray(n)){const t={};for(const e of n)t[e]=e;return t}else if(typeof n=="object")return n;return{[n]:n}}function rn(n,t=1){let[e,u]=h.extent(n);const o=[];let c=e;for(;c<=u;)o.push(c),c+=t;return o}function N(n,t="day",e=1){let[u,o]=h.extent(n);const c=[];let r=new Date(u);for(;r<=o;)if(c.push(new Date(r)),t==="second"||t==="s"||t==="seconds")r.setUTCSeconds(r.getUTCSeconds()+1*e);else if(t==="minute"||t==="min"||t==="minutes")r.setUTCMinutes(r.getUTCMinutes()+1*e);else if(t==="day"||t==="d"||t==="days")r.setUTCDate(r.getUTCDate()+1*e);else if(t==="week"||t==="w"||t==="weeks")r.setUTCDate(r.getUTCDate()+7*e);else if(t==="month"||t==="m"||t==="months")r.setUTCMonth(r.getUTCMonth()+1*e);else if(t==="year"||t==="y"||t==="years")r.setUTCFullYear(r.getUTCFullYear()+1*e);else throw new Error("Invalid granularity for date sequence: "+t);return c}function Rn(n,t){return function(u){t=t!=null?t:1;const o=typeof n=="function"?n:c=>c[n];return rn(u.map(o),t)}}function Wn(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:r=>r[n];return N(o.map(c),t,e)}}function Un(n,t,e){return function(o){t=t!=null?t:"day",e=e!=null?e:1;const c=typeof n=="function"?n:r=>r[n];return N(o.map(r=>new Date(c(r))),t,e).map(r=>r.toISOString())}}function cn(n){return e=>{const u=[];for(const o of e){const c={...o};for(const r in n)c[r]==null&&(c[r]=n[r]);u.push(c)}return u}}function Vn(n,t){return u=>{const o=on(n)(u),c=nn(u)(o);return t?cn(t)(c):c}}function Jn(n){return e=>{const u=S(n),o={};return e.map(c=>{const r={...c};for(const s of u)r[s]!=null?o[s]=r[s]:o[s]!=null&&(r[s]=o[s]);return r})}}function Bn(n,t){return(u,o)=>{var c;let r="[tidy.debug";if((c=o==null?void 0:o.groupKeys)==null?void 0:c.length){const y=o.groupKeys.map(g=>g.join(": ")).join(", ");y.length&&(r+="|"+y)}t=t!=null?t:{};const{limit:s=10,output:f="table"}=t,i="--------------------------------------------------------------------------------";let a=i.length;const d=r+"]"+(n==null?"":" "+n);return a=Math.max(0,a-(d.length+2)),console.log(`${d} ${i.substring(0,a)}`),console[f](s==null||s>=u.length?u:u.slice(0,s)),u}}function D(n,t,e){return n==null||t==null?void 0:t===0&&n===0?0:!e&&t===0?void 0:n/t}function Nn(n,t,e){return n==null||t==null?e?(n!=null?n:0)-(t!=null?t:0):void 0:n-t}function Gn(n,t,e){return n==null||t==null?e?(n!=null?n:0)+(t!=null?t:0):void 0:n+t}var Hn=Object.freeze({__proto__:null,rate:D,subtract:Nn,add:Gn});function Pn(n,t,e){const u=typeof n=="function"?n:s=>s[n],o=typeof t=="function"?t:s=>s[t],{predicate:c,allowDivideByZero:r}=e!=null?e:{};return c==null?s=>{const f=o(s),i=u(s);return D(i,f,r)}:s=>{if(!c(s))return;const f=o(s),i=u(s);return D(i,f,r)}}function Yn(n,t){let e=new h.Adder,u=0;return Float64Array.from(n,o=>e.add(+(t(o,u++,n)||0)))}function Zn(n,t){let e=0;for(let u=0;u<n.length;++u){const o=t(n[u],u,n);+o===o&&(e+=1)}return e?h.fsum(n,t)/e:void 0}function Qn(n){const t=typeof n=="function"?n:e=>e[n];return e=>Yn(e,t)}function Xn(n,t,e){const{partial:u=!1}=e!=null?e:{};return o=>o.map((c,r)=>{const s=r;if(!u&&s-n+1<0)return;const f=Math.max(0,s-n+1),i=o.slice(f,s+1);return t(i,s)})}function xn(n,t){const e=typeof n=="function"?n:c=>c[n],{n:u=1,default:o}=t!=null?t:{};return c=>c.map((r,s)=>{const f=c[s-u];return f==null?o:e(f)})}function nt(n,t){const e=typeof n=="function"?n:c=>c[n],{n:u=1,default:o}=t!=null?t:{};return c=>c.map((r,s)=>{const f=c[s+u];return f==null?o:e(f)})}function tt(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.min(e,t)}function et(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.max(e,t)}function ut(n){const t=typeof n=="function"?n:e=>e[n];return e=>Zn(e,t)}function ot(n,t){const e=typeof n=="function"?n:o=>o[n],u=typeof t=="function"?t:o=>o[t];return o=>{const c=h.fsum(o,e),r=h.fsum(o,u);return D(c,r)}}function rt(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.median(e,t)}function ct(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.deviation(e,t)}function st(n){const t=typeof n=="function"?n:e=>e[n];return e=>h.variance(e,t)}function lt(n,t={}){const e=typeof n=="function"?n:u=>u[n];return u=>{const o=new Map;let c=0;for(const r of u){const s=e(r);if(!o.has(s)){if(!t.includeUndefined&&s===void 0||t.includeNull===!1&&s===null)continue;c+=1,o.set(s,!0)}}return c}}function ft(n){const t=typeof n=="function"?n:e=>e[n];return e=>e.length?t(e[0]):void 0}function it(n){const t=typeof n=="function"?n:e=>e[n];return e=>e.length?t(e[e.length-1]):void 0}function at(n,t=!0){return e=>{const u=new RegExp(`^${n}`,t?"i":void 0);return w(e).filter(c=>u.test(c))}}function mt(n,t=!0){return e=>{const u=new RegExp(`${n}$`,t?"i":void 0);return w(e).filter(c=>u.test(c))}}function dt(n,t=!0){return e=>{const u=new RegExp(n,t?"i":void 0);return w(e).filter(c=>u.test(c))}}function yt(n){return t=>w(t).filter(u=>n.test(u))}function pt(n,t,e){return u=>{const o=w(u),c=[];for(let r=t[0];r<=t[1];++r){const s=e==null?r:new String("00000000"+r).slice(-e);c.push(`${n}${s}`)}return o.filter(r=>c.includes(r))}}function ht(n){return t=>{let e=new Set;for(const o of S(n))if(typeof o=="function"){const c=o(t);for(const r of c)e.add(r)}else e.add(o);return Array.from(e).map(o=>`-${o}`)}}l.TMath=Hn,l.addItems=un,l.addRows=un,l.arrange=j,l.asc=G,l.complete=Vn,l.contains=dt,l.count=jn,l.cumsum=Qn,l.debug=Bn,l.desc=C,l.deviation=ct,l.distinct=an,l.endsWith=mt,l.everything=tn,l.expand=on,l.fill=Jn,l.filter=sn,l.first=ft,l.fixedOrder=mn,l.fullJoin=zn,l.fullSeq=Rn,l.fullSeqDate=Wn,l.fullSeqDateISOString=Un,l.groupBy=v,l.innerJoin=On,l.lag=xn,l.last=it,l.lead=nt,l.leftJoin=nn,l.map=fn,l.matches=yt,l.max=et,l.mean=ut,l.meanRate=ot,l.median=rt,l.min=tt,l.mutate=k,l.mutateWithSummary=$n,l.n=Q,l.nDistinct=lt,l.negate=ht,l.numRange=pt,l.pick=B,l.pivotLonger=Cn,l.pivotWider=Dn,l.rate=Pn,l.rename=kn,l.replaceNully=cn,l.roll=Xn,l.select=B,l.slice=W,l.sliceHead=wn,l.sliceMax=In,l.sliceMin=Kn,l.sliceSample=An,l.sliceTail=Fn,l.sort=j,l.startsWith=at,l.sum=X,l.summarize=L,l.summarizeAll=P,l.summarizeAt=Z,l.summarizeIf=Y,l.tally=x,l.tidy=O,l.total=dn,l.totalAll=yn,l.totalAt=hn,l.totalIf=pn,l.transmute=Tn,l.variance=st,l.vectorSeq=rn,l.vectorSeqDate=N,l.when=ln,Object.defineProperty(l,"__esModule",{value:!0})});
//# sourceMappingURL=tidy.min.js.map
{
"name": "@tidyjs/tidy",
"version": "2.3.1",
"version": "2.4.0",
"description": "Tidy up your data with JavaScript, inspired by dplyr and the tidyverse",

@@ -47,3 +47,3 @@ "main": "dist/lib/index.js",

},
"gitHead": "efce90735c23307a88da679826b261818490d476"
"gitHead": "72eaf3b5f4ad14fae85507a65111e2c8368208ff"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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