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.4.6 to 2.5.0

dist/es/vector/rowNumber.js

1

dist/es/index.js

@@ -35,2 +35,3 @@ export { tidy } from './tidy.js';

export { lead } from './vector/lead.js';
export { rowNumber } from './vector/rowNumber.js';
export { sum } from './summary/sum.js';

@@ -37,0 +38,0 @@ export { min } from './summary/min.js';

14

dist/es/item/rate.js

@@ -7,11 +7,11 @@ import { rate as rate$1 } from '../math/math.js';

const {predicate, allowDivideByZero} = options != null ? options : {};
return predicate == null ? (d) => {
const denom = denominatorFn(d);
const numer = numeratorFn(d);
return predicate == null ? (d, index, array) => {
const denom = denominatorFn(d, index, array);
const numer = numeratorFn(d, index, array);
return rate$1(numer, denom, allowDivideByZero);
} : (d) => {
if (!predicate(d))
} : (d, index, array) => {
if (!predicate(d, index, array))
return void 0;
const denom = denominatorFn(d);
const numer = numeratorFn(d);
const denom = denominatorFn(d, index, array);
const numer = numeratorFn(d, index, array);
return rate$1(numer, denom, allowDivideByZero);

@@ -18,0 +18,0 @@ };

function mutate(mutateSpec) {
const _mutate = (items) => {
const mutatedItems = [];
for (const item of items) {
const mutatedItem = {...item};
const mutatedItems = items.map((d) => ({...d}));
let i = 0;
for (const mutatedItem of mutatedItems) {
for (const key in mutateSpec) {
const mutateSpecValue = mutateSpec[key];
const mutatedResult = typeof mutateSpecValue === "function" ? mutateSpecValue(mutatedItem) : mutateSpecValue;
const mutatedResult = typeof mutateSpecValue === "function" ? mutateSpecValue(mutatedItem, i, mutatedItems) : mutateSpecValue;
mutatedItem[key] = mutatedResult;
}
mutatedItems.push(mutatedItem);
++i;
}

@@ -13,0 +13,0 @@ return mutatedItems;

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

function n() {
function n(options) {
if (options == null ? void 0 : options.predicate) {
const predicate = options.predicate;
return (items) => items.reduce((n2, d, i) => predicate(d, i, items) ? n2 + 1 : n2, 0);
}
return (items) => items.length;

@@ -3,0 +7,0 @@ }

@@ -6,4 +6,5 @@ function nDistinct(key, options = {}) {

let count = 0;
let i = 0;
for (const item of items) {
const value = keyFn(item);
const value = keyFn(item, i++, items);
if (!uniques.has(value)) {

@@ -10,0 +11,0 @@ if (!options.includeUndefined && value === void 0 || options.includeNull === false && value === null) {

import { fsum } from 'd3-array';
function sum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
function sum(key, options) {
let keyFn = typeof key === "function" ? key : (d) => d[key];
if (options == null ? void 0 : options.predicate) {
const originalKeyFn = keyFn;
const predicate = options.predicate;
keyFn = (d, index, array) => predicate(d, index, array) ? originalKeyFn(d, index, array) : 0;
}
return (items) => fsum(items, keyFn);

@@ -6,0 +11,0 @@ }

@@ -7,3 +7,3 @@ function lag(key, options) {

const lagItem = items[i - n];
return lagItem == null ? defaultValue : keyFn(lagItem);
return lagItem == null ? defaultValue : keyFn(lagItem, i, items);
});

@@ -10,0 +10,0 @@ };

@@ -7,3 +7,3 @@ function lead(key, options) {

const leadItem = items[i + n];
return leadItem == null ? defaultValue : keyFn(leadItem);
return leadItem == null ? defaultValue : keyFn(leadItem, i, items);
});

@@ -10,0 +10,0 @@ };

@@ -39,2 +39,3 @@ 'use strict';

var lead = require('./vector/lead.js');
var rowNumber = require('./vector/rowNumber.js');
var sum = require('./summary/sum.js');

@@ -118,2 +119,3 @@ var min = require('./summary/min.js');

exports.lead = lead.lead;
exports.rowNumber = rowNumber.rowNumber;
exports.sum = sum.sum;

@@ -120,0 +122,0 @@ exports.min = min.min;

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

const {predicate, allowDivideByZero} = options != null ? options : {};
return predicate == null ? (d) => {
const denom = denominatorFn(d);
const numer = numeratorFn(d);
return predicate == null ? (d, index, array) => {
const denom = denominatorFn(d, index, array);
const numer = numeratorFn(d, index, array);
return math.rate(numer, denom, allowDivideByZero);
} : (d) => {
if (!predicate(d))
} : (d, index, array) => {
if (!predicate(d, index, array))
return void 0;
const denom = denominatorFn(d);
const numer = numeratorFn(d);
const denom = denominatorFn(d, index, array);
const numer = numeratorFn(d, index, array);
return math.rate(numer, denom, allowDivideByZero);

@@ -22,0 +22,0 @@ };

@@ -7,11 +7,11 @@ 'use strict';

const _mutate = (items) => {
const mutatedItems = [];
for (const item of items) {
const mutatedItem = {...item};
const mutatedItems = items.map((d) => ({...d}));
let i = 0;
for (const mutatedItem of mutatedItems) {
for (const key in mutateSpec) {
const mutateSpecValue = mutateSpec[key];
const mutatedResult = typeof mutateSpecValue === "function" ? mutateSpecValue(mutatedItem) : mutateSpecValue;
const mutatedResult = typeof mutateSpecValue === "function" ? mutateSpecValue(mutatedItem, i, mutatedItems) : mutateSpecValue;
mutatedItem[key] = mutatedResult;
}
mutatedItems.push(mutatedItem);
++i;
}

@@ -18,0 +18,0 @@ return mutatedItems;

@@ -5,3 +5,7 @@ 'use strict';

function n() {
function n(options) {
if (options == null ? void 0 : options.predicate) {
const predicate = options.predicate;
return (items) => items.reduce((n2, d, i) => predicate(d, i, items) ? n2 + 1 : n2, 0);
}
return (items) => items.length;

@@ -8,0 +12,0 @@ }

@@ -10,4 +10,5 @@ 'use strict';

let count = 0;
let i = 0;
for (const item of items) {
const value = keyFn(item);
const value = keyFn(item, i++, items);
if (!uniques.has(value)) {

@@ -14,0 +15,0 @@ if (!options.includeUndefined && value === void 0 || options.includeNull === false && value === null) {

@@ -7,4 +7,9 @@ 'use strict';

function sum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
function sum(key, options) {
let keyFn = typeof key === "function" ? key : (d) => d[key];
if (options == null ? void 0 : options.predicate) {
const originalKeyFn = keyFn;
const predicate = options.predicate;
keyFn = (d, index, array) => predicate(d, index, array) ? originalKeyFn(d, index, array) : 0;
}
return (items) => d3Array.fsum(items, keyFn);

@@ -11,0 +16,0 @@ }

@@ -11,3 +11,3 @@ 'use strict';

const lagItem = items[i - n];
return lagItem == null ? defaultValue : keyFn(lagItem);
return lagItem == null ? defaultValue : keyFn(lagItem, i, items);
});

@@ -14,0 +14,0 @@ };

@@ -11,3 +11,3 @@ 'use strict';

const leadItem = items[i + n];
return leadItem == null ? defaultValue : keyFn(leadItem);
return leadItem == null ? defaultValue : keyFn(leadItem, i, items);
});

@@ -14,0 +14,0 @@ };

@@ -220,11 +220,11 @@ (function (global, factory) {

const _mutate = (items) => {
const mutatedItems = [];
for (const item of items) {
const mutatedItem = {...item};
const mutatedItems = items.map((d) => ({...d}));
let i = 0;
for (const mutatedItem of mutatedItems) {
for (const key in mutateSpec) {
const mutateSpecValue = mutateSpec[key];
const mutatedResult = typeof mutateSpecValue === "function" ? mutateSpecValue(mutatedItem) : mutateSpecValue;
const mutatedResult = typeof mutateSpecValue === "function" ? mutateSpecValue(mutatedItem, i, mutatedItems) : mutateSpecValue;
mutatedItem[key] = mutatedResult;
}
mutatedItems.push(mutatedItem);
++i;
}

@@ -519,8 +519,17 @@ return mutatedItems;

function n() {
function n(options) {
if (options == null ? void 0 : options.predicate) {
const predicate = options.predicate;
return (items) => items.reduce((n2, d, i) => predicate(d, i, items) ? n2 + 1 : n2, 0);
}
return (items) => items.length;
}
function sum(key) {
const keyFn = typeof key === "function" ? key : (d) => d[key];
function sum(key, options) {
let keyFn = typeof key === "function" ? key : (d) => d[key];
if (options == null ? void 0 : options.predicate) {
const originalKeyFn = keyFn;
const predicate = options.predicate;
keyFn = (d, index, array) => predicate(d, index, array) ? originalKeyFn(d, index, array) : 0;
}
return (items) => d3Array.fsum(items, keyFn);

@@ -1110,11 +1119,11 @@ }

const {predicate, allowDivideByZero} = options != null ? options : {};
return predicate == null ? (d) => {
const denom = denominatorFn(d);
const numer = numeratorFn(d);
return predicate == null ? (d, index, array) => {
const denom = denominatorFn(d, index, array);
const numer = numeratorFn(d, index, array);
return rate(numer, denom, allowDivideByZero);
} : (d) => {
if (!predicate(d))
} : (d, index, array) => {
if (!predicate(d, index, array))
return void 0;
const denom = denominatorFn(d);
const numer = numeratorFn(d);
const denom = denominatorFn(d, index, array);
const numer = numeratorFn(d, index, array);
return rate(numer, denom, allowDivideByZero);

@@ -1166,3 +1175,3 @@ };

const lagItem = items[i - n];
return lagItem == null ? defaultValue : keyFn(lagItem);
return lagItem == null ? defaultValue : keyFn(lagItem, i, items);
});

@@ -1178,3 +1187,3 @@ };

const leadItem = items[i + n];
return leadItem == null ? defaultValue : keyFn(leadItem);
return leadItem == null ? defaultValue : keyFn(leadItem, i, items);
});

@@ -1184,2 +1193,10 @@ };

function rowNumber(options) {
var _a;
const startAt = (_a = options == null ? void 0 : options.startAt) != null ? _a : 0;
return (items) => {
return items.map((_, i) => i + startAt);
};
}
function min(key) {

@@ -1230,4 +1247,5 @@ const keyFn = typeof key === "function" ? key : (d) => d[key];

let count = 0;
let i = 0;
for (const item of items) {
const value = keyFn(item);
const value = keyFn(item, i++, items);
if (!uniques.has(value)) {

@@ -1366,2 +1384,3 @@ if (!options.includeUndefined && value === void 0 || options.includeNull === false && value === null) {

exports.roll = roll;
exports.rowNumber = rowNumber;
exports.select = select;

@@ -1368,0 +1387,0 @@ exports.slice = slice;

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

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

},
"gitHead": "fe7b8e4619ec6615a7c50448fb905a587274e71a"
"gitHead": "12bd8e5b62f4c943c3c90218076f6dd0465f35a7"
}

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 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 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 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 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 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